|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.tools.SimpleJavaFileObject
public class SimpleJavaFileObject
Provides simple implementations for most methods in JavaFileObject. This class is designed to be subclassed and used as a basis for JavaFileObject implementations. Subclasses can override the implementation and specification of any method of this class as long as the general contract of JavaFileObject is obeyed.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface javax.tools.JavaFileObject |
---|
JavaFileObject.Kind |
Field Summary | |
---|---|
protected JavaFileObject.Kind |
kind
The kind of this file object. |
protected URI |
uri
A URI for this file object. |
Constructor Summary | |
---|---|
protected |
SimpleJavaFileObject(URI uri,
JavaFileObject.Kind kind)
Construct a SimpleJavaFileObject of the given kind and with the given URI. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final URI uri
protected final JavaFileObject.Kind kind
Constructor Detail |
---|
protected SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)
uri
- the URI for this file objectkind
- the kind of this file objectMethod Detail |
---|
public 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 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 occurredpublic CharSequence getCharContent(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 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 writing
UnsupportedOperationException
- if this kind of
file object does not support character access
IOException
- 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
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(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 kind
true
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())
toString
in class Object
|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.