org.netbeans.modules.java.source 0.80.1 17

org.netbeans.api.java.source
Class TypeMirrorHandle<T extends TypeMirror>

java.lang.Object
  extended by org.netbeans.api.java.source.TypeMirrorHandle<T>

public final class TypeMirrorHandle<T extends TypeMirror>
extends Object

Represents a handle for TypeMirror which can be kept and later resolved by another javac. The Javac TypeMirrors are valid only in the single CompilationTask or single run of the CancellableTask. If the client needs to keep a reference to the TypeMirror and use it in the other CancellableTask he has to serialize it into the TypeMirrorHandle.

Typical usage of TypeMirrorHandle is:

 final TypeMirrorHandle[] typeMirrorHandle = new TypeMirrorHandle[1];
 javaSource.runCompileControlTask(new CancellableTask() {
     public void run(CompilationController compilationController) {
         parameter.toPhase(Phase.RESOLVED);
         CompilationUnitTree cu = compilationController.getTree ();
         TypeMirror type = getInterestingType(cu);
         typeMirrorHandle[0] = TypeMirrorHandle.create (type);
    }
 },priority);

 otherJavaSource.runCompileControlTask(new CancellableTask() {
     public void run(CompilationController compilationController) {
         parameter.toPhase(Phase.RESOLVED);
         TypeMirror type = typeMirrorHandle[0].resolve (compilationController);
         ....
    }
 },priority);
 
Currently, not all the TypeMirror kinds are supported by handle. The unsupported kinds are: TypeKind.EXECUTABLE, TypeKind.OTHER, and TypeKind.PACKAGE.


Method Summary
static
<T extends TypeMirror>
TypeMirrorHandle<T>
create(T tm)
          Factory method for creating TypeMirrorHandle.
 TypeKind getKind()
          Returns the TypeKind of this handle, it is the kind of the TypeMirror from which the handle was created.
 T resolve(CompilationInfo info)
          Resolves an TypeMirror from the TypeMirrorHandle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

@NonNull
public static <T extends TypeMirror> TypeMirrorHandle<T> create(@NonNull
                                                                        T tm)
Factory method for creating TypeMirrorHandle.

Parameters:
{@link - TypeMirror} for which the TypeMirrorHandle should be created. Not all the TypeMirror kinds are currently supported. The unsupported kinds are: TypeKind.EXECUTABLE, TypeKind.OTHER, and TypeKind.PACKAGE.
Returns:
a new TypeMirrorHandle
Throws:
IllegalArgumentException - if the TypeMirror is of an unsupported TypeKind.

resolve

public T resolve(@NonNull
                 CompilationInfo info)
Resolves an TypeMirror from the TypeMirrorHandle.

Parameters:
{@link - CompilationInfo} representing the CompilationTask in which the TypeMirror should be resolved.
Returns:
resolved subclass of TypeMirror or null if the type cannot be resolved in this CompilationTask.

getKind

@NonNull
public TypeKind getKind()
Returns the TypeKind of this handle, it is the kind of the TypeMirror from which the handle was created.

Returns:
TypeKind

org.netbeans.modules.java.source 0.80.1 17

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.