|
org.netbeans.modules.java.source 0.80.1 17 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.java.source.ElementHandle<T>
public final class ElementHandle<T extends Element>
Represents a handle for Element
which can be kept and later resolved
by another javac. The javac Element
s are valid only in a single
CompilationTask
or a single run of a
CancellableTask
. A client needing to
keep a reference to an Element
and use it in another CancellableTask
must serialize it into an ElementHandle
.
Currently not all Element
s can be serialized. See create(T)
for details.
Typical usage of ElementHandle
is as follows:
final ElementHandle[] elementHandle = new ElementHandle[1]; javaSource.runUserActionTask(new Task<CompilationController>() { public void run(CompilationController compilationController) { compilationController.toPhase(Phase.RESOLVED); CompilationUnitTree cu = compilationController.getTree(); List<? extends Tree> types = getTypeDecls(cu); Tree tree = getInterestingElementTree(types); Element element = compilationController.getElement(tree); elementHandle[0] = ElementHandle.create(element); } }, true); otherJavaSource.runUserActionTask(new Task<CompilationController>() { public void run(CompilationController compilationController) { compilationController.toPhase(Phase.RESOLVED); Element element = elementHandle[0].resolve(compilationController); // .... } }, true);
Method Summary | ||
---|---|---|
static
|
create(T element)
Factory method for creating ElementHandle . |
|
boolean |
equals(Object other)
|
|
static ElementHandle<? extends TypeElement> |
from(TypeMirrorHandle<? extends DeclaredType> typeMirrorHandle)
Gets ElementHandle from TypeMirrorHandle representing DeclaredType . |
|
String |
getBinaryName()
Returns a binary name of the TypeElement represented by this
ElementHandle . |
|
ElementKind |
getKind()
Returns the ElementKind of this element handle,
it is the kind of the Element from which the handle
was created. |
|
String |
getQualifiedName()
Returns a qualified name of the TypeElement represented by this
ElementHandle . |
|
int |
hashCode()
|
|
T |
resolve(CompilationInfo compilationInfo)
Resolves an Element from the ElementHandle . |
|
boolean |
signatureEquals(ElementHandle<? extends Element> handle)
Tests if the handle has the same signature as the parameter. |
|
boolean |
signatureEquals(T element)
Tests if the handle has this same signature as the parameter. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
@CheckForNull public T resolve(@NonNull CompilationInfo compilationInfo)
Element
from the ElementHandle
.
compilationInfo
- representing the CompilationTask
in which the Element
should be resolved.
Element
or null if the elment does not exist on
the classpath/sourcepath of CompilationTask
.public boolean signatureEquals(@NonNull ElementHandle<? extends Element> handle)
JavaCompiler
task, but may be resolved into
the different Element
s in the different JavaCompiler
tasks.
handle
- to be checked
Element
s
in the same JavaCompiler
task.@NonNull public String getBinaryName() throws IllegalStateException
TypeElement
represented by this
ElementHandle
. When the ElementHandle
doesn't represent
a TypeElement
it throws a IllegalStateException
an
- IllegalStateException
when this ElementHandle
isn't created for the TypeElement
.
IllegalStateException
@NonNull public String getQualifiedName() throws IllegalStateException
TypeElement
represented by this
ElementHandle
. When the ElementHandle
doesn't represent
a TypeElement
it throws a IllegalStateException
an
- IllegalStateException
when this ElementHandle
isn't creatred for the TypeElement
.
IllegalStateException
public boolean signatureEquals(@NonNull T element)
JavaCompiler
task, but may be resolved into
the different Element
in the different JavaCompiler
task.
element
- to be checked
Element
in the same JavaCompiler
task.@NonNull public ElementKind getKind()
ElementKind
of this element handle,
it is the kind of the Element
from which the handle
was created.
ElementKind
@NonNull public static <T extends Element> ElementHandle<T> create(@NonNull T element) throws IllegalArgumentException
ElementHandle
.
element
- for which the ElementHandle
should be created. Permitted
ElementKind
s
are: ElementKind.PACKAGE
, ElementKind.CLASS
,
ElementKind.INTERFACE
, ElementKind.ENUM
, ElementKind.ANNOTATION_TYPE
, ElementKind.METHOD
,
ElementKind.CONSTRUCTOR
, ElementKind.INSTANCE_INIT
, ElementKind.STATIC_INIT
,
ElementKind.FIELD
, and ElementKind.ENUM_CONSTANT
.
ElementHandle
IllegalArgumentException
- if the element is of an unsupported ElementKind
@NonNull public static ElementHandle<? extends TypeElement> from(@NonNull TypeMirrorHandle<? extends DeclaredType> typeMirrorHandle)
ElementHandle
from TypeMirrorHandle
representing DeclaredType
.
typeMirrorHandle
- from which the ElementHandle
should be retrieved. Permitted
TypeKind
is TypeKind.DECLARED
.
ElementHandle
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
|
org.netbeans.modules.java.source 0.80.1 17 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |