APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.api

public Class WrappingJavaFileManager<M extends JavaFileManager>

extends ForwardingJavaFileManager<M extends JavaFileManager>
Class Inheritance
Type Parameters
<M>
the type of file manager wrapped to by this object
Imports
java.io.IOException, java.net.URI, java.util.ArrayList, .Collections, .List, .Set, javax.tools.*, .JavaFileObject.Kind, com.sun.tools.javac.util.ClientCodeException, .DefinedBy, .DefinedBy.Api

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

This class might be moved to javax.tools in a future release.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Author
Peter von der Ahé
Since
1.6

Field Summary

Inherited from javax.tools.ForwardingJavaFileManager:
fileManager

Constructor Summary

AccessConstructor and Description
protected
WrappingJavaFileManager(M
file manager to be wrapped
fileManager
)

Creates a new instance of WrappingJavaFileManager.

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(JavaFileManager.Location location, FileObject file)

Overrides javax.tools.ForwardingJavaFileManager.contains.

Overrides default javax.tools.JavaFileManager.contains.

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

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

Overrides javax.tools.ForwardingJavaFileManager.getFileForInput.

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)

Overrides javax.tools.ForwardingJavaFileManager.getFileForOutput.

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 JavaFileObject
getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind)

Overrides javax.tools.ForwardingJavaFileManager.getJavaFileForInput.

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)

Overrides javax.tools.ForwardingJavaFileManager.getJavaFileForOutput.

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 String
inferBinaryName(JavaFileManager.Location location, JavaFileObject file)

Overrides javax.tools.ForwardingJavaFileManager.inferBinaryName.

Implements javax.tools.JavaFileManager.inferBinaryName.

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

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

Overrides javax.tools.ForwardingJavaFileManager.list.

Implements javax.tools.JavaFileManager.list.

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

protected FileObject
unwrap(FileObject
a file object
fileObject
)

This implementation returns the given file object.

protected JavaFileObject
unwrap(JavaFileObject
a file object
fileObject
)

This implementation forwards to unwrap(FileObject).

protected URI
unwrap(URI
a URI
uri
)

This implementation returns the given URI.

protected FileObject
wrap(FileObject
a file object
fileObject
)

This implementation returns the given file object.

protected JavaFileObject
wrap(JavaFileObject
a file object
fileObject
)

This implementation forwards to wrap(FileObject).

protected Iterable<JavaFileObject>

Returns:

the mapping
wrap
(Iterable<JavaFileObject>
a list of file objects
fileObjects
)

This implementation maps the given list of file objects by calling wrap on each.

Inherited from javax.tools.ForwardingJavaFileManager:
closeflushgetClassLoadergetFileForOutputForOriginatingFilesgetJavaFileForOutputForOriginatingFilesgetLocationForModulegetLocationForModulegetServiceLoaderhandleOptionhasLocationinferModuleNameisSameFileisSupportedOptionlistLocationsForModules

Constructor Detail

WrappingJavaFileManagerback to summary
protected WrappingJavaFileManager(M fileManager)

Creates a new instance of WrappingJavaFileManager.

Parameters
fileManager:M

file manager to be wrapped

Method Detail

containsback to summary
public boolean contains(JavaFileManager.Location location, FileObject file) throws IOException

Overrides javax.tools.ForwardingJavaFileManager.contains.

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
@DefinedBy:COMPILER
Exceptions
IOException:
if there is a problem determining the result
getFileForInputback to summary
public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) throws IOException

Overrides javax.tools.ForwardingJavaFileManager.getFileForInput.

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
@DefinedBy:COMPILER
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

Overrides javax.tools.ForwardingJavaFileManager.getFileForOutput.

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
@DefinedBy:COMPILER
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
getJavaFileForInputback to summary
public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException

Overrides javax.tools.ForwardingJavaFileManager.getJavaFileForInput.

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
@DefinedBy:COMPILER
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
UnsupportedOperationException
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

Overrides javax.tools.ForwardingJavaFileManager.getJavaFileForOutput.

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
@DefinedBy:COMPILER
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
UnsupportedOperationException
IllegalStateException:
close has been called and this file manager cannot be reopened
inferBinaryNameback to summary
public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file)

Overrides javax.tools.ForwardingJavaFileManager.inferBinaryName.

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
@DefinedBy:COMPILER
Exceptions
IllegalStateException:
if close has been called and this file manager cannot be reopened
listback to summary
public Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException

Overrides javax.tools.ForwardingJavaFileManager.list.

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
@DefinedBy:COMPILER
Exceptions
IOException:

Doc from javax.tools.ForwardingJavaFileManager.list.

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
unwrapback to summary
protected FileObject unwrap(FileObject fileObject)

This implementation returns the given file object. Subclasses may override this behavior.

Parameters
fileObject:FileObject

a file object

unwrapback to summary
protected JavaFileObject unwrap(JavaFileObject fileObject)

This implementation forwards to unwrap(FileObject). Subclasses may override this behavior.

Parameters
fileObject:JavaFileObject

a file object

Exceptions
ClassCastException:
if the file object returned from the forwarded call is not a subtype of JavaFileObject
unwrapback to summary
protected URI unwrap(URI uri)

This implementation returns the given URI. Subclasses may override this behavior.

Parameters
uri:URI

a URI

wrapback to summary
protected FileObject wrap(FileObject fileObject)

This implementation returns the given file object. Subclasses may override this behavior.

Parameters
fileObject:FileObject

a file object

wrapback to summary
protected JavaFileObject wrap(JavaFileObject fileObject)

This implementation forwards to wrap(FileObject). Subclasses may override this behavior.

Parameters
fileObject:JavaFileObject

a file object

Exceptions
ClassCastException:
if the file object returned from the forwarded call is not a subtype of JavaFileObject
wrapback to summary
protected Iterable<JavaFileObject> wrap(Iterable<JavaFileObject> fileObjects)

This implementation maps the given list of file objects by calling wrap on each. Subclasses may override this behavior.

Parameters
fileObjects:Iterable<JavaFileObject>

a list of file objects

Returns:Iterable<JavaFileObject>

the mapping