public class JavacPathFileManager extends BaseFileManager implements PathFileManager
Just as a Path is somewhat analagous to a File, so too is this JavacPathFileManager analogous to JavacFileManager, as it relates to the support of FileObjects based on File objects (i.e. just RegularFileObject, not ZipFileObject and its variants.)
The default values for the standard locations supported by this file
manager are the same as the default values provided by JavacFileManager --
i.e. as determined by the javac.file.Paths class. To override these values,
call setLocation(javax.tools.JavaFileManager.Location, java.lang.Iterable<? extends java.nio.file.Path>)
.
To reduce confusion with Path objects, the locations such as "class path", "source path", etc, are generically referred to here as "search paths".
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.
BaseFileManager.ContentCacheEntry
JavaFileManager.Location
Modifier and Type | Field and Description |
---|---|
protected FileSystem |
defaultFileSystem |
charset, classLoaderClass, contentCache, locations, log, options
Constructor and Description |
---|
JavacPathFileManager(Context context,
boolean register,
Charset charset)
Create a JavacPathFileManager using a given context, optionally registering
it as the JavaFileManager for that context.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
ClassLoader |
getClassLoader(JavaFileManager.Location location) |
FileSystem |
getDefaultFileSystem()
Get the default file system used to create paths.
|
FileObject |
getFileForInput(JavaFileManager.Location location,
String packageName,
String relativeName) |
FileObject |
getFileForOutput(JavaFileManager.Location location,
String packageName,
String relativeName,
FileObject sibling) |
JavaFileObject |
getJavaFileForInput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind) |
JavaFileObject |
getJavaFileForOutput(JavaFileManager.Location location,
String className,
JavaFileObject.Kind kind,
FileObject sibling) |
Iterable<? extends JavaFileObject> |
getJavaFileObjects(Path... paths)
Get file objects representing the given paths.
|
Iterable<? extends JavaFileObject> |
getJavaFileObjectsFromPaths(Iterable<? extends Path> paths)
Get file objects representing the given files.
|
Iterable<? extends Path> |
getLocation(JavaFileManager.Location location)
Get the search path associated with the given location.
|
Path |
getPath(FileObject fo)
Return the Path for a file object that has been obtained from this
file manager.
|
boolean |
hasLocation(JavaFileManager.Location location) |
String |
inferBinaryName(JavaFileManager.Location location,
JavaFileObject fo) |
boolean |
isDefaultBootClassPath() |
boolean |
isSameFile(FileObject a,
FileObject b) |
Iterable<JavaFileObject> |
list(JavaFileManager.Location location,
String packageName,
Set<JavaFileObject.Kind> kinds,
boolean recurse) |
void |
setContext(Context context)
Set the context for JavacPathFileManager.
|
void |
setDefaultFileSystem(FileSystem fs)
Set the default file system used to create paths.
|
void |
setLocation(JavaFileManager.Location location,
Iterable<? extends Path> searchPath)
Associate the given search path with the given location.
|
cache, createLocations, decode, flushCache, getCachedContent, getClassLoader, getDecoder, getEncodingName, getKind, getSource, handleOption, isSupportedOption, makeByteBuffer, nullCheck, nullCheck, recycleByteBuffer
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
contains, getLocationForModule, getLocationForModule, getServiceLoader, handleOption, inferModuleName, listLocationsForModules
isSupportedOption
protected FileSystem defaultFileSystem
public void setContext(Context context)
setContext
in class BaseFileManager
public FileSystem getDefaultFileSystem()
PathFileManager
FileSystems.getDefault()
.getDefaultFileSystem
in interface PathFileManager
public void setDefaultFileSystem(FileSystem fs)
PathFileManager
setDefaultFileSystem
in interface PathFileManager
fs
- the default file system used to create any new paths.public void flush() throws IOException
flush
in interface Flushable
flush
in interface JavaFileManager
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface JavaFileManager
IOException
public ClassLoader getClassLoader(JavaFileManager.Location location)
getClassLoader
in interface JavaFileManager
public boolean isDefaultBootClassPath()
isDefaultBootClassPath
in class BaseFileManager
public boolean hasLocation(JavaFileManager.Location location)
hasLocation
in interface JavaFileManager
public Iterable<? extends Path> getLocation(JavaFileManager.Location location)
PathFileManager
getLocation
in interface PathFileManager
location
- a locationnull
if this location has no
associated search pathPathFileManager.setLocation(javax.tools.JavaFileManager.Location, java.lang.Iterable<? extends java.nio.file.Path>)
public void setLocation(JavaFileManager.Location location, Iterable<? extends Path> searchPath) throws IOException
PathFileManager
setLocation
in interface PathFileManager
location
- a locationsearchPath
- a list of files, if null
use the default
search path for this locationIOException
- if location is an output location and searchpath
does not represent an existing directoryPathFileManager.getLocation(javax.tools.JavaFileManager.Location)
public Path getPath(FileObject fo)
PathFileManager
getPath
in interface PathFileManager
fo
- A file object that has been obtained from this file manager.public boolean isSameFile(FileObject a, FileObject b)
isSameFile
in interface JavaFileManager
public Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException
list
in interface JavaFileManager
IOException
public Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths(Iterable<? extends Path> paths)
PathFileManager
getJavaFileObjectsFromPaths
in interface PathFileManager
paths
- a list of pathspublic Iterable<? extends JavaFileObject> getJavaFileObjects(Path... paths)
PathFileManager
getJavaFileObjectsFromPaths(Arrays.asList(paths))
getJavaFileObjects
in interface PathFileManager
paths
- an array of pathspublic JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException
getJavaFileForInput
in interface JavaFileManager
IOException
public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) throws IOException
getFileForInput
in interface JavaFileManager
IOException
public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException
getJavaFileForOutput
in interface JavaFileManager
IOException
public FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, FileObject sibling) throws IOException
getFileForOutput
in interface JavaFileManager
IOException
public String inferBinaryName(JavaFileManager.Location location, JavaFileObject fo)
inferBinaryName
in interface JavaFileManager
Copyright © 2017 earcam. All rights reserved.