com.plumtree.openfoundation.util
Class XPType

java.lang.Object
  extended bycom.plumtree.openfoundation.util.XPType

public class XPType
extends java.lang.Object

Instances of the class XPType represent classes and interfaces in a running Plumtree application. Every array also belongs to a class that is reflected as a XPType object that is shared by all arrays with the same element type and number of dimensions. The primitive types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.

XPType has no public constructor. Instead XPType objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.


Field Summary
static XPType BOOLEAN
          The XPType object representing the primitive type boolean.
static XPType BYTE
          The XPType object representing the primitive type byte.
static XPType CHAR
          The XPType object representing the primitive type char.
static XPType DOUBLE
          The XPType object representing the primitive type double.
static XPType FLOAT
          The XPType object representing the primitive type float.
static XPType INTEGER
          The XPType object representing the primitive type int.
static XPType LONG
          The XPType object representing the primitive type long.
static XPType SHORT
          The XPType object representing the primitive type short.
static XPType VOID
          The XPType object representing the primitive type void.
 
Constructor Summary
XPType(java.lang.Class _class)
          XPType Constructor and it takes Class Object.
 
Method Summary
 java.lang.Object CreateInstance()
          Creates a new instance of the class represented by this XPType object.
 boolean equals(java.lang.Object obj)
          Compares an object with this XPType.
 boolean Equals(java.lang.Object obj)
          Compares an object with this XPType.
 XPType GetBaseType()
          Returns the XPType representing the superclass of the entity (class, interface, primitive type or void) represented by this XPType.
 XPConstructor GetConstructor(XPType[] constructorArgs)
          Returns a XPConstructor object that reflects the specified public constructor of the class represented by this XPType object.
 XPField[] GetDeclaredFields()
          Gets all fields declared on this class (not superclasses).
 XPMethod GetDeclaredMethod(java.lang.String name, XPType[] methodArgs)
          Returns a XPMethod object that reflects the specified declared method of the class or interface represented by this XPType object.
 XPMethod[] GetDeclaredMethods()
          Returns an array of XPMethod objects reflecting all the methods declared by the class or interface represented by this XPType object.
 XPMethod GetMethod(java.lang.String name, XPType[] methodArgs)
          Return a reflective handle to a method by name.
 XPMethod[] GetMethods()
          Returns all methods available on this type.
 java.lang.String GetName()
          Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this XPType object, as a String.
static java.lang.String GetName(java.lang.Class jclass)
          Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this XPType object, as a String.
 XPField[] GetPublicFields()
          Gets all public fields available on this class (and superclasses).
 XPInputStream GetResourceAsStream(java.lang.String name)
          Finds a resource with a given name.
static XPType GetType(java.lang.String fullName)
          Returns the XPType object associated with the class or interface with the given string name.
 java.lang.Class GetUnderlyingObject()
          Gets the underlying Class of XPType.
 int hashCode()
          Returns the hash code value for this type.
 boolean IsAssignableFrom(XPType type)
          Determines if the class or interface represented by this XPType object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified XPType parameter.
 boolean IsPublic()
          Return true if the integer argument includes the public modifer, false otherwise.
 boolean IsVoidType()
          Indicates whether some other object is "equal to" this one.
 java.lang.String toString()
          Returns a string which may be useful in representing this object at runtime.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BOOLEAN

public static final XPType BOOLEAN
The XPType object representing the primitive type boolean.


INTEGER

public static final XPType INTEGER
The XPType object representing the primitive type int.


SHORT

public static final XPType SHORT
The XPType object representing the primitive type short.


LONG

public static final XPType LONG
The XPType object representing the primitive type long.


FLOAT

public static final XPType FLOAT
The XPType object representing the primitive type float.


DOUBLE

public static final XPType DOUBLE
The XPType object representing the primitive type double.


CHAR

public static final XPType CHAR
The XPType object representing the primitive type char.


BYTE

public static final XPType BYTE
The XPType object representing the primitive type byte.


VOID

public static final XPType VOID
The XPType object representing the primitive type void.

Constructor Detail

XPType

public XPType(java.lang.Class _class)
XPType Constructor and it takes Class Object.

