M
- the type of file manager wrapped to by this objectpublic class WrappingJavaFileManager<M extends JavaFileManager> extends ForwardingJavaFileManager<M>
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.
JavaFileManager.Location
fileManager
Modifier | Constructor and Description |
---|---|
protected |
WrappingJavaFileManager(M fileManager)
Creates a new instance of WrappingJavaFileManager.
|
Modifier and Type | Method and Description |
---|---|
FileObject |
getFileForInput(JavaFileManager.Location location,
String packageName,
String relativeName)
Gets a file object for input
representing the specified relative
name in the specified package in the given location.
|
FileObject |
getFileForOutput(JavaFileManager.Location location,
String packageName,
String relativeName,
FileObject sibling)
Gets a file object for output
representing the specified relative
name in the specified package in the given location.
|
JavaFileObject |
getJavaFileForInput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind)
Gets a file object for input
representing the specified class of the specified kind in the
given location.
|
JavaFileObject |
getJavaFileForOutput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind,
FileObject sibling)
Gets a file object for output
representing the specified class of the specified kind in the
given location.
|
String |
inferBinaryName(JavaFileManager.Location location,
JavaFileObject file)
Infers a binary name of a file object based on a location.
|
Iterable<JavaFileObject> |
list(JavaFileManager.Location location,
String packageName,
Set<JavaFileObject.Kind> kinds,
boolean recurse)
Lists all file objects matching the given criteria in the given
location.
|
protected FileObject |
unwrap(FileObject fileObject)
This implementation returns the given file object.
|
protected JavaFileObject |
unwrap(JavaFileObject fileObject)
This implementation forwards to
unwrap(FileObject) . |
protected URI |
unwrap(URI uri)
This implementation returns the given URI.
|
protected FileObject |
wrap(FileObject fileObject)
This implementation returns the given file object.
|
protected Iterable<JavaFileObject> |
wrap(Iterable<JavaFileObject> fileObjects)
This implementation maps the given list of file objects by
calling wrap on each.
|
protected JavaFileObject |
wrap(JavaFileObject fileObject)
This implementation forwards to
wrap(FileObject) . |
close, flush, getClassLoader, handleOption, hasLocation, isSameFile, isSupportedOption
protected WrappingJavaFileManager(M fileManager)
fileManager
- file manager to be wrappedprotected FileObject wrap(FileObject fileObject)
fileObject
- a file objectprotected JavaFileObject wrap(JavaFileObject fileObject)
wrap(FileObject)
.
Subclasses may override this behavior.fileObject
- a file objectClassCastException
- if the file object returned from the
forwarded call is not a subtype of JavaFileObjectprotected FileObject unwrap(FileObject fileObject)
fileObject
- a file objectprotected JavaFileObject unwrap(JavaFileObject fileObject)
unwrap(FileObject)
.
Subclasses may override this behavior.fileObject
- a file objectClassCastException
- if the file object returned from the
forwarded call is not a subtype of JavaFileObjectprotected Iterable<JavaFileObject> wrap(Iterable<JavaFileObject> fileObjects)
fileObjects
- a list of file objectsprotected URI unwrap(URI uri)
uri
- a URIpublic Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException
JavaFileManager
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.
list
in interface JavaFileManager
list
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationpackageName
- a package namekinds
- return objects only of these kindsrecurse
- if true include "subpackages"IllegalStateException
- if JavaFileManager.close()
has been called
and this file manager cannot be reopenedIOException
- if an I/O error occurred, or if JavaFileManager.close()
has been called and this file manager cannot be
reopenedpublic String inferBinaryName(JavaFileManager.Location location, JavaFileObject file)
JavaFileManager
inferBinaryName
in interface JavaFileManager
inferBinaryName
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationfile
- a file objectnull
the file object is not
found in the given locationIllegalStateException
- if JavaFileManager.close()
has been called
and this file manager cannot be reopenedpublic JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException
JavaFileManager
getJavaFileForInput
in interface JavaFileManager
getJavaFileForInput
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationclassName
- the name of a classkind
- the kind of file, must be one of SOURCE
or CLASS
null
if the
file does not existIllegalArgumentException
- 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 validUnsupportedOperationException
IllegalStateException
- if JavaFileManager.close()
has been called
and this file manager cannot be reopenedIOException
- if an I/O error occurred, or if JavaFileManager.close()
has been called and this file manager cannot be
reopenedpublic JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException
JavaFileManager
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.
getJavaFileForOutput
in interface JavaFileManager
getJavaFileForOutput
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationclassName
- the name of a classkind
- the kind of file, must be one of SOURCE
or CLASS
sibling
- a file object to be used as hint for placement;
might be null
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 validUnsupportedOperationException
IllegalStateException
- JavaFileManager.close()
has been called
and this file manager cannot be reopenedIOException
- if an I/O error occurred, or if JavaFileManager.close()
has been called and this file manager cannot be
reopenedpublic FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) throws IOException
JavaFileManager
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");
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"
.
getFileForInput
in interface JavaFileManager
getFileForInput
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationpackageName
- a package namerelativeName
- a relative namenull
if the file
does not existIllegalArgumentException
- if the location is not known
to this file manager and the file manager does not support
unknown locations, or if relativeName
is not validIllegalStateException
- if JavaFileManager.close()
has been called
and this file manager cannot be reopenedIOException
- if an I/O error occurred, or if JavaFileManager.close()
has been called and this file manager cannot be
reopenedpublic FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) throws IOException
JavaFileManager
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.
getFileForOutput
in interface JavaFileManager
getFileForOutput
in class ForwardingJavaFileManager<M extends JavaFileManager>
location
- a locationpackageName
- a package namerelativeName
- a relative namesibling
- a file object to be used as hint for placement;
might be null
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 validIllegalStateException
- if JavaFileManager.close()
has been called
and this file manager cannot be reopenedIOException
- if an I/O error occurred, or if JavaFileManager.close()
has been called and this file manager cannot be
reopenedCopyright © 2015. All rights reserved.