APIdia Launch Partner
Top Description Fields Constructors Methods
javax.tools

public Class ForwardingJavaFileManager<M extends JavaFileManager>

extends Object
implements JavaFileManager
Class Inheritance
All Implemented Interfaces
javax.tools.JavaFileManager, javax.tools.OptionChecker, java.io.Flushable, java.io.Closeable, java.lang.AutoCloseable
Type Parameters
<M>
the kind of file manager forwarded to by this object
Imports
java.io.IOException, java.lang.reflect.Method, java.util.Iterator, .Objects, .ServiceLoader, .Set, javax.tools.JavaFileObject.Kind

Forwards calls to a given file manager. Subclasses of this class might override some of these methods and might also provide additional fields and methods.

Unless stated otherwise, references in this class to "this file manager" should be interpreted as referring indirectly to the delegate file manager.

Since
1.6

Field Summary

Modifier and TypeField and Description
protected final M
fileManager

The file manager to which all methods are delegated.

Constructor Summary

AccessConstructor and Description
protected
ForwardingJavaFileManager(M
delegate to this file manager
fileManager
)

Creates a new instance of ForwardingJavaFileManager.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements javax.tools.JavaFileManager.close.

Releases any resources opened by this file manager directly or indirectly.

public boolean
contains(JavaFileManager.Location location, FileObject fo)

Overrides default javax.tools.JavaFileManager.contains.

Determines whether or not a given file object is "contained in" a specified location.

public void
flush()

Implements javax.tools.JavaFileManager.flush.

Flushes any resources opened for output by this file manager directly or indirectly.

public ClassLoader
getClassLoader(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.getClassLoader.

Returns a class loader for loading plug-ins from the given package-oriented location.

public FileObject
getFileForInput(JavaFileManager.Location location, String packageName, String relativeName)

Implements javax.tools.JavaFileManager.getFileForInput.

Returns a file object for input representing the specified relative name in the specified package in the given package-oriented location.

public FileObject
getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling)

Implements javax.tools.JavaFileManager.getFileForOutput.

Returns a file object for output representing the specified relative name in the specified package in the given location.

public FileObject
getFileForOutputForOriginatingFiles(JavaFileManager.Location location, String packageName, String relativeName, FileObject... originatingFiles)

Overrides default javax.tools.JavaFileManager.getFileForOutputForOriginatingFiles.

Returns a file object for output representing the specified relative name in the specified package in the given location.

public JavaFileObject
getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind)

Implements javax.tools.JavaFileManager.getJavaFileForInput.

Returns a file object for input representing the specified class of the specified kind in the given package-oriented location.

public JavaFileObject
getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling)

Implements javax.tools.JavaFileManager.getJavaFileForOutput.

Returns a file object for output representing the specified class of the specified kind in the given package-oriented location.

public JavaFileObject
getJavaFileForOutputForOriginatingFiles(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject... originatingFiles)

Overrides default javax.tools.JavaFileManager.getJavaFileForOutputForOriginatingFiles.

Returns a file object for output representing the specified class of the specified kind in the given package-oriented location.

public JavaFileManager.Location
getLocationForModule(JavaFileManager.Location location, String moduleName)

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Gets a location for a named module within a location, which may be either a module-oriented location or an output location.

public JavaFileManager.Location
getLocationForModule(JavaFileManager.Location location, JavaFileObject fo)

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Gets a location for the module containing a specific file to be found within a location, which may be either a module-oriented location or an output location.

public <S> ServiceLoader<S>
getServiceLoader(JavaFileManager.Location location, Class<S> service)

Overrides default javax.tools.JavaFileManager.getServiceLoader.

Get a service loader for a specific service class from a given location.

public boolean
handleOption(String current, Iterator<String> remaining)

Implements javax.tools.JavaFileManager.handleOption.

Handles one option.

public boolean
hasLocation(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.hasLocation.

Determines if a location is known to this file manager.

public String
inferBinaryName(JavaFileManager.Location location, JavaFileObject file)

Implements javax.tools.JavaFileManager.inferBinaryName.

Infers a binary name of a file object based on a package-oriented location.

public String
inferModuleName(JavaFileManager.Location location)

Overrides default javax.tools.JavaFileManager.inferModuleName.

Infer the name of the module from its location, as returned by getLocationForModule or listModuleLocations.

public boolean
isSameFile(FileObject a, FileObject b)

Implements javax.tools.JavaFileManager.isSameFile.

Compares two file objects and returns true if they represent the same underlying object.

public int
isSupportedOption(String option)

Implements javax.tools.OptionChecker.isSupportedOption.

Determines if the given option is supported and if so, the number of arguments the option takes.

public Iterable<JavaFileObject>
list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse)

