|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjparse.Type
jparse.SourceType
Information on a Java type defined in a Java source file.
Field Summary | |
(package private) boolean |
anonymous
true if this is an anonymous class |
private ConstrAST[] |
constrs
The constructors for this class |
private int |
dim
The dimension of the array represented by this type. |
(package private) FileAST |
file
The AST representing the file containing this parsed type |
private Type[] |
inner
The inner classes and interfaces of this type |
private Type[] |
interfaces
The interfaces this class implements, or this interface extends |
private int |
modifiers
The modifiers for this class |
private SourceType |
outer
For inner classes, a pointer to the enclosing class. |
private Type |
parent
The parent type |
private TypeAST |
theType
The AST representing this parsed type |
Fields inherited from class jparse.Type |
booleanType, byteType, charType, doubleType, floatType, intType, longType, map, objectType, pkgMap, shortType, stringType, voidType |
Constructor Summary | |
(package private) |
SourceType(SourceType original,
int dims)
Create a new SourceType object by modifying the dimension
of another SourceType object |
(package private) |
SourceType(TypeAST root)
Create a new SourceType object |
Method Summary | |
void |
anonCheckSuper()
Check whether this anonymous class is really extending a superclass, or if it is implementing an interface |
void |
dump()
Dump information about this type to standard error |
Type |
getArrayType()
Get the type that corresponds to an array of this type |
Type[] |
getClasses()
Returns an array containing Type objects representing all
the classes and interfaces that are members of this type. |
Type |
getComponentType()
Get the component type of an array, or return null if this
type does not represent an array |
Constructor |
getConstructor(Type[] params,
Type caller)
Get an object representing the constructor for this class with the specified parameter types |
Type |
getDeclaringClass()
If this is an inner class, return the outer class. |
Type |
getInner(String name)
Get an inner class with a specified name. |
Type[] |
getInterfaces()
Get the interfaces implemented by this type (if it is a class) or extended by this type (if it is an interface) |
Method |
getMethod(String methName,
Type[] paramTypes,
Type caller)
Get an object representing a method in this class with the specified parameter types |
Method[] |
getMethods()
Returns an array containing Method objects representing
all the methods that are members of this type. |
Method[] |
getMeths(String name,
Type[] params,
Type caller)
Retrieve matching methods |
int |
getModifiers()
Get the modifiers for this class, encoded as per The Java Virtual Machine Specification, table 4.1. |
String |
getName()
Get the fully qualified name of a type |
String |
getPackage()
Get the package in which the type definition resides |
Type |
getSuperclass()
Get the supertype of this Type object |
boolean |
isArray()
Determine whether this type represents an array type |
boolean |
isAssignableFrom(Type type)
Determine whether this type, as a formal parameter, can have a value of type type assigned to it as an actual parameter. |
boolean |
isInner()
Determine whether this type is an inner class |
boolean |
isInterface()
Determine whether this type represents an interface |
boolean |
isPrimitive()
Determine whether this type represents a Java primitive type |
String |
toString()
Return a string representation of the type |
Type |
varType(String varName)
Determine the type of a (static or instance) variable |
Methods inherited from class jparse.Type |
arithType, demangle, exists, forClass, forName, implementsInterface, mangle, mergeTypeLists, parseFile, parseFile, superClassOf, superInterfaceOf, varType |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
final FileAST file
boolean anonymous
true
if this is an anonymous class
private final TypeAST theType
private final int dim
private Type parent
private Type[] interfaces
private Type[] inner
private SourceType outer
null
.
private final int modifiers
private ConstrAST[] constrs
Constructor Detail |
SourceType(TypeAST root)
SourceType
object
root
- the root of the AST for this source fileSourceType(SourceType original, int dims)
SourceType
object by modifying the dimension
of another SourceType
object
original
- the original SourceType
objectdims
- the dimension of the array typeMethod Detail |
public void anonCheckSuper()
public boolean isAssignableFrom(Type type)
Type
java.lang.Class
when type is null
. It throws a
NullPointerException
, but this
checks whether this type is not primitive (i.e., is able to hold a
value of null
).
isAssignableFrom
in class Type
type
- the type to check against this type
true
if type can be the type of an
actual parameter passed into a method declared as taking this
type as a formal parameter; false
otherwisepublic boolean isInterface()
Type
isInterface
in class Type
true
if this type is an interfacepublic boolean isArray()
Type
isArray
in class Type
true
if this type is an array typepublic boolean isPrimitive()
Type
isPrimitive
in class Type
true
if this type is a Java primitive typepublic boolean isInner()
Type
isInner
in class Type
true
if this type is an inner classpublic String getName()
Type
getName
in class Type
public Type getSuperclass() throws ClassNotFoundException
Type
Type
object
getSuperclass
in class Type
Type
object
ClassNotFoundException
- if the superclass definition cannot
be foundpublic String getPackage()
Type
getPackage
in class Type
public Type[] getInterfaces()
Type
getInterfaces
in class Type
public Type getComponentType()
Type
null
if this
type does not represent an array
getComponentType
in class Type
public int getModifiers()
Type
getModifiers
in class Type
Modifier
public Type getDeclaringClass()
Type
null
getDeclaringClass
in class Type
null
if nonepublic Type[] getClasses()
Type
Type
objects representing all
the classes and interfaces that are members of this type. This
includes class and interface members inherited from superclasses and
class and interface members declared by the class. This method returns
an array of length 0 if this type has no member classes or interfaces.
This method also returns an array of length 0 if this is a primitive
type, an array class, or void
.
getClasses
in class Type
public Method[] getMethods()
Type
Method
objects representing
all the methods that are members of this type. This includes methods
inherited from superclasses, abstract methods defined by interfaces
(for abstract types only), and methods declared by this class. This
method returns an array of length 0 if this is a primitive type, an
array class, or void
.
getMethods
in class Type
public Method getMethod(String methName, Type[] paramTypes, Type caller)
Type
getMethod
in class Type
methName
- the name of the method to look upparamTypes
- the types of the parameterscaller
- the type in which the method call is contained (used to
check visibility)
Method
object representing the best-matching
method with those parameter types, or null
if there is
nonepublic Constructor getConstructor(Type[] params, Type caller)
Type
getConstructor
in class Type
params
- the types of the parameterscaller
- the type creating an instance of this object with
new
(used to check visibility)
Constructor
object representing the constructor
with those parameter types, or null
if there is nonepublic Type getInner(String name)
Type
getInner
in class Type
name
- the name of the inner class to lookup
null
otherwisepublic Type getArrayType()
Type
getArrayType
in class Type
public Type varType(String varName)
Type
varType
in class Type
varName
- the name of the variable to look up
public Method[] getMeths(String name, Type[] params, Type caller)
Type
getMeths
in class Type
name
- the name of the method to matchparams
- the types of the parameters to the methodcaller
- the type of the caller
public String toString()
public void dump()
Type
dump
in class Type
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |