📄 javafilemanager.java
字号:
* Handles one option. If {@code current} is an option to this * file manager it will consume any arguments to that option from * {@code remaining} and return true, otherwise return false. * * @param current current option * @param remaining remaining options * @return true if this option was handled by this file manager, * false otherwise * @throws IllegalArgumentException if this option to this file * manager is used incorrectly * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ boolean handleOption(String current, Iterator<String> remaining); /** * Determines if a location is known to this file manager. * * @param location a location * @return true if the location is known */ boolean hasLocation(Location location); /** * Gets a {@linkplain JavaFileObject file object} for input * representing the specified class of the specified kind in the * given location. * * @param location a location * @param className the name of a class * @param kind the kind of file, must be one of {@link * JavaFileObject.Kind#SOURCE SOURCE} or {@link * JavaFileObject.Kind#CLASS CLASS} * @return a file object, might return {@code null} if the * file does not exist * @throws 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 * @throws IOException if an I/O error occurred, or if {@link * #close} has been called and this file manager cannot be * reopened * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException; /** * Gets a {@linkplain JavaFileObject file object} for output * representing the specified class of the specified kind in the * given location. * * <p>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. Sun's 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. * * @param location a location * @param className the name of a class * @param kind the kind of file, must be one of {@link * JavaFileObject.Kind#SOURCE SOURCE} or {@link * JavaFileObject.Kind#CLASS CLASS} * @param sibling a file object to be used as hint for placement; * might be {@code null} * @return a file object for output * @throws 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 * @throws IOException if an I/O error occurred, or if {@link * #close} has been called and this file manager cannot be * reopened * @throws IllegalStateException {@link #close} has been called * and this file manager cannot be reopened */ JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException; /** * Gets a {@linkplain FileObject file object} for input * representing the specified <a href="JavaFileManager.html#relative_name">relative * name</a> in the specified package in the given location. * * <p>If the returned object represents a {@linkplain * JavaFileObject.Kind#SOURCE source} or {@linkplain * JavaFileObject.Kind#CLASS class} file, it must be an instance * of {@link JavaFileObject}. * * <p>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 {@linkplain * StandardLocation#SOURCE_PATH SOURCE_PATH} location, this method * might be called like so: * * <pre>getFileForInput(SOURCE_PATH, "com.sun.tools.javac", "resources/compiler.properties");</pre> * * <p>If the call was executed on Windows, with SOURCE_PATH set to * <code>"C:\Documents and Settings\UncleBob\src\share\classes"</code>, * a valid result would be a file object representing the file * <code>"C:\Documents and Settings\UncleBob\src\share\classes\com\sun\tools\javac\resources\compiler.properties"</code>. * * @param location a location * @param packageName a package name * @param relativeName a relative name * @return a file object, might return {@code null} if the file * does not exist * @throws IllegalArgumentException if the location is not known * to this file manager and the file manager does not support * unknown locations, or if {@code relativeName} is not valid * @throws IOException if an I/O error occurred, or if {@link * #close} has been called and this file manager cannot be * reopened * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException; /** * Gets a {@linkplain FileObject file object} for output * representing the specified <a href="JavaFileManager.html#relative_name">relative * name</a> in the specified package in the given location. * * <p>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. Sun's 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. * * <p>If the returned object represents a {@linkplain * JavaFileObject.Kind#SOURCE source} or {@linkplain * JavaFileObject.Kind#CLASS class} file, it must be an instance * of {@link JavaFileObject}. * * <p>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 {@link * #getFileForInput getFileForInput} for an example. * * @param location a location * @param packageName a package name * @param relativeName a relative name * @param sibling a file object to be used as hint for placement; * might be {@code null} * @return a file object * @throws 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 {@code relativeName} is not valid * @throws IOException if an I/O error occurred, or if {@link * #close} has been called and this file manager cannot be * reopened * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException; /** * Flushes any resources opened for output by this file manager * directly or indirectly. Flushing a closed file manager has no * effect. * * @throws IOException if an I/O error occurred * @see #close */ void flush() throws IOException; /** * 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. * * @throws IOException if an I/O error occurred * @see #flush */ void close() throws IOException;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -