Package com.sun.tools.jxc.model.nav
Class ApNavigator
java.lang.Object
com.sun.tools.jxc.model.nav.ApNavigator
- All Implemented Interfaces:
Navigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
public final class ApNavigator
extends Object
implements Navigator<TypeMirror,TypeElement,VariableElement,ExecutableElement>
Navigator implementation for annotation processing.
TODO: check the spec on how generics are supposed to be handled- Author:
- Kohsuke Kawaguchi (kk@kohsuke.org)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets theCrepresentation for the given class.asDecl(TypeMirror m) If the given type is an use of class declaration, returns the type casted asC.Computes the erasuregetBaseClass(TypeMirror type, TypeElement sup) Gets the parameterization of the given base type.getClassLocation(TypeElement typeElement) Returns a location of the specified class.Gets the fully-qualified name of the class.Gets the short name of the class ("Object" forObject.)Gets the component type of the array.getDeclaredField(TypeElement clazz, String fieldName) Gets the named field declared on the given class.getDeclaredFields(TypeElement typeElement) Gets all the declared fields of the given class.getDeclaredMethods(TypeElement typeElement) Gets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.)Gets the class that declares the given field.Gets the class that declares the given method.getEnumConstants(TypeElement clazz) Gets the enumeration constants from an enum class.getFieldLocation(VariableElement variableElement) Gets the name of the field.Gets the type of the field.getMethodLocation(ExecutableElement executableElement) Gets the name of the method, such as "toString" or "equals".Returns the list of parameters to the method.getPackageName(TypeElement clazz) Gets the package name of the given class.getPrimitive(Class<?> primitiveType) Returns the representation for the given primitive type.Gets the return type of a method.getSuperClass(TypeElement typeElement) Gets the base class of the specified class.getTypeArgument(TypeMirror typeMirror, int i) Gets the i-th type argument from a parameterized type.getTypeName(TypeMirror typeMirror) Gets the display name of the type objectGets the representation of the primitive "void" type.booleanReturns true if the given class has a no-arg default constructor.booleanisAbstract(TypeElement clazz) Returns true if this is an abstract class.booleanisArray(TypeMirror type) Checks if the type is an array type.booleanChecks if the type is an array type but not byte[].booleanisBridgeMethod(ExecutableElement method) Returns true if this method is a bridge method as defined in JLS.booleanReturns true if this is an enum class.booleanisFinal(TypeElement clazz) Returns true if this is a final class.booleanReturns true if the method is final.booleanisInnerClass(TypeElement clazz) Returns true if the given class is an inner class.booleanisInterface(TypeElement clazz) Returns true if 'clazz' is an interface.booleanisOverriding(ExecutableElement method, TypeElement base) Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors.booleanisParameterizedType(TypeMirror typeMirror) Returns true if t is a parameterized type.booleanChecks if the given type is a primitive type.booleanReturns true if the field is public.booleanReturns true if the method is public.booleanisSameType(TypeMirror t1, TypeMirror t2) Checks if types are the samebooleanReturns true if the field is static.booleanReturns true if the method is static.booleanisSubClassOf(TypeMirror sub, TypeMirror sup) Checks ifsubis a sub-type ofsup.booleanReturns true if the field is transient.loadObjectFactory(TypeElement referencePoint, String packageName) Finds ObjectFactory for the given referencePoint.Gets the representation of the given Java type inT.use(TypeElement t) Gets the T for the given C.
-
Constructor Details
-
ApNavigator
-
-
Method Details
-
getSuperClass
Description copied from interface:NavigatorGets the base class of the specified class.- Specified by:
getSuperClassin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Returns:
- null if the parameter represents
Object.
-
getBaseClass
Description copied from interface:NavigatorGets the parameterization of the given base type.For example, given the following
This method works like this:interface Foo<T> extends List<List<T>> {} interface Bar extends Foo<String> {}getBaseClass( Bar, List ) = List<List<String>> getBaseClass( Bar, Foo ) = Foo<String> getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>> getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>- Specified by:
getBaseClassin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
type- The type that derives frombaseTypesup- The class whose parameterization we are interested in.- Returns:
- The use of
baseTypeintype. or null if the type is not assignable to the base type.
-
getClassName
Description copied from interface:NavigatorGets the fully-qualified name of the class. ("java.lang.Object" forObject)- Specified by:
getClassNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getTypeName
Description copied from interface:NavigatorGets the display name of the type object- Specified by:
getTypeNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Returns:
- a human-readable name that the type represents.
-
getClassShortName
Description copied from interface:NavigatorGets the short name of the class ("Object" forObject.) For nested classes, this method should just return the inner name. (for example "Inner" for "com.acme.Outer$Inner".- Specified by:
getClassShortNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getDeclaredFields
Description copied from interface:NavigatorGets all the declared fields of the given class.- Specified by:
getDeclaredFieldsin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getDeclaredField
Description copied from interface:NavigatorGets the named field declared on the given class. This method doesn't visit ancestors, but does recognize non-public fields.- Specified by:
getDeclaredFieldin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Returns:
- null if not found
-
getDeclaredMethods
Description copied from interface:NavigatorGets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.)Note that this method does not list methods declared on base classes.
- Specified by:
getDeclaredMethodsin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Returns:
- can be empty but always non-null.
-
getDeclaringClassForField
Description copied from interface:NavigatorGets the class that declares the given field.- Specified by:
getDeclaringClassForFieldin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getDeclaringClassForMethod
Description copied from interface:NavigatorGets the class that declares the given method.- Specified by:
getDeclaringClassForMethodin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getFieldType
Description copied from interface:NavigatorGets the type of the field.- Specified by:
getFieldTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getFieldName
Description copied from interface:NavigatorGets the name of the field.- Specified by:
getFieldNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getMethodName
Description copied from interface:NavigatorGets the name of the method, such as "toString" or "equals".- Specified by:
getMethodNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getReturnType
Description copied from interface:NavigatorGets the return type of a method.- Specified by:
getReturnTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getMethodParameters
Description copied from interface:NavigatorReturns the list of parameters to the method.- Specified by:
getMethodParametersin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isStaticMethod
Description copied from interface:NavigatorReturns true if the method is static.- Specified by:
isStaticMethodin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isFinalMethod
Description copied from interface:NavigatorReturns true if the method is final.- Specified by:
isFinalMethodin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isSubClassOf
Description copied from interface:NavigatorChecks ifsubis a sub-type ofsup. TODO: should this method take T or C?- Specified by:
isSubClassOfin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
ref
Description copied from interface:NavigatorGets the representation of the given Java type inT.- Specified by:
refin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
c- can be a primitive, array, class, or anything. (therefore the return type has to be T, not C)
-
use
Description copied from interface:NavigatorGets the T for the given C.- Specified by:
usein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
asDecl
Description copied from interface:NavigatorIf the given type is an use of class declaration, returns the type casted asC. Otherwise null.TODO: define the exact semantics.
- Specified by:
asDeclin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
asDecl
Description copied from interface:NavigatorGets theCrepresentation for the given class. The behavior is undefined if the class object represents primitives, arrays, and other types that are not class declaration.- Specified by:
asDeclin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
erasure
Description copied from interface:NavigatorComputes the erasure- Specified by:
erasurein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isAbstract
Description copied from interface:NavigatorReturns true if this is an abstract class.- Specified by:
isAbstractin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isFinal
Description copied from interface:NavigatorReturns true if this is a final class.- Specified by:
isFinalin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getEnumConstants
Description copied from interface:NavigatorGets the enumeration constants from an enum class.- Specified by:
getEnumConstantsin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
clazz- must derive fromEnum.- Returns:
- can be empty but never null.
-
getVoidType
Description copied from interface:NavigatorGets the representation of the primitive "void" type.- Specified by:
getVoidTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getPackageName
Description copied from interface:NavigatorGets the package name of the given class.- Specified by:
getPackageNamein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Returns:
- i.e. "", "java.lang" but not null.
-
loadObjectFactory
Description copied from interface:NavigatorFinds ObjectFactory for the given referencePoint.- Specified by:
loadObjectFactoryin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
referencePoint- The class that refers to the specified class.- Returns:
- null if not found.
-
isBridgeMethod
Description copied from interface:NavigatorReturns true if this method is a bridge method as defined in JLS.- Specified by:
isBridgeMethodin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isOverriding
Description copied from interface:NavigatorReturns true if the given method is overriding another one defined in the base class 'base' or its ancestors.- Specified by:
isOverridingin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isInterface
Description copied from interface:NavigatorReturns true if 'clazz' is an interface.- Specified by:
isInterfacein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isTransient
Description copied from interface:NavigatorReturns true if the field is transient.- Specified by:
isTransientin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isInnerClass
Description copied from interface:NavigatorReturns true if the given class is an inner class. This is only used to improve the error diagnostics, so it's OK to fail to detect some inner classes as such. Note that this method should return false for nested classes (static classes.)- Specified by:
isInnerClassin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isSameType
Description copied from interface:NavigatorChecks if types are the same- Specified by:
isSameTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
t1- typet2- type- Returns:
- true if types are the same
-
isArray
Description copied from interface:NavigatorChecks if the type is an array type.- Specified by:
isArrayin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isArrayButNotByteArray
Description copied from interface:NavigatorChecks if the type is an array type but not byte[].- Specified by:
isArrayButNotByteArrayin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getComponentType
Description copied from interface:NavigatorGets the component type of the array.- Specified by:
getComponentTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
t- must be an array.
-
getTypeArgument
Description copied from interface:NavigatorGets the i-th type argument from a parameterized type. For example,getTypeArgument([Map<Integer,String>],0)=Integer- Specified by:
getTypeArgumentin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - See Also:
-
isParameterizedType
Description copied from interface:NavigatorReturns true if t is a parameterized type.- Specified by:
isParameterizedTypein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isPrimitive
Description copied from interface:NavigatorChecks if the given type is a primitive type.- Specified by:
isPrimitivein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getPrimitive
Description copied from interface:NavigatorReturns the representation for the given primitive type.- Specified by:
getPrimitivein interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement> - Parameters:
primitiveType- must be Class objects likeInteger.TYPE.
-
getClassLocation
Description copied from interface:NavigatorReturns a location of the specified class.- Specified by:
getClassLocationin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getFieldLocation
- Specified by:
getFieldLocationin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
getMethodLocation
- Specified by:
getMethodLocationin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
hasDefaultConstructor
Description copied from interface:NavigatorReturns true if the given class has a no-arg default constructor. The constructor does not need to be public.- Specified by:
hasDefaultConstructorin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isStaticField
Description copied from interface:NavigatorReturns true if the field is static.- Specified by:
isStaticFieldin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isPublicMethod
Description copied from interface:NavigatorReturns true if the method is public.- Specified by:
isPublicMethodin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isPublicField
Description copied from interface:NavigatorReturns true if the field is public.- Specified by:
isPublicFieldin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-
isEnum
Description copied from interface:NavigatorReturns true if this is an enum class.- Specified by:
isEnumin interfaceNavigator<TypeMirror,TypeElement, VariableElement, ExecutableElement>
-