Implements javax.tools.JavaFileManager.list.

Lists all file objects matching the given criteria in the given package-oriented location.

public Iterable<Set<JavaFileManager.Location>>
listLocationsForModules(JavaFileManager.Location location)

Overrides default javax.tools.JavaFileManager.listLocationsForModules.

Lists the locations for all the modules in a module-oriented location or an output location.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileManagerback to summary
protected final M fileManager

The file manager to which all methods are delegated.

Constructor Detail

ForwardingJavaFileManagerback to summary
protected ForwardingJavaFileManager(M fileManager)

Creates a new instance of ForwardingJavaFileManager.

Parameters
fileManager:M

delegate to this file manager

Method Detail

closeback to summary
public void close() throws IOException

Implements javax.tools.JavaFileManager.close.

Doc from javax.tools.JavaFileManager.close.

Releases any resources opened by this file manager directly or indirectly. This might render this file manager useless and the effect of subsequent calls to methods on this object or any objects obtained through this object is undefined unless explicitly allowed. However, closing a file manager which has already been closed has no effect.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
containsback to summary
public boolean contains(JavaFileManager.Location location, FileObject fo) throws IOException

Overrides default javax.tools.JavaFileManager.contains.

Doc from javax.tools.JavaFileManager.contains.

Determines whether or not a given file object is "contained in" a specified location.

For a package-oriented location, a file object is contained in the location if there exist values for packageName and relativeName such that either of the following calls would return the same file object:

getFileForInput(location, packageName, relativeName) getFileForOutput(location, packageName, relativeName, null)
getFileForInput(location, packageName, relativeName)
getFileForOutput(location, packageName, relativeName, null)

For a module-oriented location, a file object is contained in the location if there exists a module that may be obtained by the call:

getLocationForModule(location, moduleName)
getLocationForModule(location, moduleName)
such that the file object is contained in the (package-oriented) location for that module.
Annotations
@Override
Exceptions
IOException:
if there is a problem determining the result
Since
9
flushback to summary
public void flush() throws IOException

Implements javax.tools.JavaFileManager.flush.

Doc from javax.tools.JavaFileManager.flush.

Flushes any resources opened for output by this file manager directly or indirectly. Flushing a closed file manager has no effect.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
getClassLoaderback to summary
public ClassLoader getClassLoader(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.getClassLoader.

Doc from javax.tools.JavaFileManager.getClassLoader.

Returns a class loader for loading plug-ins from the given package-oriented location. For example, to load annotation processors, a compiler will request a class loader for the ANNOTATION_PROCESSOR_PATH location.

Annotations
@Override
Exceptions
IllegalStateException:
if close has been called and this file manager cannot be reopened
getFileForInputback to summary
public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) throws IOException

Implements javax.tools.JavaFileManager.getFileForInput.

Doc from javax.tools.JavaFileManager.getFileForInput.

Returns a file object for input representing the specified relative name in the specified package in the given package-oriented location.

If the returned object represents a source or class file, it must be an instance of JavaFileObject.

Informally, the file object returned by this method is located in the concatenation of the location, package name, and relative name. For example, to locate the properties file "resources/compiler.properties" in the package "com.sun.tools.javac" in the SOURCE_PATH location, this method might be called like so:

getFileForInput(SOURCE_PATH, "com.sun.tools.javac", "resources/compiler.properties");
getFileForInput(SOURCE_PATH, "com.sun.tools.javac", "resources/compiler.properties");

If the call was executed on Windows, with SOURCE_PATH set to "C:\Documents and Settings\UncleBob\src\share\classes", a valid result would be a file object representing the file "C:\Documents and Settings\UncleBob\src\share\classes\com\sun\tools\javac\resources\compiler.properties".

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if the location is not known to this file manager and the file manager does not support unknown locations, or if relativeName is not valid, or if the location is a module-oriented location
IllegalStateException:
if close has been called and this file manager cannot be reopened
getFileForOutputback to summary
public FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) throws IOException

Implements javax.tools.JavaFileManager.getFileForOutput.

Doc from javax.tools.JavaFileManager.getFileForOutput.

Returns a file object for output representing the specified relative name in the specified package in the given location.

