Package oms3.compiler
Class MemoryOutputJavaFileManager
- java.lang.Object
-
- javax.tools.ForwardingJavaFileManager<JavaFileManager>
-
- oms3.compiler.MemoryOutputJavaFileManager
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,JavaFileManager,OptionChecker
public class MemoryOutputJavaFileManager extends ForwardingJavaFileManager<JavaFileManager>
A java file manager that stores output in memory, delegating all other functions to another file manager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.tools.JavaFileManager
JavaFileManager.Location
-
-
Field Summary
-
Fields inherited from class javax.tools.ForwardingJavaFileManager
fileManager
-
-
Constructor Summary
Constructors Constructor Description MemoryOutputJavaFileManager(JavaFileManager fileManager)Constructs aMemoryOutputJavaFileManager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddClassPathUrl(URL url)Adds a URL that classes may be loaded from.static URLbaseUrlOfClass(Class<?> clazz)Returns the base URL of the specified class.JavaFileObjectgetJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind)JavaFileObjectgetJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling)StringinferBinaryName(JavaFileManager.Location location, JavaFileObject file)Iterable<JavaFileObject>list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse)protected List<JavaFileObject>listClassesFromUrl(URL base, String packageName)Lists all files at a specified URL.-
Methods inherited from class javax.tools.ForwardingJavaFileManager
close, contains, flush, getClassLoader, getFileForInput, getFileForOutput, getLocationForModule, getLocationForModule, getServiceLoader, handleOption, hasLocation, inferModuleName, isSameFile, isSupportedOption, listLocationsForModules
-
-
-
-
Constructor Detail
-
MemoryOutputJavaFileManager
public MemoryOutputJavaFileManager(JavaFileManager fileManager)
Constructs aMemoryOutputJavaFileManager.- Parameters:
fileManager- the underlying file manager to use.
-
-
Method Detail
-
addClassPathUrl
public void addClassPathUrl(URL url)
Adds a URL that classes may be loaded from. All classes from this URL will be added to the classpath.- Parameters:
url- the URL to add.- Throws:
NullPointerException- ifurlis null.
-
baseUrlOfClass
public static URL baseUrlOfClass(Class<?> clazz)
Returns the base URL of the specified class.For example, if
java.lang.Stringexists at http://base.net/parent/java/lang/String.class, the base URL is http://base.net/parent/.- Parameters:
clazz- the class.- Returns:
- a base URL where the class is located.
- Throws:
IllegalArgumentException- if a URL cannot be obtained.
-
getJavaFileForOutput
public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind, FileObject sibling) throws IOException
- Specified by:
getJavaFileForOutputin interfaceJavaFileManager- Overrides:
getJavaFileForOutputin classForwardingJavaFileManager<JavaFileManager>- Throws:
IOException
-
getJavaFileForInput
public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) throws IOException
- Specified by:
getJavaFileForInputin interfaceJavaFileManager- Overrides:
getJavaFileForInputin classForwardingJavaFileManager<JavaFileManager>- Throws:
IOException
-
inferBinaryName
public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file)
- Specified by:
inferBinaryNamein interfaceJavaFileManager- Overrides:
inferBinaryNamein classForwardingJavaFileManager<JavaFileManager>
-
list
public Iterable<JavaFileObject> list(JavaFileManager.Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException
- Specified by:
listin interfaceJavaFileManager- Overrides:
listin classForwardingJavaFileManager<JavaFileManager>- Throws:
IOException
-
listClassesFromUrl
protected List<JavaFileObject> listClassesFromUrl(URL base, String packageName) throws IOException
Lists all files at a specified URL.- Parameters:
base- the URL.packageName- the package name of classes to list.- Returns:
- a list of class files.
- Throws:
IOException- if an I/O error occurs.
-
-