is new.
java.lang.Objectjavax.tools.SimpleJavaFileObject
FileObject
,
JavaFileObject
publicabstractclass SimpleJavaFileObject
Provides simple implementations for most methods in JavaFileObject. This class is designed to be subclassed and used as a basis for JavaFileObject implementations.
See JavaFileObject for a definition of extensions.
Subclasses can override the implementation and specification of any method of this class as long as the general contract of JavaFileObject is obeyed.
Since:
1.6
| 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
|
| Constructor Summary | |
|---|---|
protected
|
SimpleJavaFileObject
URI
uri,
JavaFileObject.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
for
object.
|
NestingKind
|
getNestingKind
This implementation returns null.
|
boolean
|
isNameCompatible
(
String
simpleName,
JavaFileObject.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)
|
| 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 |
|---|
uri
protected finalURI
Stringuri
name
A URI for this file object.
protected final JavaFileObject.Kind kind
| Constructor Detail |
|---|
protected
publicSimpleJavaFileObject(URI
Stringuri,
name,JavaFileObject.Kind kind)
kind
and with the given
URI.
uri
URI for
Method Detail
|
|---|
toUri
public
URI
toUri
()
Description copied from interface:
FileObject
Returns a URI identifying this file object.
Specified by:
toUri
in interface
FileObject
Returns:
a URI
getName
publicString
getName
SimpleJavaFileObject()
(Stringname)
Description copied from interface:
FileObject
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 "BobsJavaApp\Test.java" on the command line, this method should return "BobsJavaApp\Test.java" whereas the
toUri
method might return file:///C:/Documents%20and%20Settings/UncleBob/BobsJavaApp/Test.java.
Specified by:
getName
in interface
FileObject
Returns:
a user-friendly name
|
|---|
openInputStream
public
InputStream
public booleanopenInputStream
delete() throws
IOException
()
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
openInputStream
FileObject
an InputStream
Throws:
IOException
- if an I/O error occurred
openOutputStream
publicOutputStream
JavaFileObject.KindopenOutputStream
getKind() throws
IOException
()
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
openOutputStream
FileObject
an OutputStream
Throws:
IOException
- if an I/O error occurred
openReader
publicReader
StringopenReader
getName(boolean ignoreEncodingErrors) throws
IOException
()
Wraps the result of
getCharContent(boolean)
in a Reader. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
openReader
FileObject
Parameters:
ignoreEncodingErrors - ignore encoding errors if true
a Reader wrapping the result of getCharContent
Throws:
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
getCharContent
publicCharSequence
StringgetCharContent
getNameWithoutExtension(boolean ignoreEncodingErrors) throws
IOException
()
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
getCharContent
FileObject
Parameters:
ignoreEncodingErrors - ignore encoding errors if true
a CharSequence if available; null otherwise
Throws:
IOException
- if an I/O error occurred
openWriter
publicWriter
StringopenWriter
getPath() throws
IOException
()
Wraps the result of openOutputStream in a Writer. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
openWriter
FileObject
a Writer wrapping the result of openOutputStream
Throws:
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
getLastModified
public longgetLastModified
lastModified()
Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
getLastModified
FileObject
delete
publicboolean
longdelete
lengthInBytes()
This implementation does nothing. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
This implemenation calls getCharContent(true).length() to get the length.
delete
FileObject
false
getKind
public
JavaFileObject.Kind
public booleangetKind
matches()
(StringsimpleName,JavaFileObject.Kindkind)
Description copied from interface:
JavaFileObject
Gets the kind of this file object.
Compares this.kind to kind and this.name to simpleName.
getKind
this.kind
isNameCompatible
public boolean
publicStringisNameCompatible
toString(
String
simpleName,
JavaFileObject.Kind
kind)
()
This implementation compares the path of its URI to the given simple name. This method returns true if the given kind is equal to the kind of this object, and if the path is equal to 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.
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())
Subclasses can change this behavior as long as the contract of
JavaFileObject
is obeyed.
The exact value returned by this method is unspecified.
Specified by:
isNameCompatible
in interface
JavaFileObject
Parameters:
simpleName - a simple name of a class
kind - a kind
true if this file object is compatible; false otherwise
getNestingKind
publicNestingKind
ReadergetNestingKind
openReader()
() throwsIOException,IllegalStateException,UnsupportedOperationException
This implementation returns null. Subclasses can change this behavior as long as the contract of
JavaFileObject
is obeyed.
getNestingKind
the nesting kind, or null if the nesting kind is not known
getAccessLevel
publicModifier
WritergetAccessLevel
openWriter()
() throwsIOException,IllegalStateException,UnsupportedOperationException
This implementation returns null. Subclasses can change this behavior as long as the contract of
JavaFileObject
is obeyed.
getAccessLevel
the access level
toString
public
String
toString
()
Description copied from class:
Object
Returns a string representation of the object. In general, the 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())
Overrides:
toString
in class
Object
Returns:
a string representation of the object.