|
Préférences
Moteurs de recherche
|
||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
javax.annotation.processing
|
Method Summary | |
---|---|
JavaFileObject |
createClassFile(CharSequence name,
Element... originatingElements)
Creates a new class file, and returns an object to allow writing to it. |
FileObject |
createResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName,
Element... originatingElements)
Creates a new auxiliary resource file for writing and returns a file object for it. |
JavaFileObject |
createSourceFile(CharSequence name,
Element... originatingElements)
Creates a new source file and returns an object to allow writing to it. |
FileObject |
getResource(JavaFileManager.Location location,
CharSequence pkg,
CharSequence relativeName)
Returns an object for reading an existing resource. |
Method Detail |
---|
JavaFileObject createSourceFile(CharSequence name, Element... originatingElements) throws IOException
name
be the
package's name followed by ".package-info"
; to create a
source file for an unnamed package, use "package-info"
.
Note that to use a particular charset to encode the contents of the
file, an OutputStreamWriter
with the chosen charset can
be created from the OutputStream
from the returned
object. If the Writer
from the returned object is
directly used for writing, its charset is determined by the
implementation. An annotation processing tool may have an
-encoding
flag or analogous option for specifying this;
otherwise, it will typically be the platform's default
encoding.
To avoid subsequent errors, the contents of the source file should be compatible with the source version being used for this run.
name
- canonical (fully qualified) name of the principal type
being declared in this file or a package name followed by
".package-info"
for a package information fileoriginatingElements
- type or package elements causally
associated with the creation of this file, may be elided or
null
JavaFileObject
to write the new source file
FilerException
- if the same pathname has already been
created, the same type has already been created, or the name is
not valid for a type
IOException
- if the file cannot be createdJavaFileObject createClassFile(CharSequence name, Element... originatingElements) throws IOException
name
be the
package's name followed by ".package-info"
; creating a
class file for an unnamed package is not supported.
To avoid subsequent errors, the contents of the class file should be compatible with the source version being used for this run.
name
- binary name of the type being written or a package name followed by
".package-info"
for a package information fileoriginatingElements
- type or package elements causally
associated with the creation of this file, may be elided or
null
JavaFileObject
to write the new class file
FilerException
- if the same pathname has already been
created, the same type has already been created, or the name is
not valid for a type
IOException
- if the file cannot be createdFileObject createResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName, Element... originatingElements) throws IOException
CLASS_OUTPUT
and SOURCE_OUTPUT
must be
supported. The resource may be named relative to some package
(as are source and class files), and from there by a relative
pathname. In a loose sense, the full pathname of the new file
will be the concatenation of location
, pkg
, and
relativeName
.
Files created via this method are not registered for annotation processing, even if the full pathname of the file would correspond to the full pathname of a new source file or new class file.
location
- location of the new filepkg
- package relative to which the file should be named,
or the empty string if nonerelativeName
- final pathname components of the fileoriginatingElements
- type or package elements causally
associated with the creation of this file, may be elided or
null
FileObject
to write the new resource
IOException
- if the file cannot be created
FilerException
- if the same pathname has already been
created
IllegalArgumentException
- for an unsupported location
IllegalArgumentException
- if relativeName
is not relativeFileObject getResource(JavaFileManager.Location location, CharSequence pkg, CharSequence relativeName) throws IOException
CLASS_OUTPUT
and SOURCE_OUTPUT
must
be supported.
location
- location of the filepkg
- package relative to which the file should be searched,
or the empty string if nonerelativeName
- final pathname components of the file
FilerException
- if the same pathname has already been
opened for writing
IOException
- if the file cannot be opened
IllegalArgumentException
- for an unsupported location
IllegalArgumentException
- if relativeName
is not relative