public class SimpleJavaFileObject extends Objectimplements JavaFileObject
JavaFileObject.Kind | Modifier and Type | Field and Description |
|---|---|
protected JavaFileObject |
kind
The kind of this file object.
|
protected URI |
uri
A URI for this file object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleJavaFileObject(URI
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 |
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
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 URIuri
protected final JavaFileObject.Kind kind
protected SimpleJavaFileObject(URIuri, JavaFileObject .Kind kind)
uri - the URI for this file object
kind - the kind of this file object
public URItoUri()
FileObject
toUri in interface
FileObject
public StringgetName()
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 InputStreamopenInputStream() throws IOException
FileObject is obeyed.
openInputStream in interface
FileObject
IOException - if an I/O error occurred
public OutputStreamopenOutputStream() throws IOException
FileObject is obeyed.
openOutputStream in interface
FileObject
IOException - if an I/O error occurred
public ReaderopenReader(boolean ignoreEncodingErrors) throws IOException
FileObject is obeyed.
openReader in interface
FileObject
ignoreEncodingErrors - ignore encoding errors if true
IllegalStateException - if this file object was opened for writing and does not support reading
UnsupportedOperationException - if this kind of file object does not support character access
IOException - if an I/O error occurred
public CharSequencegetCharContent(boolean ignoreEncodingErrors) throws IOException
FileObject is obeyed.
getCharContent in interface
FileObject
ignoreEncodingErrors - ignore encoding errors if true
null otherwise
IOException - if an I/O error occurred
public WriteropenWriter() throws IOException
FileObject is obeyed.
openWriter in interface
FileObject
IllegalStateException - if this file object was opened for reading and does not support writing
UnsupportedOperationException - if this kind of file object does not support character access
IOException - if an I/O error occurred
public long getLastModified()
0L. Subclasses can change this behavior as long as the contract of
FileObject is obeyed.
getLastModified in interface
FileObject
0L
public boolean delete()
FileObject is obeyed.
delete in interface
FileObject
false
public JavaFileObject.Kind getKind()
JavaFileObject
getKind in interface
JavaFileObject
this.kind
public boolean isNameCompatible(StringsimpleName, 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 class
kind - a kind
true if this file object is compatible; false otherwise
public NestingKindgetNestingKind()
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 known
public ModifiergetAccessLevel()
null. Subclasses can change this behavior as long as the contract of
JavaFileObject is obeyed.
getAccessLevel in interface
JavaFileObject
public StringtoString()
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())