Optionally, this file manager might consider the sibling as a hint for where to place the output. The exact semantics of this hint is unspecified. The JDK compiler, javac, for example, will place class files in the same directories as originating source files unless a class file output directory is provided. To facilitate this behavior, javac might provide the originating source file as sibling when calling this method.

If the returned object represents a source or class file, it must be an instance of JavaFileObject.

Informally, the file object returned by this method is located in the concatenation of the location, package name, and relative name or next to the sibling argument. See getFileForInput for an example.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if sibling is not known to this file manager, or if the location is not known to this file manager and the file manager does not support unknown locations, or if relativeName is not valid, or if the location is not an output location
IllegalStateException:
if close has been called and this file manager cannot be reopened
getFileForOutputForOriginatingFilesback to summary
public FileObject getFileForOutputForOriginatingFiles(JavaFileManager.Location location, String packageName, String relativeName, FileObject... originatingFiles) throws IOException

Overrides default javax.tools.JavaFileManager.getFileForOutputForOriginatingFiles.

Doc from javax.tools.JavaFileManager.getFileForOutputForOriginatingFiles.

Returns a file object for output representing the specified relative name in the specified package in the given location.

The provided originatingFiles represent files that were, in an unspecified way, used to create the content of the file created by this method. See originatingElements in Filer#createResource. Elements#getFileObjectOf may be used to convert the Elements to FileObjects.

If the returned object represents a source or class file, it must be an instance of JavaFileObject.

Informally, the file object returned by this method is located in the concatenation of the location, package name, and relative name or in a location inferred from the originatingFiles. See getFileForInput for an example.

Implementation Specification

If the subclass of the ForwardingJavaFileManager overrides the getFileForOutput method, this method will delegate to it as per the general contract of JavaFileManager#getFileForOutputForOriginatingFiles. If the subclass does not override the method, the call will be delegated to the fileManager.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if sibling is not known to this file manager, or if the location is not known to this file manager and the file manager does not support unknown locations, or if relativeName is not valid, or if the location is not an output location
IllegalStateException:
if close has been called and this file manager cannot be reopened
Since
18
getJavaFileForInputback to summary
public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException

Implements javax.tools.JavaFileManager.getJavaFileForInput.

Doc from javax.tools.JavaFileManager.getJavaFileForInput.

Returns a file object for input representing the specified class of the specified kind in the given package-oriented location.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if the location is not known to this file manager and the file manager does not support unknown locations, or if the kind is not valid, or if the location is a module-oriented location
IllegalStateException:
if close has been called and this file manager cannot be reopened
getJavaFileForOutputback to summary
public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException

Implements javax.tools.JavaFileManager.getJavaFileForOutput.

Doc from javax.tools.JavaFileManager.getJavaFileForOutput.

Returns a file object for output representing the specified class of the specified kind in the given package-oriented location.

Optionally, this file manager might consider the sibling as a hint for where to place the output. The exact semantics of this hint is unspecified. The JDK compiler, javac, for example, will place class files in the same directories as originating source files unless a class file output directory is provided. To facilitate this behavior, javac might provide the originating source file as sibling when calling this method.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if sibling is not known to this file manager, or if the location is not known to this file manager and the file manager does not support unknown locations, or if the kind is not valid, or if the location is not an output location
IllegalStateException:
close has been called and this file manager cannot be reopened
getJavaFileForOutputForOriginatingFilesback to summary
public JavaFileObject getJavaFileForOutputForOriginatingFiles(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject... originatingFiles) throws IOException

Overrides default javax.tools.JavaFileManager.getJavaFileForOutputForOriginatingFiles.

Doc from javax.tools.JavaFileManager.getJavaFileForOutputForOriginatingFiles.

Returns a file object for output representing the specified class of the specified kind in the given package-oriented location.

The provided originatingFiles represent files that were, in an unspecified way, used to create the content of the file created by this method. See originatingElements in Filer#createSourceFile. Elements#getFileObjectOf may be used to convert the Elements to FileObjects.

Implementation Specification

If the subclass of the ForwardingJavaFileManager overrides the getJavaFileForOutput method, this method will delegate to it as per the general contract of JavaFileManager#getJavaFileForOutputForOriginatingFiles. If the subclass does not override the method, the call will be delegated to the fileManager.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalArgumentException:
if sibling is not known to this file manager, or if the location is not known to this file manager and the file manager does not support unknown locations, or if the kind is not valid, or if the location is not an output location
IllegalStateException:
close has been called and this file manager cannot be reopened
Since
18
getLocationForModuleback to summary
public JavaFileManager.Location getLocationForModule(JavaFileManager.Location location, String moduleName) throws IOException

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Doc from javax.tools.JavaFileManager.getLocationForModule.