Parameters:
_class - This class Object.
Method Detail

GetType

public static XPType GetType(java.lang.String fullName)
Returns the XPType object associated with the class or interface with the given string name.

Parameters:
fullName - the fully qualified name of the desired class.
Returns:
the XPType object for the class with the specified name.
Throws:
java.lang.LinkageError - if the linkage fails
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails
java.lang.ClassNotFoundException - if the class cannot be located

CreateInstance

public java.lang.Object CreateInstance()
Creates a new instance of the class represented by this XPType object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.

If there is a security manager, this method first calls the security manager's checkMemberAccess method with this and Member.PUBLIC as its arguments. If the class is in a package, then this method also calls the security manager's checkPackageAccess method with the package name as its argument. Either of these calls could result in a SecurityException.

Returns:
a newly allocated instance of the class represented by this object.
Throws:
java.lang.IllegalAccessException - if the class or its nullary constructor is not accessible.
java.lang.InstantiationException - if this XPType represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reason.
java.lang.ExceptionInInitializerError - if the initialization provoked by this method fails.
java.lang.SecurityException - if there is no permission to create a new instance.

GetName

public static java.lang.String GetName(java.lang.Class jclass)
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this XPType object, as a String.

If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java Language Specification, Second Edition.

If this class object represents a primitive type or void, then the name returned is a String equal to the Java language keyword corresponding to the primitive type or void.

If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more '[' characters representing the depth of the array nesting. The encoding of element type names is as follows:

Element XPType Encoding
boolean Z
byte B
char C
class or interface Lclassname;
double D
float F
int I
long J
short S

The class or interface name classname is the binary name of the class specified above.

Parameters:
jclass - classname
Returns:
the name of the class or interface represented by this object.

GetName

public java.lang.String GetName()
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this XPType object, as a String.

If this class object represents a reference type that is not an array type then the binary name of the class is returned, as specified by the Java Language Specification, Second Edition.

If this class object represents a primitive type or void, then the name returned is a String equal to the Java language keyword corresponding to the primitive type or void.

If this class object represents a class of arrays, then the internal form of the name consists of the name of the element type preceded by one or more '[' characters representing the depth of the array nesting. The encoding of element type names is as follows:

Element XPType Encoding
boolean Z
byte B
char C
class or interface Lclassname;
double D
float F
int I
long J
short S

The class or interface name classname is the binary name of the class specified above.

Returns:
the name of the class or interface represented by this object.

GetConstructor

public XPConstructor GetConstructor(XPType[] constructorArgs)
Returns a XPConstructor object that reflects the specified public constructor of the class represented by this XPType object.

Parameters:
constructorArgs - an array of XPType objects
Returns:
the XPConstructor object of the public constructor that matches the specified parameterTypes
Throws:
java.lang.NoSuchMethodException - if a matching method is not found.
java.lang.SecurityException - if access to the information is denied.

IsPublic

public boolean IsPublic()
Return true if the integer argument includes the public modifer, false otherwise.

Returns:
true if mod includes the public modifier; false otherwise.

GetBaseType

public XPType GetBaseType()
Returns the XPType representing the superclass of the entity (class, interface, primitive type or void) represented by this XPType. If this XPType represents either the Object class, an interface, a primitive type, or void, then null is returned. If this object represents an array class then the XPType object representing the Object class is returned.

Returns:
the superclass of the XPType represented by this object.

IsAssignableFrom

public boolean IsAssignableFrom(XPType type)
Determines if the class or interface represented by this XPType object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified XPType parameter. It returns true if so; otherwise it returns false. If this XPType object represents a primitive type, this method returns true if the specified XPType parameter is exactly this XPType object; otherwise it returns false.

Parameters:
type - the XPType object to be checked
Returns:
the boolean value indicating whether objects of the type type can be assigned to objects of this class

GetMethods

public XPMethod[] GetMethods()
Returns all methods available on this type. Includes all methods (all access levels) both instance and static, declared on this type and all super-types. Note: Does not include java.lang.Object methods

Returns:
All methods available on this type

GetMethod

