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.Modifier and Type | Field and Description |
---|---|
static NavigatorImpl |
theInstance |
Modifier and Type | Method and Description |
---|---|
NClass |
asDecl(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(Class c) |
static NType |
create(Type t) |
static NType |
createParameterizedType(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
|
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.
|
String |
getClassName(NClass nClass)
Gets the fully-qualified name of the class.
|
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.
|
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 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(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 same
|
boolean |
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 if
sub is a sub-type of sup . |
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(Class c)
Gets the representation of the given Java type in
T . |
NClass |
ref(JClass c) |
NType |
use(NClass nc)
Gets the T for the given C.
|
public static final NavigatorImpl theInstance
public NClass getSuperClass(NClass nClass)
Navigator
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>
public String getClassName(NClass nClass)
Navigator
Object
)public String getTypeName(NType type)
Navigator
public 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".public Collection<? extends Void> getDeclaredFields(NClass nClass)
Navigator
public Void getDeclaredField(NClass clazz, String fieldName)
Navigator
public Collection<? extends Void> getDeclaredMethods(NClass nClass)
Navigator
Note that this method does not list methods declared on base classes.
public NClass getDeclaringClassForField(Void aVoid)
Navigator
public NClass getDeclaringClassForMethod(Void aVoid)
Navigator
public NType getFieldType(Void aVoid)
Navigator
public String getFieldName(Void aVoid)
Navigator
public String getMethodName(Void aVoid)
Navigator
public NType getReturnType(Void aVoid)
Navigator
public NType[] getMethodParameters(Void aVoid)
Navigator
public boolean isStaticMethod(Void aVoid)
Navigator
public boolean isFinalMethod(Void aVoid)
Navigator
public boolean isSubClassOf(NType sub, NType sup)
Navigator
sub
is a sub-type of sup
.
TODO: should this method take T or C?public NClass ref(Class 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(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
public NType getComponentType(NType nType)
Navigator
public NType getTypeArgument(NType nt, int i)
Navigator
getTypeArgument([Map<Integer,String>],0)=Integer
getTypeArgument
in interface Navigator<NType,NClass,Void,Void>
Navigator.isParameterizedType(Object)
public boolean isParameterizedType(NType nt)
Navigator
public boolean isPrimitive(NType type)
Navigator
public NType getPrimitive(Class primitiveType)
Navigator
getPrimitive
in interface Navigator<NType,NClass,Void,Void>
primitiveType
- must be Class objects like Integer.TYPE
.public static NType createParameterizedType(NClass rawType, NType... args)
NType
representation for a parameterized type
RawType<ParamType1,ParamType2,...>
.public Location getClassLocation(NClass c)
Navigator
public boolean hasDefaultConstructor(NClass nClass)
Navigator
public boolean isStaticField(Void aVoid)
Navigator
public boolean isPublicMethod(Void aVoid)
Navigator
public boolean isPublicField(Void aVoid)
Navigator
public boolean isEnum(NClass c)
Navigator
public <T> NType erasure(NType type)
Navigator
public boolean isAbstract(NClass clazz)
Navigator
public boolean isFinal(NClass clazz)
Navigator
public Void[] getEnumConstants(NClass clazz)
Navigator
public NType getVoidType()
Navigator
public String getPackageName(NClass clazz)
Navigator
public NClass loadObjectFactory(NClass referencePoint, String pkg)
Navigator
public boolean isBridgeMethod(Void method)
Navigator
public boolean isOverriding(Void method, NClass clazz)
Navigator
public boolean isInterface(NClass clazz)
Navigator
public boolean isTransient(Void f)
Navigator
public boolean isInnerClass(NClass clazz)
Navigator
Copyright © 2017 JBoss by Red Hat. All rights reserved.