public final class NavigatorImpl extends java.lang.Object implements Navigator<NType,NClass,java.lang.Void,java.lang.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.Modifier and Type | Field and Description |
---|---|
static NavigatorImpl |
theInstance |
REFLECTION
Modifier and Type | Method and Description |
---|---|
NClass |
asDecl(java.lang.Class c)
Gets the
C representation for the given class. |
NClass |
asDecl(NType nt)
If the given type is an use of class declaration,
returns the type casted as
C . |
static NClass |
create(java.lang.Class c) |
static NType |
create(java.lang.reflect.Type t) |
static NType |
createParameterizedType(java.lang.Class rawType,
NType... args) |
static NType |
createParameterizedType(NClass rawType,
NType... args)
Creates a
NType representation for a parameterized type
RawType<ParamType1,ParamType2,...> . |
<T> NType |
erasure(NType type)
Computes the erasure
|
NClass |
findClass(java.lang.String className,
NClass referencePoint)
Finds the class/interface/enum/annotation of the given name.
|
NType |
getBaseClass(NType nt,
NClass base)
Gets the parameterization of the given base type.
|
Location |
getClassLocation(NClass c)
Returns a location of the specified class.
|
java.lang.String |
getClassName(NClass nClass)
Gets the fully-qualified name of the class.
|
java.lang.String |
getClassShortName(NClass nClass)
Gets the short name of the class ("Object" for
Object .)
For nested classes, this method should just return the inner name. |
NType |
getComponentType(NType nType)
Gets the component type of the array.
|
java.lang.Void |
getDeclaredField(NClass clazz,
java.lang.String fieldName)
Gets the named field declared on the given class.
|
java.util.Collection<? extends java.lang.Void> |
getDeclaredFields(NClass nClass)
Gets all the declared fields of the given class.
|
java.util.Collection<? extends java.lang.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(java.lang.Void aVoid)
Gets the class that declares the given field.
|
NClass |
getDeclaringClassForMethod(java.lang.Void aVoid)
Gets the class that declares the given method.
|
java.lang.Void[] |
getEnumConstants(NClass clazz)
Gets the enumeration constants from an enum class.
|
Location |
getFieldLocation(java.lang.Void _) |
java.lang.String |
getFieldName(java.lang.Void aVoid)
Gets the name of the field.
|
NType |
getFieldType(java.lang.Void aVoid)
Gets the type of the field.
|
Location |
getMethodLocation(java.lang.Void _) |
java.lang.String |
getMethodName(java.lang.Void aVoid)
Gets the name of the method, such as "toString" or "equals".
|
NType[] |
getMethodParameters(java.lang.Void aVoid)
Returns the list of parameters to the method.
|
java.lang.String |
getPackageName(NClass clazz)
Gets the package name of the given class.
|
NType |
getPrimitive(java.lang.Class primitiveType)
Returns the representation for the given primitive type.
|
NType |
getReturnType(java.lang.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.
|
java.lang.String |
getTypeName(NType type)
Gets the display name of the type object
|
NType |
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(java.lang.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(java.lang.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(java.lang.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(java.lang.Void aVoid)
Returns true if the field is public.
|
boolean |
isPublicMethod(java.lang.Void aVoid)
Returns true if the method is public.
|
boolean |
isSameType(NType t1,
NType t2)
Checks if types are the same
|
boolean |
isStaticField(java.lang.Void aVoid)
Returns true if the field is static.
|
boolean |
isStaticMethod(java.lang.Void aVoid)
Returns true if the method is static.
|
boolean |
isSubClassOf(NType sub,
NType sup)
Checks if
sub is a sub-type of sup . |
boolean |
isTransient(java.lang.Void f)
Returns true if the field is transient.
|
NClass |
ref(java.lang.Class c)
Gets the representation of the given Java type in
T . |
NClass |
ref(JClass c)
Gets the representation of the given Java type in
T . |
NType |
use(NClass nc)
Gets the T for the given C.
|
public static final NavigatorImpl theInstance
public NClass getSuperClass(NClass nClass)
Navigator
getSuperClass
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
Object
.public NType getBaseClass(NType nt, NClass base)
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<NType,NClass,java.lang.Void,java.lang.Void>
nt
- The type that derives from baseType
base
- 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(NClass nClass)
Navigator
Object
)getClassName
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.String getTypeName(NType type)
Navigator
getTypeName
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.String getClassShortName(NClass nClass)
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<NType,NClass,java.lang.Void,java.lang.Void>
public java.util.Collection<? extends java.lang.Void> getDeclaredFields(NClass nClass)
Navigator
getDeclaredFields
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.Void getDeclaredField(NClass clazz, java.lang.String fieldName)
Navigator
getDeclaredField
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.util.Collection<? extends java.lang.Void> getDeclaredMethods(NClass nClass)
Navigator
Note that this method does not list methods declared on base classes.
getDeclaredMethods
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NClass getDeclaringClassForField(java.lang.Void aVoid)
Navigator
getDeclaringClassForField
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NClass getDeclaringClassForMethod(java.lang.Void aVoid)
Navigator
getDeclaringClassForMethod
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NType getFieldType(java.lang.Void aVoid)
Navigator
getFieldType
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.String getFieldName(java.lang.Void aVoid)
Navigator
getFieldName
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.String getMethodName(java.lang.Void aVoid)
Navigator
getMethodName
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NType getReturnType(java.lang.Void aVoid)
Navigator
getReturnType
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NType[] getMethodParameters(java.lang.Void aVoid)
Navigator
getMethodParameters
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isStaticMethod(java.lang.Void aVoid)
Navigator
isStaticMethod
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isFinalMethod(java.lang.Void aVoid)
Navigator
isFinalMethod
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isSubClassOf(NType sub, NType sup)
Navigator
sub
is a sub-type of sup
.
TODO: should this method take T or C?isSubClassOf
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NClass ref(java.lang.Class c)
Navigator
T
.public NClass ref(JClass c)
Navigator
T
.public NType use(NClass nc)
Navigator
public NClass asDecl(NType nt)
Navigator
C
.
Otherwise null.
TODO: define the exact semantics.
public NClass asDecl(java.lang.Class c)
Navigator
C
representation for the given class.
The behavior is undefined if the class object represents
primitives, arrays, and other types that are not class declaration.public boolean isArray(NType nType)
Navigator
public boolean isArrayButNotByteArray(NType t)
Navigator
isArrayButNotByteArray
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NType getComponentType(NType nType)
Navigator
getComponentType
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
nType
- must be an array.public NType getTypeArgument(NType nt, int i)
Navigator
getTypeArgument([Map<Integer,String>],0)=Integer
getTypeArgument
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
Navigator.isParameterizedType(Object)
public boolean isParameterizedType(NType nt)
Navigator
isParameterizedType
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isPrimitive(NType type)
Navigator
isPrimitive
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NType getPrimitive(java.lang.Class primitiveType)
Navigator
getPrimitive
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
primitiveType
- must be Class objects like Integer.TYPE
.public static final NType create(java.lang.reflect.Type t)
public static NClass create(java.lang.Class c)
public static NType createParameterizedType(NClass rawType, NType... args)
NType
representation for a parameterized type
RawType<ParamType1,ParamType2,...>
.public static NType createParameterizedType(java.lang.Class rawType, NType... args)
public Location getClassLocation(NClass c)
Navigator
getClassLocation
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public Location getFieldLocation(java.lang.Void _)
getFieldLocation
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public Location getMethodLocation(java.lang.Void _)
getMethodLocation
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean hasDefaultConstructor(NClass nClass)
Navigator
hasDefaultConstructor
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isStaticField(java.lang.Void aVoid)
Navigator
isStaticField
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isPublicMethod(java.lang.Void aVoid)
Navigator
isPublicMethod
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isPublicField(java.lang.Void aVoid)
Navigator
isPublicField
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isEnum(NClass c)
Navigator
public <T> NType erasure(NType type)
Navigator
public boolean isAbstract(NClass clazz)
Navigator
isAbstract
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isFinal(NClass clazz)
Navigator
public java.lang.Void[] getEnumConstants(NClass clazz)
Navigator
getEnumConstants
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
clazz
- must derive from Enum
.public NType getVoidType()
Navigator
getVoidType
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public java.lang.String getPackageName(NClass clazz)
Navigator
getPackageName
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public NClass findClass(java.lang.String className, NClass referencePoint)
Navigator
public boolean isBridgeMethod(java.lang.Void method)
Navigator
isBridgeMethod
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isOverriding(java.lang.Void method, NClass clazz)
Navigator
isOverriding
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isInterface(NClass clazz)
Navigator
isInterface
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isTransient(java.lang.Void f)
Navigator
isTransient
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>
public boolean isInnerClass(NClass clazz)
Navigator
isInnerClass
in interface Navigator<NType,NClass,java.lang.Void,java.lang.Void>