ForwardingFileObject (Java SE 16 & JDK 16) (original) (raw)
Type Parameters:
F
- the kind of file object forwarded to by this object
All Implemented Interfaces:
[FileObject](FileObject.html "interface in javax.tools")
Direct Known Subclasses:
[ForwardingJavaFileObject](ForwardingJavaFileObject.html "class in javax.tools")
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
Fieldsprotected [F](ForwardingFileObject.html "type parameter in ForwardingFileObject")
The file object which all methods are delegated to.
Constructor Summary
Constructorsprotected
[ForwardingFileObject](#%3Cinit%3E%28F%29)([F](ForwardingFileObject.html "type parameter in ForwardingFileObject") fileObject)
Creates a new instance of ForwardingFileObject
.
Method Summary
boolean
[delete](#delete%28%29)()
Deletes this file object.[getCharContent](#getCharContent%28boolean%29)(boolean ignoreEncodingErrors)
Returns the character content of this file object, if available.long
Returns the time this file object was last modified.[getName](#getName%28%29)()
Returns a user-friendly name for this file object.
Returns an InputStream for this file object.
Returns an OutputStream for this file object.[openReader](#openReader%28boolean%29)(boolean ignoreEncodingErrors)
Returns a reader for this object.
Returns a Writer for this file object.[toUri](#toUri%28%29)()
Returns a URI identifying this file object.
Methods declared in class java.lang.Object
[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)
Field Details
fileObject
protected final F extends FileObject fileObject
The file object which all methods are delegated to.Constructor Details
ForwardingFileObject
protected ForwardingFileObject(F fileObject)
Creates a new instance ofForwardingFileObject
.
Parameters:
fileObject
- delegate to this file objectMethod Details
toUri
public URI toUri()
Description copied from interface:[FileObject](FileObject.html#toUri%28%29)
Returns a URI identifying this file object.
Specified by:
[toUri](FileObject.html#toUri%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
a URIgetName
Description copied from interface:
[FileObject](FileObject.html#getName%28%29)
Returns 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 method might returnfile:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java
.
Specified by:
[getName](FileObject.html#getName%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
a user-friendly nameopenInputStream
Description copied from interface:
[FileObject](FileObject.html#openInputStream%28%29)
Returns an InputStream for this file object.
Specified by:
[openInputStream](FileObject.html#openInputStream%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
an InputStream
Throws:
[IllegalStateException](../../../java.base/java/lang/IllegalStateException.html "class in java.lang")
- if this file object was opened for writing and does not support reading
[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")
- if this kind of file object does not support byte access
[IOException](../../../java.base/java/io/IOException.html "class in java.io")
- if an I/O error occurredopenOutputStream
Description copied from interface:
[FileObject](FileObject.html#openOutputStream%28%29)
Returns an OutputStream for this file object.
Specified by:
[openOutputStream](FileObject.html#openOutputStream%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
an OutputStream
Throws:
[IllegalStateException](../../../java.base/java/lang/IllegalStateException.html "class in java.lang")
- if this file object was opened for reading and does not support writing
[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")
- if this kind of file object does not support byte access
[IOException](../../../java.base/java/io/IOException.html "class in java.io")
- if an I/O error occurredopenReader
public Reader openReader(boolean ignoreEncodingErrors) throws IOException
Description copied from interface:[FileObject](FileObject.html#openReader%28boolean%29)
Returns 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 unlessignoreEncodingErrors
is true.
Specified by:
[openReader](FileObject.html#openReader%28boolean%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Parameters:
ignoreEncodingErrors
- ignore encoding errors if true
Returns:
a Reader
Throws:
[IllegalStateException](../../../java.base/java/lang/IllegalStateException.html "class in java.lang")
- if this file object was opened for writing and does not support reading
[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")
- if this kind of file object does not support character access
[IOException](../../../java.base/java/io/IOException.html "class in java.io")
- if an I/O error occurredgetCharContent
Description copied from interface:
[FileObject](FileObject.html#getCharContent%28boolean%29)
Returns 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 unlessignoreEncodingErrors
is true.
Specified by:
[getCharContent](FileObject.html#getCharContent%28boolean%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Parameters:
ignoreEncodingErrors
- ignore encoding errors if true
Returns:
a CharSequence if available;null
otherwise
Throws:
[IllegalStateException](../../../java.base/java/lang/IllegalStateException.html "class in java.lang")
- if this file object was opened for writing and does not support reading
[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")
- if this kind of file object does not support character access
[IOException](../../../java.base/java/io/IOException.html "class in java.io")
- if an I/O error occurredopenWriter
Description copied from interface:
[FileObject](FileObject.html#openWriter%28%29)
Returns a Writer for this file object.
Specified by:
[openWriter](FileObject.html#openWriter%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
a Writer
Throws:
[IllegalStateException](../../../java.base/java/lang/IllegalStateException.html "class in java.lang")
- if this file object was opened for reading and does not support writing
[UnsupportedOperationException](../../../java.base/java/lang/UnsupportedOperationException.html "class in java.lang")
- if this kind of file object does not support character access
[IOException](../../../java.base/java/io/IOException.html "class in java.io")
- if an I/O error occurredgetLastModified
public long getLastModified()
Description copied from interface:[FileObject](FileObject.html#getLastModified%28%29)
Returns 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](FileObject.html#getLastModified%28%29)
in interface[FileObject](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 supporteddelete
public boolean delete()
Description copied from interface:[FileObject](FileObject.html#delete%28%29)
Deletes this file object. In case of errors, returns false.
Specified by:
[delete](FileObject.html#delete%28%29)
in interface[FileObject](FileObject.html "interface in javax.tools")
Returns:
true if and only if this file object is successfully deleted; false otherwise