- java.lang.Object
- 
- javax.tools.SimpleJavaFileObject
 
- 
- All Implemented Interfaces:
- FileObject,- JavaFileObject
 
 public class SimpleJavaFileObject extends Object implements JavaFileObject 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.- Since:
- 1.6
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces declared in interface javax.tools.JavaFileObjectJavaFileObject.Kind
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected JavaFileObject.KindkindThe kind of this file object.protected URIuriA URI for this file object.
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedSimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)Construct a SimpleJavaFileObject of the given kind and with the given URI.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandelete()This implementation does nothing.ModifiergetAccessLevel()This implementation returnsnull.CharSequencegetCharContent(boolean ignoreEncodingErrors)This implementation always throws UnsupportedOperationException.JavaFileObject.KindgetKind()Returns the kind of this file object.longgetLastModified()This implementation returns0L.NestingKindgetNestingKind()This implementation returnsnull.booleanisNameCompatible(String simpleName, JavaFileObject.Kind kind)This implementation compares the path of its URI to the given simple name.InputStreamopenInputStream()This implementation always throws UnsupportedOperationException.OutputStreamopenOutputStream()This implementation always throws UnsupportedOperationException.ReaderopenReader(boolean ignoreEncodingErrors)Wraps the result of getCharContent(boolean) in a Reader.WriteropenWriter()Wraps the result of openOutputStream in a Writer.- 
Methods declared in class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods declared in interface javax.tools.FileObjectgetName, toUri
 
- 
 
- 
- 
- 
Field Detail- 
uriprotected final URI uri A URI for this file object.
 - 
kindprotected final JavaFileObject.Kind kind The kind of this file object.
 
- 
 - 
Constructor Detail- 
SimpleJavaFileObjectprotected SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind) Construct a SimpleJavaFileObject of the given kind and with the given URI.- Parameters:
- uri- the URI for this file object
- kind- the kind of this file object
 
 
- 
 - 
Method Detail- 
openInputStreampublic InputStream openInputStream() throws IOException This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- openInputStreamin interface- FileObject
- Returns:
- an InputStream
- Throws:
- IOException- if an I/O error occurred
 
 - 
openOutputStreampublic OutputStream openOutputStream() throws IOException This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- openOutputStreamin interface- FileObject
- Returns:
- an OutputStream
- Throws:
- IOException- if an I/O error occurred
 
 - 
openReaderpublic Reader openReader(boolean ignoreEncodingErrors) throws IOException Wraps the result of getCharContent(boolean) in a Reader. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- openReaderin interface- FileObject
- Parameters:
- ignoreEncodingErrors- ignore encoding errors if true
- Returns:
- 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
 
 - 
getCharContentpublic CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- getCharContentin interface- FileObject
- Parameters:
- ignoreEncodingErrors- ignore encoding errors if true
- Returns:
- a CharSequence if available; nullotherwise
- Throws:
- IOException- if an I/O error occurred
 
 - 
openWriterpublic Writer openWriter() throws IOException Wraps the result of openOutputStream in a Writer. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- openWriterin interface- FileObject
- Returns:
- 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
 
 - 
getLastModifiedpublic long getLastModified() This implementation returns0L. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- getLastModifiedin interface- FileObject
- Returns:
- 0L
 
 - 
deletepublic boolean delete() This implementation does nothing. Subclasses can change this behavior as long as the contract ofFileObjectis obeyed.- Specified by:
- deletein interface- FileObject
- Returns:
- false
 
 - 
getKindpublic JavaFileObject.Kind getKind() Description copied from interface:JavaFileObjectReturns the kind of this file object.- Specified by:
- getKindin interface- JavaFileObject
- Returns:
- this.kind
 
 - 
isNameCompatiblepublic boolean isNameCompatible(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 tosimpleName + kind.extensionor if it ends with"/" + simpleName + kind.extension.This method calls getKind()andFileObject.toUri()and does not access the fieldsuriandkinddirectly.Subclasses can change this behavior as long as the contract of JavaFileObjectis obeyed.- Specified by:
- isNameCompatiblein interface- JavaFileObject
- Parameters:
- simpleName- a simple name of a class
- kind- a kind
- Returns:
- trueif this file object is compatible; false otherwise
 
 - 
getNestingKindpublic NestingKind getNestingKind() This implementation returnsnull. Subclasses can change this behavior as long as the contract ofJavaFileObjectis obeyed.- Specified by:
- getNestingKindin interface- JavaFileObject
- Returns:
- the nesting kind, or nullif the nesting kind is not known
 
 - 
getAccessLevelpublic Modifier getAccessLevel() This implementation returnsnull. Subclasses can change this behavior as long as the contract ofJavaFileObjectis obeyed.- Specified by:
- getAccessLevelin interface- JavaFileObject
- Returns:
- the access level
 
 
- 
 
-