- java.lang.Object
-
- com.sun.tools.xjc.model.nav.NavigatorImpl
-
public final class NavigatorImpl extends Object implements Navigator<NType,NClass,Void,Void>
Navigator
implementation for XJC. Most of the Navigator methods are used for parsing the model, which doesn't happen in XJC. So Most of the methods aren't really implemented. Implementations should be filled in as needed.- Author:
- Kohsuke Kawaguchi
-
-
Field Summary
Fields Modifier and Type Field Description static NavigatorImpl
theInstance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description NClass
asDecl(NType nt)
If the given type is an use of class declaration, returns the type casted asC
.NClass
asDecl(Class c)
Gets theC
representation for the given class.static NClass
create(Class c)
static NType
create(Type t)
static NType
createParameterizedType(NClass rawType, NType... args)
Creates aNType
representation for a parameterized typeRawType<ParamType1,ParamType2,...>
.static NType
createParameterizedType(Class rawType, NType... args)
<T> NType
erasure(NType type)
Computes the erasureNType
getBaseClass(NType nt, NClass base)
Gets the parameterization of the given base type.Location
getClassLocation(NClass c)
Returns a location of the specified class.String
getClassName(NClass nClass)
Gets the fully-qualified name of the class.String
getClassShortName(NClass nClass)
Gets the short name of the class ("Object" forObject
.) For nested classes, this method should just return the inner name.NType
getComponentType(NType nType)
Gets the component type of the array.Void
getDeclaredField(NClass clazz, String fieldName)
Gets the named field declared on the given class.Collection<? extends Void>
getDeclaredFields(NClass nClass)
Gets all the declared fields of the given class.Collection<? extends Void>
getDeclaredMethods(NClass nClass)
Gets all the declared methods of the given class (regardless of their access modifiers, regardless of whether they override methods of the base classes.)NClass
getDeclaringClassForField(Void aVoid)
Gets the class that declares the given field.NClass
getDeclaringClassForMethod(Void aVoid)
Gets the class that declares the given method.Void[]
getEnumConstants(NClass clazz)
Gets the enumeration constants from an enum class.Location
getFieldLocation(Void v)
String
getFieldName(Void aVoid)
Gets the name of the field.NType
getFieldType(Void aVoid)
Gets the type of the field.Location
getMethodLocation(Void v)
String
getMethodName(Void aVoid)
Gets the name of the method, such as "toString" or "equals".NType[]
getMethodParameters(Void aVoid)
Returns the list of parameters to the method.String
getPackageName(NClass clazz)
Gets the package name of the given class.NType
getPrimitive(Class primitiveType)
Returns the representation for the given primitive type.NType
getReturnType(Void aVoid)
Gets the return type of a method.NClass
getSuperClass(NClass nClass)
Gets the base class of the specified class.NType
getTypeArgument(NType nt, int i)
Gets the i-th type argument from a parameterized type.String
getTypeName(NType type)
Gets the display name of the type objectNType
getVoidType()
Gets the representation of the primitive "void" type.boolean
hasDefaultConstructor(NClass nClass)
Returns true if the given class has a no-arg default constructor.boolean
isAbstract(NClass clazz)
Returns true if this is an abstract class.boolean
isArray(NType nType)
Checks if the type is an array type.boolean
isArrayButNotByteArray(NType t)
Checks if the type is an array type but not byte[].boolean
isBridgeMethod(Void method)
Returns true if this method is a bridge method as defined in JLS.boolean
isEnum(NClass c)
Returns true if this is an enum class.boolean
isFinal(NClass clazz)
Deprecated.no class generated by XJC is final.boolean
isFinalMethod(Void aVoid)
Returns true if the method is final.boolean
isInnerClass(NClass clazz)
Returns true if the given class is an inner class.boolean
isInterface(NClass clazz)
Returns true if 'clazz' is an interface.boolean
isOverriding(Void method, NClass clazz)
Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors.boolean
isParameterizedType(NType nt)
Returns true if t is a parameterized type.boolean
isPrimitive(NType type)
Checks if the given type is a primitive type.boolean
isPublicField(Void aVoid)
Returns true if the field is public.boolean
isPublicMethod(Void aVoid)
Returns true if the method is public.boolean
isSameType(NType t1, NType t2)
Checks if types are the sameboolean
isStaticField(Void aVoid)
Returns true if the field is static.boolean
isStaticMethod(Void aVoid)
Returns true if the method is static.boolean
isSubClassOf(NType sub, NType sup)
Checks ifsub
is a sub-type ofsup
.boolean
isTransient(Void f)
Returns true if the field is transient.NClass
loadObjectFactory(NClass referencePoint, String pkg)
Finds ObjectFactory for the given referencePoint.NClass
ref(JClass c)
NClass
ref(Class c)
Gets the representation of the given Java type inT
.NType
use(NClass nc)
Gets the T for the given C.
-
-
-
Field Detail
-
theInstance
public static final NavigatorImpl theInstance
-
-
Method Detail
-
getSuperClass
public NClass getSuperClass(NClass nClass)
Description copied from interface:Navigator
Gets the base class of the specified class.
-
getBaseClass
public NType getBaseClass(NType nt, NClass base)
Description copied from interface:Navigator
Gets 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>
-
getClassName
public String getClassName(NClass nClass)
Description copied from interface:Navigator
Gets the fully-qualified name of the class. ("java.lang.Object" forObject
)
-
getTypeName
public String getTypeName(NType type)
Description copied from interface:Navigator
Gets the display name of the type object
-
getClassShortName
public String getClassShortName(NClass nClass)
Description copied from interface:Navigator
Gets 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".
-
getDeclaredFields
public Collection<? extends Void> getDeclaredFields(NClass nClass)
Description copied from interface:Navigator
Gets all the declared fields of the given class.
-
getDeclaredField
public Void getDeclaredField(NClass clazz, String fieldName)
Description copied from interface:Navigator
Gets the named field declared on the given class. This method doesn't visit ancestors, but does recognize non-public fields.
-
getDeclaredMethods
public Collection<? extends Void> getDeclaredMethods(NClass nClass)
Description copied from interface:Navigator
Gets 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.
-
getDeclaringClassForField
public NClass getDeclaringClassForField(Void aVoid)
Description copied from interface:Navigator
Gets the class that declares the given field.
-
getDeclaringClassForMethod
public NClass getDeclaringClassForMethod(Void aVoid)
Description copied from interface:Navigator
Gets the class that declares the given method.
-
getFieldType
public NType getFieldType(Void aVoid)
Description copied from interface:Navigator
Gets the type of the field.
-
getFieldName
public String getFieldName(Void aVoid)
Description copied from interface:Navigator
Gets the name of the field.
-
getMethodName
public String getMethodName(Void aVoid)
Description copied from interface:Navigator
Gets the name of the method, such as "toString" or "equals".
-
getReturnType
public NType getReturnType(Void aVoid)
Description copied from interface:Navigator
Gets the return type of a method.
-
getMethodParameters
public NType[] getMethodParameters(Void aVoid)
Description copied from interface:Navigator
Returns the list of parameters to the method.
-
isStaticMethod
public boolean isStaticMethod(Void aVoid)
Description copied from interface:Navigator
Returns true if the method is static.
-
isFinalMethod
public boolean isFinalMethod(Void aVoid)
Description copied from interface:Navigator
Returns true if the method is final.
-
isSubClassOf
public boolean isSubClassOf(NType sub, NType sup)
Description copied from interface:Navigator
Checks ifsub
is a sub-type ofsup
. TODO: should this method take T or C?
-
ref
public NClass ref(Class c)
Description copied from interface:Navigator
Gets the representation of the given Java type inT
.
-
use
public NType use(NClass nc)
Description copied from interface:Navigator
Gets the T for the given C.
-
asDecl
public NClass asDecl(NType nt)
Description copied from interface:Navigator
If the given type is an use of class declaration, returns the type casted asC
. Otherwise null.TODO: define the exact semantics.
-
asDecl
public NClass asDecl(Class c)
Description copied from interface:Navigator
Gets theC
representation for the given class. The behavior is undefined if the class object represents primitives, arrays, and other types that are not class declaration.
-
isArray
public boolean isArray(NType nType)
Description copied from interface:Navigator
Checks if the type is an array type.
-
isArrayButNotByteArray
public boolean isArrayButNotByteArray(NType t)
Description copied from interface:Navigator
Checks if the type is an array type but not byte[].
-
getComponentType
public NType getComponentType(NType nType)
Description copied from interface:Navigator
Gets the component type of the array.
-
getTypeArgument
public NType getTypeArgument(NType nt, int i)
Description copied from interface:Navigator
Gets the i-th type argument from a parameterized type. For example,getTypeArgument([Map<Integer,String>],0)=Integer
- Specified by:
getTypeArgument
in interfaceNavigator<NType,NClass,Void,Void>
- See Also:
Navigator.isParameterizedType(Object)
-
isParameterizedType
public boolean isParameterizedType(NType nt)
Description copied from interface:Navigator
Returns true if t is a parameterized type.
-
isPrimitive
public boolean isPrimitive(NType type)
Description copied from interface:Navigator
Checks if the given type is a primitive type.
-
getPrimitive
public NType getPrimitive(Class primitiveType)
Description copied from interface:Navigator
Returns the representation for the given primitive type.- Specified by:
getPrimitive
in interfaceNavigator<NType,NClass,Void,Void>
- Parameters:
primitiveType
- must be Class objects likeInteger.TYPE
.
-
createParameterizedType
public static NType createParameterizedType(NClass rawType, NType... args)
Creates aNType
representation for a parameterized typeRawType<ParamType1,ParamType2,...>
.
-
getClassLocation
public Location getClassLocation(NClass c)
Description copied from interface:Navigator
Returns a location of the specified class.
-
hasDefaultConstructor
public boolean hasDefaultConstructor(NClass nClass)
Description copied from interface:Navigator
Returns true if the given class has a no-arg default constructor. The constructor does not need to be public.
-
isStaticField
public boolean isStaticField(Void aVoid)
Description copied from interface:Navigator
Returns true if the field is static.
-
isPublicMethod
public boolean isPublicMethod(Void aVoid)
Description copied from interface:Navigator
Returns true if the method is public.
-
isPublicField
public boolean isPublicField(Void aVoid)
Description copied from interface:Navigator
Returns true if the field is public.
-
isEnum
public boolean isEnum(NClass c)
Description copied from interface:Navigator
Returns true if this is an enum class.
-
erasure
public <T> NType erasure(NType type)
Description copied from interface:Navigator
Computes the erasure
-
isAbstract
public boolean isAbstract(NClass clazz)
Description copied from interface:Navigator
Returns true if this is an abstract class.
-
isFinal
@Deprecated public boolean isFinal(NClass clazz)
Deprecated.no class generated by XJC is final.Description copied from interface:Navigator
Returns true if this is a final class.
-
getEnumConstants
public Void[] getEnumConstants(NClass clazz)
Description copied from interface:Navigator
Gets the enumeration constants from an enum class.
-
getVoidType
public NType getVoidType()
Description copied from interface:Navigator
Gets the representation of the primitive "void" type.
-
getPackageName
public String getPackageName(NClass clazz)
Description copied from interface:Navigator
Gets the package name of the given class.
-
loadObjectFactory
public NClass loadObjectFactory(NClass referencePoint, String pkg)
Description copied from interface:Navigator
Finds ObjectFactory for the given referencePoint.
-
isBridgeMethod
public boolean isBridgeMethod(Void method)
Description copied from interface:Navigator
Returns true if this method is a bridge method as defined in JLS.
-
isOverriding
public boolean isOverriding(Void method, NClass clazz)
Description copied from interface:Navigator
Returns true if the given method is overriding another one defined in the base class 'base' or its ancestors.
-
isInterface
public boolean isInterface(NClass clazz)
Description copied from interface:Navigator
Returns true if 'clazz' is an interface.
-
isTransient
public boolean isTransient(Void f)
Description copied from interface:Navigator
Returns true if the field is transient.
-
isInnerClass
public boolean isInnerClass(NClass clazz)
Description copied from interface:Navigator
Returns 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.)
-
-