public XPMethod GetMethod(java.lang.String name,
                          XPType[] methodArgs)
Return a reflective handle to a method by name. The method may be an instance or static method. If a method with a given name and argument list is not found in the current class, its superclasses are checked in turn until a matching method is found and returned, or none is found and XPNoSuchMethodException is thrown. Note that according to the behavior established by Java's Class.getMethod(), a superclass's static method may be returned if there is no match in the current class, as an exception to the usual lack of polymorphic binding for static methods.

Parameters:
name - Name of the method to return a reflective handle to.
methodArgs - array of XPType objects representing argument types; use XPType.INTEGER etc. for Java primitives.
Returns:
an instance of XPMethod corresponding to the method name and arguments supplied.
Throws:
XPNoSuchMethodException - if not found.

GetDeclaredMethods

public XPMethod[] GetDeclaredMethods()
Returns an array of XPMethod objects reflecting all the methods declared by the class or interface represented by this XPType object. This includes public, protected, default (package) access, and private methods, but excludes inherited methods. The elements in the array returned are not sorted and are not in any particular order. This method returns an array of length 0 if the class or interface declares no methods, or if this XPType object represents a primitive type, an array class, or void. The class initialization method <clinit> is not included in the returned array. If the class declares multiple public member methods with the same parameter types, they are all included in the returned array.

Returns:
the array of XPMethod objects representing all the declared methods of this class
Throws:
java.lang.SecurityException - if access to the information is denied.

GetDeclaredMethod

public XPMethod GetDeclaredMethod(java.lang.String name,
                                  XPType[] methodArgs)
Returns a XPMethod object that reflects the specified declared method of the class or interface represented by this XPType object. The name parameter is a String that specifies the simple name of the desired method, and the parameterTypes parameter is an array of XPMethod objects that identify the method's formal parameter types, in declared order. If more than one method with the same parameter types is declared in a class, and one of these methods has a return type that is more specific than any of the others, that method is returned; otherwise one of the methods is chosen arbitrarily. If the name is "<init>"or "<clinit>" a NoSuchMethodException is raised.

Parameters:
name - the name of the method
methodArgs - the parameter array
Returns:
the Method object for the method of this class matching the specified name and parameters
Throws:
java.lang.NoSuchMethodException - if a matching method is not found.
java.lang.NullPointerException - if name is null
java.lang.SecurityException - if access to the information is denied.

GetPublicFields

public XPField[] GetPublicFields()
Gets all public fields available on this class (and superclasses).

Returns:
an array of the public fields

GetDeclaredFields

public XPField[] GetDeclaredFields()
Gets all fields declared on this class (not superclasses).

Returns:
an array of the declared fields.

GetResourceAsStream

public XPInputStream GetResourceAsStream(java.lang.String name)
Finds a resource with a given name. This method returns null if no resource with this name is found. The rules for searching resources associated with a given class are implemented by the defining class loader of the class.

Parameters:
name - name of the desired resource
Returns:
a XPInputStream object or null.

IsVoidType

public boolean IsVoidType()
Indicates whether some other object is "equal to" this one.

Returns:
true if this object is the same as the obj argument; false otherwise.

GetUnderlyingObject

public java.lang.Class GetUnderlyingObject()
Gets the underlying Class of XPType.

Returns:
Returns the Class Object of XPType.

Equals

public boolean Equals(java.lang.Object obj)
Compares an object with this XPType.

Parameters:
obj - to test equals with
Returns:
true if the argument obj is equal to this type; false if this type does not have the same value as the obj argument.

equals

public boolean equals(java.lang.Object obj)
Compares an object with this XPType.

Parameters:
obj - to test equals with
Returns:
true if the argument obj is equal to this type; false if this type does not have the same value as the obj argument.

hashCode

public int hashCode()
Returns the hash code value for this type.

Returns:
int value of the hashcode for this XPType Object

toString

public java.lang.String toString()
Returns a string which may be useful in representing this object at runtime. Note: Calls through to GetName() - use GetName() directly if you want the name, do NOT rely on this method.

Returns:
A string describing this object


Copyright © 2002, 2003, 2004 Plumtree Software Inc. All Rights Reserved.