TopBlend:
Here is the
first difference.
There are 152 differences.
is old.
is new.
javax.tools
Class SimpleJavaFileObject
java.lang.Object
javax.tools.SimpleJavaFileObject
-
All Implemented Interfaces:
-
FileObject
JavaFileObject
,
JavaFileObject
-
public 
abstract 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.
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
uri
name
protected final
URI
String
uri 
name
-
A URI for this file object.
The name of this file object. The name is without extension unless the kind is OTHER.
kind
protected final JavaFileObject.Kind kind
-
The kind of this file object.
SimpleJavaFileObject
protected 
public SimpleJavaFileObject(
URI
String
uri,

name,
JavaFileObject.Kind kind)
-
Construct a SimpleJavaFileObject of the given
kind
and with the given
URI.
name. Unless the kind is OTHER the name must be without extension.
-
Parameters:
-
uri
name
- the
URI for
name of
this file object -
kind - the kind of this file object
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
SimpleJavaFileObject
public
String
getName 
SimpleJavaFileObject
() 
( 
String
name)
-
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.
Construct a SimpleJavaFileObject with the given name. If the name includes an extension which matches an extension of a particular kind (JavaFileObject.Kind), then that kind is the kind of this object; otherwise the kind is OTHER.
-
-
Specified by:
Parameters:
-
getName
in interface
FileObject
name - the name of this file object
-
-
Returns:
-
a user-friendly name
Method Detail
|
openInputStream
delete
public
InputStream
public boolean
openInputStream 
delete
()
throws
IOException
()
-
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
This implementation does nothing.
-
-
Specified by:
-
openInputStream
delete
in interface
FileObject
JavaFileObject
-
-
Returns:
-
an InputStream
-
Throws:
-
IOException
- if an I/O error occurred
false
openOutputStream
getKind
public
OutputStream
JavaFileObject.Kind
openOutputStream 
getKind
()
throws
IOException
()
-
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
Gets the kind of this file object.
-
-
Specified by:
-
openOutputStream
getKind
in interface
FileObject
JavaFileObject
-
-
Returns:
-
an OutputStream
-
Throws:
-
IOException
- if an I/O error occurred
this.kind
openReader
getName
public
Reader
String
openReader 
getName
(boolean ignoreEncodingErrors)
throws
IOException
()
-
Wraps the result of
getCharContent(boolean)
Description copied from interface:
JavaFileObject
in a Reader. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
-
Gets the base name of this file object. Similar to java.io.File.getName.
-
-
Specified by:
-
openReader
getName
in interface
FileObject
JavaFileObject
-
-
Parameters:
-
ignoreEncodingErrors - ignore encoding errors if true
-
Returns:
-
a Reader wrapping the result of getCharContent
the base name
-
Throws:
See Also:
-
IllegalStateException
File.getName()
- 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
getNameWithoutExtension
public
CharSequence
String
getCharContent 
getNameWithoutExtension
(boolean ignoreEncodingErrors)
throws
IOException
()
-
This implementation always throws
UnsupportedOperationException
. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
Gets the base name of this file object without any extension.
-
-
Specified by:
-
getCharContent
getNameWithoutExtension
in interface
FileObject
JavaFileObject
-
-
Parameters:
-
ignoreEncodingErrors - ignore encoding errors if true
-
Returns:
-
a CharSequence if available; null otherwise
the name without extension
-
Throws:
See Also:
-
IOException
JavaFileObject.getName()
- if an I/O error occurred
openWriter
getPath
public
Writer
String
openWriter 
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.
Gets the path to this file object. Similar to java.io.File.getPath.
-
-
Specified by:
-
openWriter
getPath
in interface
FileObject
JavaFileObject
-
-
Returns:
-
a Writer wrapping the result of openOutputStream
the same as getName
-
Throws:
See Also:
-
IllegalStateException
File.getPath()
- 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
lastModified
public long
getLastModified 
lastModified ()
-
This implementation returns 0L.
Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
-
-
Specified by:
-
getLastModified
lastModified
in interface
FileObject
JavaFileObject
-
-
Returns:
-
0L
delete
lengthInBytes
public
boolean 
long
delete 
lengthInBytes ()
-
This implementation does nothing. Subclasses can change this behavior as long as the contract of
FileObject
is obeyed.
Gets the length of this file object in bytes, if byte access is supported.
This implemenation calls getCharContent(true).length() to get the length.
-
-
Specified by:
-
delete
lengthInBytes
in interface
FileObject
JavaFileObject
-
-
Returns:
-
false
the length in bytes if byte access is supported; -1 otherwise
getKind
matches
public
JavaFileObject.Kind
public boolean
getKind 
matches
() 
( 
String
simpleName,

JavaFileObject.Kind
kind)
-
Description copied from interface:
JavaFileObject
-
Gets the kind of this file object.
Checks if the name of this file object matches the specified simple name and kind.
Compares this.kind to kind and this.name to simpleName.
-
-
Specified by:
-
getKind
matches
in interface
JavaFileObject
-
-
Parameters:
-
simpleName - a simple name of a class
-
kind - a kind
-
Returns:
-
this.kind
true if this file object matches; false otherwise
isNameCompatible
toString
public boolean 
public 
String
isNameCompatible 
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.
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.
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:
Overrides:
-
isNameCompatible
toString
in interface
JavaFileObject
in class
Object
-
-
Parameters:
-
simpleName - a simple name of a class
-
kind - a kind
-
Returns:
-
true if this file object is compatible; false otherwise
a string representation of the object.
getNestingKind
openReader
public
NestingKind
Reader
getNestingKind 
openReader
() 
()
throws 
IOException
,

IllegalStateException
,

UnsupportedOperationException
-
This implementation returns null. Subclasses can change this behavior as long as the contract of
JavaFileObject
is obeyed.
Wraps the result of getCharContent in a Reader.
-
-
Specified by:
-
getNestingKind
openReader
in interface
JavaFileObject
-
-
Returns:
-
the nesting kind, or null if the nesting kind is not known
a Reader wrapping the result of getCharContent
-
Throws:
-
IOException
- if an I/O error occurred
-
IllegalStateException
- if this file object was opened for writing and doesn't support reading
-
UnsupportedOperationException
- if this kind of file object doesn't support character access
getAccessLevel
openWriter
public
Modifier
Writer
getAccessLevel 
openWriter
() 
()
throws 
IOException
,

IllegalStateException
,

UnsupportedOperationException
-
This implementation returns null. Subclasses can change this behavior as long as the contract of
JavaFileObject
is obeyed.
Wraps the result of openOutputStream in a Writer.
-
-
Specified by:
-
getAccessLevel
openWriter
in interface
JavaFileObject
-
-
Returns:
-
the access level
a Writer wrapping the result of openOutputStream
-
Throws:
-
IOException
-
IllegalStateException
-
UnsupportedOperationException
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.