com.borland.jbuilder.jot
Interface JotClass

All Known Subinterfaces:
JotAnonymousClass, JotClassSource, JotInnerClass
All Known Implementing Classes:
JotArrayClass, JotPrimitiveClass

public interface JotClass

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).

See Also:
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

getFile

public JotFile getFile()

isInstance

public boolean isInstance(java.lang.Object obj)
This method is the dynamic equivalent of the Java language 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.

Parameters:
obj - The object to check

isAssignableFrom

public 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.

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.

Parameters:
cls - the class or interface represented by the JotClass object to be tested

Returns:
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.

Throws:
java.lang.NullPointerException - If the specified JotClass parameter is null.

isInterface

public boolean isInterface()
Determines if this JotClass object represents an interface type

Returns:
true if it represents an interface.

isPrimitive

public boolean isPrimitive()
Determines if this JotClass object represents a primitive Java type.

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.

Returns:
true if this JotClass object represents a primitive type.

See Also:
JotPrimitiveClass.booleanType, JotPrimitiveClass.charType, JotPrimitiveClass.byteType, JotPrimitiveClass.shortType, JotPrimitiveClass.intType, JotPrimitiveClass.longType, JotPrimitiveClass.floatType, JotPrimitiveClass.doubleType, JotPrimitiveClass.voidType

isArray

public boolean isArray()
Determines if this JotClass object represents an array type.

Returns:
true if this JotClass object represents an array type.

getComponentType

public JotClass getComponentType()
If this Jotclass represents an array type, returns the JotClass object representing the component type of the array; otherwise returns null.

See Also:
java.lang.reflect.Array

getName

public 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.

getType

public JotType getType()
Returns a JotType object that refers to this class

getModifiers

public int getModifiers()
Returns the Java language modifiers for this class or interface, encoded in an integer. The valid modifiers for classes consist of the Java Virtual Machine's constants for public, protected, private, final, and interface. They should be decoded using the methods of class Modifier.

The modifier encodings are defined in The Java Virtual Machine Specification, table 4.1.

See Also:
Modifier

getSuperclass

public JotType getSuperclass()
If this JotClass object represents a class other than Object, returns the JotClass that represents the superclass of the class. Returns null if this JotClass represents the class Object, or if it represents an interface or a primitive type.

getInterfaces

public JotType[] getInterfaces()
Returns an array of classIds representing the interfaces of the class or interface represented by this JotClass object. If this JotClass object represents a class, returns an array containing objects representing the interfaces directly implemented by this class. If this JotClass object represents an interface, returns an array containing the direct superinterfaces of this interface.

Returns:
an array of classIDs representing the interfaces of the class or interface represented by this JotClass object. If this JotClass object represents a class that implements no interfaces or if it represents a primitive type this method will return an array of length 0.

getDeclaredFields

public JotField[] getDeclaredFields()
Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this JotClass object. This includes public, protected, default (package) access, and private fields, but excludes inherited fields. Returns an array of length 0 if the class or interface declares no fields, or if this JotClass object represents a primitive type.

See The Java Language Specification, sections 8.2 and 8.3 for more information..

Throws:
java.lang.SecurutyException - If access to this information is denied.

See Also:
Field

getDeclaredField

public 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. The name parameter is a String that specifies the simple name of the desired field.

Throws:
java.lang.NoSuchFieldException - If a field with the specified name is not found.
java.lang.SecurityException - If access to this information is denied.

See Also:
Field

getFields

public JotField[] getFields()
Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this JotClass object. Returns an array of length 0 if the class or interface has no accessible public fields, or if it represents an array type or a primitive type.

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.

Throws:
java.lang.SecurityException - If access to this information is denied.

See Also:
Field

getField

public 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. The name parameter is a String specifying the simple name of the desired field.

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.

Throws:
java.lang.NoSuchFieldException - If a matching field is not found.
java.lang.SecurityException - If access to the underlying field is denied.

See Also:
Field

getDeclaredMethods

public JotMethod[] getDeclaredMethods()
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this JotClass object. 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.

See The Java Language Specification, section 8.2 for more information.

Throws:
java.lang.SecurityException - If access to this information is denied.

See Also:
Method

getDeclaredMethods

public 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. 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.

Parameters:
name - is the name of the method sought

Throws:
java.lang.SecurityException - If access to this information is denied.

See Also:
Method

getDeclaredMethod

public 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.

Parameters:
name - is a String that specifies the simple name of the desired method
parameterTypes - is an array of JotClass objects that identify the method's formal parameter types, in declared order.

Throws:
java.lang.NoSuchMethodException - If a matching method is not found.
java.lang.SecurityException - If access to the underlying method is denied.

See Also:
Method

getMethods

public 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. Returns an array of length 0 if the class or interface has no public member methods.

See The Java Language Specification, sections 8.2 and 8.4 for more information.

Throws:
java.lang.SecurityException - if access to this information is denied.

See Also:
Method

getMethods

public 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. 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.

Parameters:
methodName - A string representation of the name of the method sought.

Throws:
java.lang.SecurityException - if access to this information is denied.

See Also:
Method

getMethod

public 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. The name parameter is a String specifying the simple name the desired method, and the parameterTypes parameter is an array of JotClass objects that identify the method's formal parameter types, in declared order.

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.

Throws:
java.lang.NoSuchMethodException - If a matching method is not found.
java.lang.SecurityException - If access to the underlying method is denied.

See Also:
Method

getDeclaredConstructors

public JotConstructor[] getDeclaredConstructors()
Returns an array of Constructor objects reflecting all the constructors declared by the class represented by this JotClass object. These are public, protected, default (package) access, and private constructors. Returns an array of length 0 if this JotClass object represents an interface or a primitive type.

See The Java Language Specification, section 8.2, for more information.

Throws:
java.lang.SecurityException - If access to this information is denied.

See Also:
Constructor

getDeclaredConstructor

public JotConstructor getDeclaredConstructor(JotClass[] parameterTypes)
Returns a Constructor object that reflects the specified public constructor of the class represented by this JotClass object. The parameterTypes parameter is an array of JotClass objects that identify the constructor's formal parameter types, in declared order.

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.

Throws:
java.lang.NoSuchMethodException - If a matching constructor is not found.
java.lang.SecurityException - If access to the underlying constructor is denied.

See Also:
Constructor

getConstructors

public JotConstructor[] getConstructors()
Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this JotClass object. An array of length 0 is returned if the class has no public constructors.

Throws:
java.lang.SecurityException - If access to this information is denied.

See Also:
Constructor

getConstructor

public JotConstructor getConstructor(JotClass[] parameterTypes)
Returns a Constructor object that reflects the specified declared constructor of the class or interface represented by this JotClass object. The parameterTypes parameter is an array of JotClass objects that identify the constructor's formal parameter types, in declared order.

Throws:
java.lang.NoSuchMethodException - If a matching constructor is not found.
java.lang.SecurityException - If access to the underlying constructor is denied.

See Also:
Constructor

getDeclaredInnerClasses

public JotClass[] getDeclaredInnerClasses()
Returns an array of JotClass objects reflecting the collection of all inner classes of this class.

getInnerClasses

public 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.

newInstance

public java.lang.Object newInstance()
                             throws java.lang.InstantiationException,
                                    java.lang.IllegalAccessException
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). If successful, returns the newly created and initialized instance.

Returns:
The new instance of this class.

Throws:
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.

addUserData

public void addUserData(java.lang.Object key,
                        java.lang.Object data)
Allows client supplied data to be associated with this JotClass. The data may be removed by adding the same key and specifying null as the data. >p>
Parameters:
key - an Object which will can be used to identify the data
data - 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.

See Also:
getUserData

getUserData

public java.lang.Object getUserData(java.lang.Object key)
Retrieves client data associated with this JotClass.
Parameters:
key - is the Object which identifies the client data to extract.
Returns:
the Object which is associated with the key or null if no matching data is found.