public class SimpleJavaFileObject extends Object implements JavaFileObject
JavaFileObject.Kind| Modifier and Type | Field and Description |
|---|---|
protected JavaFileObject.Kind |
kind
这种文件对象的种类。
|
protected URI |
uri
此文件对象的URI。
|
| Modifier | Constructor and Description |
|---|---|
protected |
SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)
构造给定类型的SimpleJavaFileObject和给定的URI。
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
delete()
这个实现什么都不做。
|
Modifier |
getAccessLevel()
此实现返回
null 。
|
CharSequence |
getCharContent(boolean ignoreEncodingErrors)
这个实现总是抛出UnsupportedOperationException 。
|
JavaFileObject.Kind |
getKind()
获取此文件对象的种类。
|
long |
getLastModified()
此实现返回
0L 。
|
String |
getName()
获取此文件对象的用户友好名称。
|
NestingKind |
getNestingKind()
此实现返回
null 。
|
boolean |
isNameCompatible(String simpleName, JavaFileObject.Kind kind)
此实现将其URI的路径与给定的简单名称进行比较。
|
InputStream |
openInputStream()
这个实现总是抛出UnsupportedOperationException 。
|
OutputStream |
openOutputStream()
这个实现总是抛出UnsupportedOperationException 。
|
Reader |
openReader(boolean ignoreEncodingErrors)
将
getCharContent(boolean)的结果包装在阅读器中。
|
Writer |
openWriter()
在Writer中将openOutputStream的结果包起来。
|
String |
toString()
返回对象的字符串表示形式。
|
URI |
toUri()
返回标识此文件对象的URI。
|
protected final URI uri
protected final JavaFileObject.Kind kind
protected SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)
uri - 此文件对象的URI
kind - 这个文件对象的种类
public URI toUri()
FileObject
toUri在界面
FileObject
public String getName()
FileObject复制
"BobsApp\Test.java" ,则此方法应返回"BobsApp\Test.java"而toUri方法可能返回file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java 。
getName在接口
FileObject
public InputStream openInputStream() throws IOException
FileObject的合同, 子类就可以改变这种行为。
openInputStream在界面
FileObject
IOException - 如果发生I / O错误
public OutputStream openOutputStream() throws IOException
FileObject的合同, 子类就可以改变这种行为。
openOutputStream在界面
FileObject
IOException - 如果发生I / O错误
public Reader openReader(boolean ignoreEncodingErrors) throws IOException
FileObject的合同, 子类就可以改变这种行为。
openReader在接口
FileObject
ignoreEncodingErrors - 忽略编码错误,如果为true
IllegalStateException - 如果这个文件对象被打开来写入并且不支持读取
UnsupportedOperationException - 如果这种文件对象不支持字符访问
IOException - 如果发生I / O错误
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
FileObject的合同, 子类就可以改变这种行为。
getCharContent在接口
FileObject
ignoreEncodingErrors - 忽略编码错误,如果为true
null否则
IOException - 如果发生I / O错误
public Writer openWriter() throws IOException
FileObject的合同, 子类就可以改变这种行为。
openWriter在界面
FileObject
IllegalStateException - 如果此文件对象被打开以供阅读,并且不支持写入
UnsupportedOperationException - 如果这种文件对象不支持字符访问
IOException - 如果发生I / O错误
public long getLastModified()
0L 。
只要符合FileObject的合同, 子类就可以改变这种行为。
getLastModified在接口
FileObject
0L
public boolean delete()
FileObject的合同, 子类就可以改变这种行为。
delete在接口
FileObject
false
public JavaFileObject.Kind getKind()
JavaFileObject
getKind在界面
JavaFileObject
this.kind
public boolean isNameCompatible(String simpleName, JavaFileObject.Kind kind)
simpleName + kind.extension或它是否与结束"/" + simpleName + kind.extension 。
此方法调用getKind()和toUri() ,并且不直接访问字段uri和kind 。
只要符合JavaFileObject的合同, 子类就可以改变这种行为。
isNameCompatible在接口
JavaFileObject
simpleName - 类的简单名称
kind - 一种
true如果这个文件对象是兼容的;
否则为假
public NestingKind getNestingKind()
null 。
只要符合JavaFileObject的合同, 子类就可以改变这种行为。
getNestingKind在接口
JavaFileObject
null如果嵌套类型不知道
public Modifier getAccessLevel()
null 。
只要符合JavaFileObject的合同, 子类就可以改变这种行为。
getAccessLevel在接口
JavaFileObject
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.