Gets a location for a named module within a location, which may be either a module-oriented location or an output location. The result will be an output location if the given location is an output location, or it will be a package-oriented location.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
Since
9
getLocationForModuleback to summary
public JavaFileManager.Location getLocationForModule(JavaFileManager.Location location, JavaFileObject fo) throws IOException

Overrides default javax.tools.JavaFileManager.getLocationForModule.

Doc from javax.tools.JavaFileManager.getLocationForModule.

Gets a location for the module containing a specific file to be found within a location, which may be either a module-oriented location or an output location. The result will be an output location if the given location is an output location, or it will be a package-oriented location.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
Since
9
getServiceLoaderback to summary
public <S> ServiceLoader<S> getServiceLoader(JavaFileManager.Location location, Class<S> service) throws IOException

Overrides default javax.tools.JavaFileManager.getServiceLoader.

Doc from javax.tools.JavaFileManager.getServiceLoader.

Get a service loader for a specific service class from a given location. If the location is a module-oriented location, the service loader will use the service declarations in the modules found in that location. Otherwise, a service loader is created using the package-oriented location, in which case, the services are determined using the provider-configuration files in META-INF/services.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
Since
9
handleOptionback to summary
public boolean handleOption(String current, Iterator<String> remaining)

Implements javax.tools.JavaFileManager.handleOption.

Doc from javax.tools.JavaFileManager.handleOption.

Handles one option. If current is an option to this file manager, it will consume any arguments to that option from remaining and return true, otherwise return false.

Annotations
@Override
Exceptions
IllegalArgumentException:
if this option to this file manager is used incorrectly
IllegalStateException:
if close has been called and this file manager cannot be reopened
hasLocationback to summary
public boolean hasLocation(JavaFileManager.Location location)

Implements javax.tools.JavaFileManager.hasLocation.

Doc from javax.tools.JavaFileManager.hasLocation.

Determines if a location is known to this file manager.

Annotations
@Override
inferBinaryNameback to summary
public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file)

Implements javax.tools.JavaFileManager.inferBinaryName.

Doc from javax.tools.JavaFileManager.inferBinaryName.

Infers a binary name of a file object based on a package-oriented location. The binary name returned might not be a valid binary name according to The Java Language Specification.

Annotations
@Override
Exceptions
IllegalStateException:
if close has been called and this file manager cannot be reopened
inferModuleNameback to summary
public String inferModuleName(JavaFileManager.Location location) throws IOException

Overrides default javax.tools.JavaFileManager.inferModuleName.

Doc from javax.tools.JavaFileManager.inferModuleName.

Infer the name of the module from its location, as returned by getLocationForModule or listModuleLocations.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
Since
9
isSameFileback to summary
public boolean isSameFile(FileObject a, FileObject b)

Implements javax.tools.JavaFileManager.isSameFile.

Doc from javax.tools.JavaFileManager.isSameFile.

Compares two file objects and returns true if they represent the same underlying object.

Annotations
@Override
Exceptions
IllegalArgumentException:
if either of the arguments were created with another file manager and this file manager does not support foreign file objects
isSupportedOptionback to summary
public int isSupportedOption(String option)

Implements javax.tools.OptionChecker.isSupportedOption.

Doc from javax.tools.OptionChecker.isSupportedOption.

Determines if the given option is supported and if so, the number of arguments the option takes.

Annotations
@Override
listback to summary
public Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException

Implements javax.tools.JavaFileManager.list.

Doc from javax.tools.JavaFileManager.list.

Lists all file objects matching the given criteria in the given package-oriented location. List file objects in "subpackages" if recurse is true.

Note

even if the given location is unknown to this file manager, it may not return null. Also, an unknown location may not cause an exception.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred, or if close has been called and this file manager cannot be reopened
IllegalStateException:
if close has been called and this file manager cannot be reopened
listLocationsForModulesback to summary
public Iterable<Set<JavaFileManager.Location>> listLocationsForModules(JavaFileManager.Location location) throws IOException

Overrides default javax.tools.JavaFileManager.listLocationsForModules.

Doc from javax.tools.JavaFileManager.listLocationsForModules.

Lists the locations for all the modules in a module-oriented location or an output location. The locations that are returned will be output locations if the given location is an output, or it will be a package-oriented locations.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurred
Since
9