|
org.netbeans.modules.java.source 0.13.0 1 | |||||||||
| 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>
Represents a handle for Element which can be kept and later resolved
by another javac. The javac Elements 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 Elements can be serialized. See create(T) for details.
Typical usage of ElementHandle is as follows:
final ElementHandle[] elementHandle = new ElementHandle[1];
javaSource.runUserActionTask(new CancellableTask<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 CancellableTask<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)
|
|
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 |
|---|
public T resolve(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(ElementHandle<? extends Element> handle)
JavaCompiler task, but may be resolved into
the different Elements in the different JavaCompiler tasks.
handle - to be checked
Elements
in the same JavaCompiler task.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 creatred for the TypeElement.
IllegalStateExceptionpublic 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.
IllegalStateExceptionpublic boolean signatureEquals(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.public ElementKind getKind()
ElementKind of this element handle,
it is the kind of the Element from which the handle
was created.
ElementKindpublic static <T extends Element> ElementHandle<T> create(T element) throws IllegalArgumentException
ElementHandle.
element - for which the ElementHandle should be created. Permitted
ElementKinds
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 ElementKindpublic String toString()
public int hashCode()
public boolean equals(Object other)
|
org.netbeans.modules.java.source 0.13.0 1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||