|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.tools.jxc.model.nav.APTNavigator
public class APTNavigator
Navigator
implementation for APT.
TODO: check the spec on how generics are supposed to be handled
Field Summary |
---|
Fields inherited from interface com.sun.xml.bind.v2.model.nav.Navigator |
---|
REFLECTION |
Constructor Summary | |
---|---|
APTNavigator(AnnotationProcessorEnvironment env)
|
Method Summary | ||
---|---|---|
TypeDeclaration |
asDecl(java.lang.Class c)
If the given type is an use of class declaration, returns the type casted as C . |
|
TypeDeclaration |
asDecl(TypeMirror m)
If the given type is an use of class declaration, returns the type casted as C . |
|
|
erasure(TypeMirror t)
Computes the erasure |
|
TypeDeclaration |
findClass(java.lang.String className,
TypeDeclaration referencePoint)
Finds the class/interface/enum/annotation of the given name. |
|
TypeMirror |
getBaseClass(TypeMirror type,
TypeDeclaration sup)
Gets the parameterization of the given base type. |
|
Location |
getClassLocation(TypeDeclaration decl)
Returns a location of the specified class. |
|
java.lang.String |
getClassName(TypeDeclaration t)
Gets the fully-qualified name of the class. |
|
java.lang.String |
getClassShortName(TypeDeclaration t)
Gets the short name of the class ("Object" for Object .)
For nested classes, this method should just return the inner name. |
|
TypeMirror |
getComponentType(TypeMirror t)
Gets the component type of the array. |
|
FieldDeclaration |
getDeclaredField(TypeDeclaration clazz,
java.lang.String fieldName)
Gets the named field declared on the given class. |
|
java.util.Collection<FieldDeclaration> |
getDeclaredFields(TypeDeclaration c)
Gets all the declared fields of the given class. |
|
java.util.Collection<MethodDeclaration> |
getDeclaredMethods(TypeDeclaration c)
Gets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.) |
|
ClassDeclaration |
getDeclaringClassForField(FieldDeclaration f)
Gets the class that declares the given field. |
|
ClassDeclaration |
getDeclaringClassForMethod(MethodDeclaration m)
Gets the class that declares the given method. |
|
FieldDeclaration[] |
getEnumConstants(TypeDeclaration clazz)
Gets the enumeration constants from an enum class. |
|
Location |
getFieldLocation(FieldDeclaration decl)
|
|
java.lang.String |
getFieldName(FieldDeclaration f)
Gets the name of the field. |
|
TypeMirror |
getFieldType(FieldDeclaration f)
Gets the type of the field. |
|
Location |
getMethodLocation(MethodDeclaration decl)
|
|
java.lang.String |
getMethodName(MethodDeclaration m)
Gets the name of the method, such as "toString" or "equals". |
|
TypeMirror[] |
getMethodParameters(MethodDeclaration m)
Returns the list of parameters to the method. |
|
java.lang.String |
getPackageName(TypeDeclaration clazz)
Gets the package name of the given class. |
|
TypeMirror |
getPrimitive(java.lang.Class primitiveType)
Returns the representation for the given primitive type. |
|
TypeMirror |
getReturnType(MethodDeclaration m)
Gets the return type of a method. |
|
TypeDeclaration |
getSuperClass(TypeDeclaration t)
Gets the base class of the specified class. |
|
TypeMirror |
getTypeArgument(TypeMirror typeMirror,
int i)
Gets the i-th type argument from a parameterized type. |
|
java.lang.String |
getTypeName(TypeMirror typeMirror)
Gets the display name of the type object |
|
TypeMirror |
getVoidType()
Gets the representation of the primitive "void" type. |
|
boolean |
hasDefaultConstructor(TypeDeclaration t)
Returns true if the given class has a no-arg default constructor. |
|
boolean |
isAbstract(TypeDeclaration clazz)
Returns true if this is an abstract class. |
|
boolean |
isArray(TypeMirror t)
Checks if the type is an array type. |
|
boolean |
isArrayButNotByteArray(TypeMirror t)
Checks if the type is an array type but not byte[]. |
|
boolean |
isBridgeMethod(MethodDeclaration method)
Returns true if this method is a bridge method as defined in JLS. |
|
boolean |
isEnum(TypeDeclaration t)
Returns true if this is an enum class. |
|
boolean |
isFinal(TypeDeclaration clazz)
Returns true if this is a final class. |
|
boolean |
isFinalMethod(MethodDeclaration m)
Returns true if the method is final. |
|
boolean |
isInnerClass(TypeDeclaration clazz)
Returns true if the given class is an inner class. |
|
boolean |
isInterface(TypeDeclaration clazz)
Returns true if 'clazz' is an interface. |
|
boolean |
isOverriding(MethodDeclaration method,
TypeDeclaration base)
Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors. |
|
boolean |
isParameterizedType(TypeMirror t)
Returns true if t is a parameterized type. |
|
boolean |
isPrimitive(TypeMirror t)
Checks if the given type is a primitive type. |
|
boolean |
isPublicField(FieldDeclaration f)
Returns true if the field is public. |
|
boolean |
isPublicMethod(MethodDeclaration m)
Returns true if the method is public. |
|
boolean |
isStaticField(FieldDeclaration f)
Returns true if the field is static. |
|
boolean |
isStaticMethod(MethodDeclaration m)
Returns true if the method is static. |
|
boolean |
isSubClassOf(TypeMirror sub,
TypeMirror sup)
Checks if sub is a sub-type of sup . |
|
boolean |
isTransient(FieldDeclaration f)
Returns true if the field is transient. |
|
TypeMirror |
ref(java.lang.Class c)
Gets the representation of the given Java type in T . |
|
TypeMirror |
use(TypeDeclaration t)
Gets the T for the given C. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public APTNavigator(AnnotationProcessorEnvironment env)
Method Detail |
---|
public TypeDeclaration getSuperClass(TypeDeclaration t)
Navigator
getSuperClass
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
Object
.public TypeMirror getBaseClass(TypeMirror type, TypeDeclaration sup)
Navigator
For example, given the following
This method works like this:interface Foo extends List > {} interface Bar extends Foo
{}
getBaseClass( Bar, List ) = List getBaseClass( Bar, Foo ) = Foo
getBaseClass( Foo extends Number>, Collection ) = Collection > getBaseClass( ArrayList extends BigInteger>, List ) = List extends BigInteger>
getBaseClass
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
type
- The type that derives from baseType
sup
- The class whose parameterization we are interested in.
baseType
in type
.
or null if the type is not assignable to the base type.public java.lang.String getClassName(TypeDeclaration t)
Navigator
Object
)
getClassName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.lang.String getTypeName(TypeMirror typeMirror)
Navigator
getTypeName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.lang.String getClassShortName(TypeDeclaration t)
Navigator
Object
.)
For nested classes, this method should just return the inner name.
(for example "Inner" for "com.acme.Outer$Inner".
getClassShortName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.util.Collection<FieldDeclaration> getDeclaredFields(TypeDeclaration c)
Navigator
getDeclaredFields
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public FieldDeclaration getDeclaredField(TypeDeclaration clazz, java.lang.String fieldName)
Navigator
getDeclaredField
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.util.Collection<MethodDeclaration> getDeclaredMethods(TypeDeclaration c)
Navigator
Note that this method does not list methods declared on base classes.
getDeclaredMethods
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public ClassDeclaration getDeclaringClassForField(FieldDeclaration f)
Navigator
getDeclaringClassForField
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public ClassDeclaration getDeclaringClassForMethod(MethodDeclaration m)
Navigator
getDeclaringClassForMethod
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror getFieldType(FieldDeclaration f)
Navigator
getFieldType
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.lang.String getFieldName(FieldDeclaration f)
Navigator
getFieldName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.lang.String getMethodName(MethodDeclaration m)
Navigator
getMethodName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror getReturnType(MethodDeclaration m)
Navigator
getReturnType
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror[] getMethodParameters(MethodDeclaration m)
Navigator
getMethodParameters
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isStaticMethod(MethodDeclaration m)
Navigator
isStaticMethod
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isFinalMethod(MethodDeclaration m)
Navigator
isFinalMethod
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isSubClassOf(TypeMirror sub, TypeMirror sup)
Navigator
sub
is a sub-type of sup
.
TODO: should this method take T or C?
isSubClassOf
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror ref(java.lang.Class c)
Navigator
T
.
ref
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
c
- can be a primitive, array, class, or anything.
(therefore the return type has to be T, not C)public TypeMirror use(TypeDeclaration t)
Navigator
use
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeDeclaration asDecl(TypeMirror m)
Navigator
C
.
Otherwise null.
TODO: define the exact semantics.
asDecl
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeDeclaration asDecl(java.lang.Class c)
Navigator
C
.
Otherwise null.
TODO: define the exact semantics.
asDecl
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public <T> TypeMirror erasure(TypeMirror t)
Navigator
erasure
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isAbstract(TypeDeclaration clazz)
Navigator
isAbstract
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isFinal(TypeDeclaration clazz)
Navigator
isFinal
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public FieldDeclaration[] getEnumConstants(TypeDeclaration clazz)
Navigator
getEnumConstants
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
clazz
- must derive from Enum
.
public TypeMirror getVoidType()
Navigator
getVoidType
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public java.lang.String getPackageName(TypeDeclaration clazz)
Navigator
getPackageName
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeDeclaration findClass(java.lang.String className, TypeDeclaration referencePoint)
Navigator
findClass
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
referencePoint
- The class that refers to the specified class.
public boolean isBridgeMethod(MethodDeclaration method)
Navigator
isBridgeMethod
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isOverriding(MethodDeclaration method, TypeDeclaration base)
Navigator
isOverriding
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isInterface(TypeDeclaration clazz)
Navigator
isInterface
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isTransient(FieldDeclaration f)
Navigator
isTransient
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isInnerClass(TypeDeclaration clazz)
Navigator
isInnerClass
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isArray(TypeMirror t)
Navigator
isArray
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isArrayButNotByteArray(TypeMirror t)
Navigator
isArrayButNotByteArray
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror getComponentType(TypeMirror t)
Navigator
getComponentType
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
t
- must be an array.public TypeMirror getTypeArgument(TypeMirror typeMirror, int i)
Navigator
getTypeArgument([Map<Integer,String>],0)=Integer
getTypeArgument
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
Navigator.isParameterizedType(Object)
public boolean isParameterizedType(TypeMirror t)
Navigator
isParameterizedType
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isPrimitive(TypeMirror t)
Navigator
isPrimitive
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public TypeMirror getPrimitive(java.lang.Class primitiveType)
Navigator
getPrimitive
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
primitiveType
- must be Class objects like Integer.TYPE
.public Location getClassLocation(TypeDeclaration decl)
Navigator
getClassLocation
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public Location getFieldLocation(FieldDeclaration decl)
getFieldLocation
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public Location getMethodLocation(MethodDeclaration decl)
getMethodLocation
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean hasDefaultConstructor(TypeDeclaration t)
Navigator
hasDefaultConstructor
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isStaticField(FieldDeclaration f)
Navigator
isStaticField
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isPublicMethod(MethodDeclaration m)
Navigator
isPublicMethod
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isPublicField(FieldDeclaration f)
Navigator
isPublicField
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
public boolean isEnum(TypeDeclaration t)
Navigator
isEnum
in interface Navigator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |