ForwardingFileObject (Java Platform SE 8 ) (original) (raw)
- javax.tools.ForwardingFileObject
Type Parameters:
F
- the kind of file object forwarded to by this object
All Implemented Interfaces:
FileObject
Direct Known Subclasses:
ForwardingJavaFileObject
public class ForwardingFileObject<F extends FileObject>
extends Object
implements FileObject
Forwards calls to a given file object. Subclasses of this class might override some of these methods and might also provide additional fields and methods.
Since:
1.6
Field Summary
Fields
Modifier and Type Field Description protected F fileObject The file object which all methods are delegated to. Constructor Summary
Constructors
Modifier Constructor Description protected ForwardingFileObject(F fileObject) Creates a new instance of ForwardingFileObject. Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type Method Description boolean delete() Deletes this file object. CharSequence getCharContent(boolean ignoreEncodingErrors) Gets the character content of this file object, if available. long getLastModified() Gets the time this file object was last modified. String getName() Gets a user-friendly name for this file object. InputStream openInputStream() Gets an InputStream for this file object. OutputStream openOutputStream() Gets an OutputStream for this file object. Reader openReader(boolean ignoreEncodingErrors) Gets a reader for this object. Writer openWriter() Gets a Writer for this file object. URI toUri() Returns a URI identifying this file object. * ### Methods inherited from class java.lang.[Object](../../java/lang/Object.html "class in java.lang") `[clone](../../java/lang/Object.html#clone--), [equals](../../java/lang/Object.html#equals-java.lang.Object-), [finalize](../../java/lang/Object.html#finalize--), [getClass](../../java/lang/Object.html#getClass--), [hashCode](../../java/lang/Object.html#hashCode--), [notify](../../java/lang/Object.html#notify--), [notifyAll](../../java/lang/Object.html#notifyAll--), [toString](../../java/lang/Object.html#toString--), [wait](../../java/lang/Object.html#wait--), [wait](../../java/lang/Object.html#wait-long-), [wait](../../java/lang/Object.html#wait-long-int-)`
Field Detail
* #### fileObject protected final [F](../../javax/tools/ForwardingFileObject.html "type parameter in ForwardingFileObject") extends [FileObject](../../javax/tools/FileObject.html "interface in javax.tools") fileObject The file object which all methods are delegated to.
Constructor Detail
* #### ForwardingFileObject protected ForwardingFileObject([F](../../javax/tools/ForwardingFileObject.html "type parameter in ForwardingFileObject") fileObject) Creates a new instance of ForwardingFileObject. Parameters: `fileObject` \- delegate to this file object
Method Detail
* #### toUri public [URI](../../java/net/URI.html "class in java.net") toUri() Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#toUri--)` Returns a URI identifying this file object. Specified by: `[toUri](../../javax/tools/FileObject.html#toUri--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: a URI * #### getName public [String](../../java/lang/String.html "class in java.lang") getName() Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#getName--)` Gets a user-friendly name for this file object. The exact value returned is not specified but implementations should take care to preserve names as given by the user. For example, if the user writes the filename `"BobsApp\Test.java"` on the command line, this method should return `"BobsApp\Test.java"` whereas the [toUri](../../javax/tools/FileObject.html#toUri--) method might return `file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java`. Specified by: `[getName](../../javax/tools/FileObject.html#getName--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: a user-friendly name * #### openInputStream public [InputStream](../../java/io/InputStream.html "class in java.io") openInputStream() throws [IOException](../../java/io/IOException.html "class in java.io") Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#openInputStream--)` Gets an InputStream for this file object. Specified by: `[openInputStream](../../javax/tools/FileObject.html#openInputStream--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: an InputStream Throws: `[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")` \- if this file object was opened for writing and does not support reading `[UnsupportedOperationException](../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- if this kind of file object does not support byte access `[IOException](../../java/io/IOException.html "class in java.io")` \- if an I/O error occurred * #### openOutputStream public [OutputStream](../../java/io/OutputStream.html "class in java.io") openOutputStream() throws [IOException](../../java/io/IOException.html "class in java.io") Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#openOutputStream--)` Gets an OutputStream for this file object. Specified by: `[openOutputStream](../../javax/tools/FileObject.html#openOutputStream--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: an OutputStream Throws: `[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")` \- if this file object was opened for reading and does not support writing `[UnsupportedOperationException](../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- if this kind of file object does not support byte access `[IOException](../../java/io/IOException.html "class in java.io")` \- if an I/O error occurred * #### openReader public [Reader](../../java/io/Reader.html "class in java.io") openReader(boolean ignoreEncodingErrors) throws [IOException](../../java/io/IOException.html "class in java.io") Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#openReader-boolean-)` Gets a reader for this object. The returned reader will replace bytes that cannot be decoded with the default translation character. In addition, the reader may report a diagnostic unless `ignoreEncodingErrors` is true. Specified by: `[openReader](../../javax/tools/FileObject.html#openReader-boolean-)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Parameters: `ignoreEncodingErrors` \- ignore encoding errors if true Returns: a Reader Throws: `[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")` \- if this file object was opened for writing and does not support reading `[UnsupportedOperationException](../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- if this kind of file object does not support character access `[IOException](../../java/io/IOException.html "class in java.io")` \- if an I/O error occurred * #### getCharContent public [CharSequence](../../java/lang/CharSequence.html "interface in java.lang") getCharContent(boolean ignoreEncodingErrors) throws [IOException](../../java/io/IOException.html "class in java.io") Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#getCharContent-boolean-)` Gets the character content of this file object, if available. Any byte that cannot be decoded will be replaced by the default translation character. In addition, a diagnostic may be reported unless `ignoreEncodingErrors` is true. Specified by: `[getCharContent](../../javax/tools/FileObject.html#getCharContent-boolean-)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Parameters: `ignoreEncodingErrors` \- ignore encoding errors if true Returns: a CharSequence if available; `null` otherwise Throws: `[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")` \- if this file object was opened for writing and does not support reading `[UnsupportedOperationException](../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- if this kind of file object does not support character access `[IOException](../../java/io/IOException.html "class in java.io")` \- if an I/O error occurred * #### openWriter public [Writer](../../java/io/Writer.html "class in java.io") openWriter() throws [IOException](../../java/io/IOException.html "class in java.io") Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#openWriter--)` Gets a Writer for this file object. Specified by: `[openWriter](../../javax/tools/FileObject.html#openWriter--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: a Writer Throws: `[IllegalStateException](../../java/lang/IllegalStateException.html "class in java.lang")` \- if this file object was opened for reading and does not support writing `[UnsupportedOperationException](../../java/lang/UnsupportedOperationException.html "class in java.lang")` \- if this kind of file object does not support character access `[IOException](../../java/io/IOException.html "class in java.io")` \- if an I/O error occurred * #### getLastModified public long getLastModified() Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#getLastModified--)` Gets the time this file object was last modified. The time is measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970). Specified by: `[getLastModified](../../javax/tools/FileObject.html#getLastModified--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: the time this file object was last modified; or 0 if the file object does not exist, if an I/O error occurred, or if the operation is not supported * #### delete public boolean delete() Description copied from interface: `[FileObject](../../javax/tools/FileObject.html#delete--)` Deletes this file object. In case of errors, returns false. Specified by: `[delete](../../javax/tools/FileObject.html#delete--)` in interface `[FileObject](../../javax/tools/FileObject.html "interface in javax.tools")` Returns: true if and only if this file object is successfully deleted; false otherwise
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.