|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The fundamental JOT element is the class, represented by the JotClass interface. This is analogous to the java reflection class java.lang.Class and has similar methods (in fact, many comments are borrowed from there).
JotClassSource
Method Summary | |
void |
addUserData(java.lang.Object key,
java.lang.Object data)
Allows client supplied data to be associated with this JotClass. |
JotClass |
getComponentType()
If this Jotclass represents an array type, returns the JotClass object representing the component type of the array; otherwise returns null. |
JotConstructor |
getConstructor(JotClass[] parameterTypes)
Returns a Constructor object that reflects the specified declared constructor of the class or interface represented by this JotClass object. |
JotConstructor[] |
getConstructors()
Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this JotClass object. |
JotConstructor |
getDeclaredConstructor(JotClass[] parameterTypes)
Returns a Constructor object that reflects the specified public constructor of the class represented by this JotClass object. |
JotConstructor[] |
getDeclaredConstructors()
Returns an array of Constructor objects reflecting all the constructors declared by the class represented by this JotClass object. |
JotField |
getDeclaredField(java.lang.String name)
Returns a Field object that reflects the specified declared field of the class or interface represented by this JotClass object. |
JotField[] |
getDeclaredFields()
Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this JotClass object. |
JotClass[] |
getDeclaredInnerClasses()
Returns an array of JotClass objects reflecting the collection of all inner classes of this class. |
JotMethod |
getDeclaredMethod(java.lang.String name,
JotClass[] parameterTypes)
Returns a Method object that reflects the specified declared method of the class or interface represented by this JotClass object. |
JotMethod[] |
getDeclaredMethods()
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this JotClass object. |
JotMethod[] |
getDeclaredMethods(java.lang.String name)
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this JotClass object that match name . |
JotField |
getField(java.lang.String name)
Returns a Field object that reflects the specified public member field of the class or interface represented by this JotClass object. |
JotField[] |
getFields()
Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this JotClass object. |
JotFile |
getFile()
|
JotClass[] |
getInnerClasses()
Returns an array of JotClass objects reflecting the collection of all inner classes of this class as well as all the inner classes of all its superclasses. |
JotType[] |
getInterfaces()
Returns an array of classIds representing the interfaces of the class or interface represented by this JotClass object. |
JotMethod |
getMethod(java.lang.String name,
JotClass[] parameterTypes)
Returns a Method object that reflects the specified public member method of the class or interface represented by this JotClass object. |
JotMethod[] |
getMethods()
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this JotClass object, including those declared by the class or interface and and those inherited from superclasses and superinterfaces. |
JotMethod[] |
getMethods(java.lang.String methodName)
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this JotClass object that match the methodName passed in, including those declared by the class or
interface and and those inherited from superclasses and superinterfaces. |
int |
getModifiers()
Returns the Java language modifiers for this class or interface, encoded in an integer. |
java.lang.String |
getName()
Returns the fully-qualified name of the type (class, interface, array, or primitive) represented by this JotClass object, as a String. |
JotType |
getSuperclass()
If this JotClass object represents a class other than Object, returns the JotClass that represents the superclass of the class. |
JotType |
getType()
Returns a JotType object that refers to this class |
java.lang.Object |
getUserData(java.lang.Object key)
Retrieves client data associated with this JotClass. |
boolean |
isArray()
Determines if this JotClass object represents an array type. |
boolean |
isAssignableFrom(JotClass cls)
Informally, this method tests whether the class or interface represented by this JotClass object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified JotClass parameter. |
boolean |
isInstance(java.lang.Object obj)
This method is the dynamic equivalent of the Java language instanceof operator. |
boolean |
isInterface()
Determines if this JotClass object represents an interface type |
boolean |
isPrimitive()
Determines if this JotClass object represents a primitive Java type. |
java.lang.Object |
newInstance()
Attempts to create and initialize a new instance of the class represented by this JotClass object, provided it represents an instantiable class (whether a declared class or an array class). |
Method Detail |
public JotFile getFile()
public boolean isInstance(java.lang.Object obj)
instanceof
operator. The method returns true if
the specified Object argument is non-null and can be cast to
the reference type represented by this JotClass object without
raising a ClassCastException. It returns false otherwise.
Specifically, if this JotClass object represents a declared class, returns true if the specified Object argument is an instance of the represented class (or of any of its subclasses); false otherwise. If this JotClass object represents an array class, returns true if the specified Object argument can be converted to an object of the array type by an identity conversion or by a widening reference conversion; false otherwise. If this JotClass object represents an interface, returns true if the class or any superclass of the specified Object argument implements this interface; false otherwise. If this JotClass object represents a primitive type, returns false.
obj
- The object to checkpublic boolean isAssignableFrom(JotClass cls)
Specifically, this method tests whether the type represented by the specified JotClass parameter can be converted to the type represented by this JotClass object via an identity conversion or via a widening reference conversion.
See The Java Language Specification, sections 5.1.1 and 5.1.4 for more information.
cls
- the class or interface represented by the JotClass object to
be tested
true
if the JotClass object is either the same as, or is a
superclass or superinterface of, the class or interface represented by the
specified JotClass parameter. If this JotClass object represents a primitive
type, returns true
if the specified JotClass parameter is exactly
this JotClass object, false otherwise.
java.lang.NullPointerException
- If the specified JotClass parameter is null.public boolean isInterface()
true
if it represents an interface.public boolean isPrimitive()
There are nine predefined JotClass objects to represent the eight primitive Java types and void. These are created by the Java Virtual Machine, and have the same names as the primitive types that they represent, namely boolean, byte, char, short, int, long, float, and double, and void.
These objects may only be accessed via the following public static final variables, and are the only JotClass objects for which this method returns true.
true
if this JotClass object represents a primitive type.
JotPrimitiveClass.booleanType
,
JotPrimitiveClass.charType
,
JotPrimitiveClass.byteType
,
JotPrimitiveClass.shortType
,
JotPrimitiveClass.intType
,
JotPrimitiveClass.longType
,
JotPrimitiveClass.floatType
,
JotPrimitiveClass.doubleType
,
JotPrimitiveClass.voidType
public boolean isArray()
true
if this JotClass object represents an array type.public JotClass getComponentType()
java.lang.reflect.Array
public java.lang.String getName()
public JotType getType()
public int getModifiers()
The modifier encodings are defined in The Java Virtual Machine Specification, table 4.1.
Modifier
public JotType getSuperclass()
public JotType[] getInterfaces()
public JotField[] getDeclaredFields()
See The Java Language Specification, sections 8.2 and 8.3 for more information..
java.lang.SecurutyException
- If access to this information is denied.
Field
public JotField getDeclaredField(java.lang.String name)
java.lang.NoSuchFieldException
- If a field with the specified name is not found.java.lang.SecurityException
- If access to this information is denied.
Field
public JotField[] getFields()
Specifically, if this JotClass object represents a class, returns the public fields of this class and of all its superclasses. If this JotClass object represents an interface, returns the fields of this interface and of all its superinterfaces. If this JotClass object represents an array type or a primitive type, returns an array of length 0.
The implicit length field for array types is not reflected by this method. User code should use the methods of class Array to manipulate arrays.
See The Java Language Specification, sections 8.2 and 8.3 for more information.
java.lang.SecurityException
- If access to this information is denied.
Field
public JotField getField(java.lang.String name)
The field to be reflected is located by searching all the member fields of the class or interface represented by this JotClass object for a public field with the specified name.
See The Java Language Specification, sections 8.2 and 8.3, for more information.
java.lang.NoSuchFieldException
- If a matching field is not found.java.lang.SecurityException
- If access to the underlying field is denied.
Field
public JotMethod[] getDeclaredMethods()
See The Java Language Specification, section 8.2 for more information.
java.lang.SecurityException
- If access to this information is denied.
Method
public JotMethod[] getDeclaredMethods(java.lang.String name)
name
. This includes public, protected, default (package)
access, and private methods, but excludes inherited
methods. Returns an array of length 0 if the class or interface
declares no methods, or if this JotClass object represents a
primitive type. This is useful if you have multiple implementations of a
method in a class.
See The Java Language Specification, section 8.2 for more information.
name
- is the name of the method sought
java.lang.SecurityException
- If access to this information is denied.
Method
public JotMethod getDeclaredMethod(java.lang.String name, JotClass[] parameterTypes)
name
- is a String that specifies the simple name of the desired methodparameterTypes
- is an array of JotClass objects that identify the
method's formal parameter types, in declared order.
java.lang.NoSuchMethodException
- If a matching method is not found.java.lang.SecurityException
- If access to the underlying method is denied.
Method
public JotMethod[] getMethods()
See The Java Language Specification, sections 8.2 and 8.4 for more information.
java.lang.SecurityException
- if access to this information is denied.
Method
public JotMethod[] getMethods(java.lang.String methodName)
methodName
passed in, including those declared by the class or
interface and and those inherited from superclasses and superinterfaces. Returns
an array of length 0 if the class or interface has no public member methods
that match methodName
.
See The Java Language Specification, sections 8.2 and 8.4 for more information.
methodName
- A string representation of the name of the method sought.
java.lang.SecurityException
- if access to this information is denied.
Method
public JotMethod getMethod(java.lang.String name, JotClass[] parameterTypes)
The method to reflect is located by searching all the member methods of the class or interface represented by this JotClass object for a public method with the specified name and exactly the same formal parameter types.
See The Java Language Specification, sections 8.2 and 8.4, for more information.
java.lang.NoSuchMethodException
- If a matching method is not found.java.lang.SecurityException
- If access to the underlying method is denied.
Method
public JotConstructor[] getDeclaredConstructors()
See The Java Language Specification, section 8.2, for more information.
java.lang.SecurityException
- If access to this information is denied.
Constructor
public JotConstructor getDeclaredConstructor(JotClass[] parameterTypes)
The constructor to reflect is located by searching all the constructors of the class represented by this JotClass object for a public constructor with the exactly the same formal parameter types.
java.lang.NoSuchMethodException
- If a matching constructor is not found.java.lang.SecurityException
- If access to the underlying constructor is denied.
Constructor
public JotConstructor[] getConstructors()
java.lang.SecurityException
- If access to this information is denied.
Constructor
public JotConstructor getConstructor(JotClass[] parameterTypes)
java.lang.NoSuchMethodException
- If a matching constructor is not found.java.lang.SecurityException
- If access to the underlying constructor is denied.
Constructor
public JotClass[] getDeclaredInnerClasses()
public JotClass[] getInnerClasses()
public java.lang.Object newInstance() throws java.lang.InstantiationException, java.lang.IllegalAccessException
java.lang.InstantiationException
- If you try to instantiate
an abstract class or an interface or a primitive type, or if the
instantiation fails for some other reason.java.lang.IllegalAccessException
- If the class or initializer
is not accessible.public void addUserData(java.lang.Object key, java.lang.Object data)
key
- an Object which will can be used to identify the datadata
- an Object which a Jot client would like associated with this
JotClass. If the value is null, then the user data will be removed for
this item.
getUserData
public java.lang.Object getUserData(java.lang.Object key)
key
- is the Object which identifies the client data to extract.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |