|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.annotation.processing.AbstractProcessor
public abstract class AbstractProcessor
An abstract annotation processor designed to be a convenient superclass for most concrete annotation processors. This class examines annotation values to compute the options, annotations, and source version supported by its subtypes.
The getter methods may issue warnings about noteworthy conditions using the facilities available after the processor has been initialized.
Subclasses are free to override the implementation and
specification of any of the methods in this class as long as the
general Processor
contract for that method is obeyed.
Field Summary | |
---|---|
protected ProcessingEnvironment |
processingEnv
Processing environment providing by the tool framework. |
Constructor Summary | |
---|---|
protected |
AbstractProcessor()
Constructor for subclasses to call. |
Method Summary | |
---|---|
Iterable<? extends Completion> |
getCompletions(Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText)
Returns an empty iterable of completions. |
Set<String> |
getSupportedAnnotationTypes()
If the processor class is annotated with SupportedAnnotationTypes , return an unmodifiable set with the
same set of strings as the annotation. |
Set<String> |
getSupportedOptions()
If the processor class is annotated with SupportedOptions , return an unmodifiable set with the same set
of strings as the annotation. |
SourceVersion |
getSupportedSourceVersion()
If the processor class is annotated with SupportedSourceVersion , return the source version in the
annotation. |
void |
init(ProcessingEnvironment processingEnv)
Initializes the processor with the processing environment by setting the processingEnv field to the value of the
processingEnv argument. |
protected boolean |
isInitialized()
Returns true if this object has been initialized, false otherwise. |
abstract boolean |
process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv)
Processes a set of annotation types on type elements originating from the prior round and returns whether or not these annotations are claimed by this processor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ProcessingEnvironment processingEnv
Constructor Detail |
---|
protected AbstractProcessor()
Method Detail |
---|
public Set<String> getSupportedOptions()
SupportedOptions
, return an unmodifiable set with the same set
of strings as the annotation. If the class is not so
annotated, an empty set is returned.
getSupportedOptions
in interface Processor
SupportedOptions
public Set<String> getSupportedAnnotationTypes()
SupportedAnnotationTypes
, return an unmodifiable set with the
same set of strings as the annotation. If the class is not so
annotated, an empty set is returned.
getSupportedAnnotationTypes
in interface Processor
SupportedAnnotationTypes
public SourceVersion getSupportedSourceVersion()
SupportedSourceVersion
, return the source version in the
annotation. If the class is not so annotated, SourceVersion.RELEASE_6
is returned.
getSupportedSourceVersion
in interface Processor
SupportedSourceVersion
,
ProcessingEnvironment.getSourceVersion()
public void init(ProcessingEnvironment processingEnv)
processingEnv
field to the value of the
processingEnv
argument. An IllegalStateException
will be thrown if this method is called
more than once on the same object.
init
in interface Processor
processingEnv
- environment to access facilities the tool framework
provides to the processor
IllegalStateException
- if this method is called more than once.public abstract boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
true
is returned, the annotations are claimed and subsequent
processors will not be asked to process them; if false
is returned, the annotations are unclaimed and subsequent
processors may be asked to process them. A processor may
always return the same boolean value or may vary the result
based on chosen criteria.
The input set will be empty if the processor supports "*"
and the root elements have no annotations. A Processor
must gracefully handle an empty set of annotations.
process
in interface Processor
annotations
- the annotation types requested to be processedroundEnv
- environment for information about the current and prior round
public Iterable<? extends Completion> getCompletions(Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
getCompletions
in interface Processor
element
- the element being annotatedannotation
- the (perhaps partial) annotation being
applied to the elementmember
- the annotation member to return possible completions foruserText
- source code text to be completed
protected boolean isInitialized()
true
if this object has been initialized, false
otherwise.
true
if this object has been initialized,
false
otherwise.
|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.