public class SimpleJavaFileObject extends Object implements JavaFileObject
JavaFileObject.Kind | Modifier and Type | Field and Description |
|---|---|
protected JavaFileObject.Kind |
kind
The kind of this file object.
|
protected URI |
uri
A URI for this file object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleJavaFileObject (URI uri,
JavaFileObject.Kind kind)
Construct a SimpleJavaFileObject of the given kind and with the
given URI.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete ()
This implementation does nothing.
|
Modifier |
getAccessLevel ()
This implementation returns
null. |
CharSequence |
getCharContent (boolean ignoreEncodingErrors)
This implementation always throws UnsupportedOperationException.
|
JavaFileObject.Kind |
getKind ()
Gets the kind of this file object.
|
long |
getLastModified ()
This implementation returns
0L. |
String |
getName ()
Gets a user-friendly name for this file object.
|
NestingKind |
getNestingKind ()
This implementation returns
null. |
boolean |
isNameCompatible (String simpleName,
JavaFileObject.Kind kind)
This implementation compares the path of its URI to the given
simple name.
|
InputStream |
openInputStream ()
This implementation always throws UnsupportedOperationException.
|
OutputStream |
openOutputStream ()
This implementation always throws UnsupportedOperationException.
|
Reader |
openReader (boolean ignoreEncodingErrors)
Wraps the result of getCharContent(boolean) in a Reader.
|
Writer |
openWriter ()
Wraps the result of openOutputStream in a Writer.
|
String |
toString ()
Returns a string representation of the object.
|
URI |
toUri ()
Returns a URI identifying this file object.
|
protected final URI uri
protected final JavaFileObject.Kind kind
protected SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)
uri - the URI for this file objectkind - the kind of this file objectpublic URI toUri()
FileObject toUri in interface FileObject public String getName()
FileObject "BobsApp\Test.java" on
the command line, this method should return "BobsApp\Test.java" whereas the toUri
method might return file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java.getName in interface FileObject public InputStream openInputStream() throws IOException
FileObject is
obeyed.openInputStream in interface FileObject IOException - if an I/O error occurredpublic OutputStream openOutputStream() throws IOException
FileObject is
obeyed.openOutputStream in interface FileObject IOException - if an I/O error occurredpublic Reader openReader(boolean ignoreEncodingErrors) throws IOException
FileObject is obeyed.openReader in interface FileObject ignoreEncodingErrors - ignore encoding errors if trueIllegalStateException - if this file object was
opened for writing and does not support readingUnsupportedOperationException - if this kind of
file object does not support character accessIOException - if an I/O error occurredpublic CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
FileObject is
obeyed.getCharContent in interface FileObject ignoreEncodingErrors - ignore encoding errors if truenull otherwiseIOException - if an I/O error occurredpublic Writer openWriter() throws IOException
FileObject is obeyed.openWriter in interface FileObject IllegalStateException - if this file object was
opened for reading and does not support writingUnsupportedOperationException - if this kind of
file object does not support character accessIOException - if an I/O error occurredpublic long getLastModified()
0L. Subclasses can change
this behavior as long as the contract of FileObject is
obeyed.getLastModified in interface FileObject 0Lpublic boolean delete()
FileObject is
obeyed.delete in interface FileObject falsepublic JavaFileObject.Kind getKind()
JavaFileObject getKind in interface JavaFileObject this.kindpublic boolean isNameCompatible(String simpleName, JavaFileObject.Kind kind)
simpleName + kind.extension or if it ends with "/" + simpleName + kind.extension.
This method calls getKind() and toUri() and
does not access the fields uri and kind
directly.
Subclasses can change this behavior as long as the contract
of JavaFileObject is obeyed.
isNameCompatible in interface JavaFileObject simpleName - a simple name of a classkind - a kindtrue if this file object is compatible; false
otherwisepublic NestingKind getNestingKind()
null. Subclasses can
change this behavior as long as the contract of
JavaFileObject is obeyed.getNestingKind in interface JavaFileObject null if the nesting kind
is not knownpublic Modifier getAccessLevel()
null. Subclasses can
change this behavior as long as the contract of
JavaFileObject is obeyed.getAccessLevel in interface JavaFileObject public String toString()
Object toString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
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, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.