java.lang
Class Class

java.lang.Object
  extended byjava.lang.Class

public final class Class
extends Object


Constructor Summary
protected Class()
           
 
Method Summary
 boolean equals(Object other)
          Returns if this object is considered equal to the other object.
static Class forName(String className)
          This attempts to load a Class given the class name.
 ClassLoader getClassLoader()
          Under Ewe this will either return a valid ClassLoader or null if the class was loaded by the normal bootstrap (VM) loader.
 Class getComponentType()
          Return a Class representing the component type IF this class represents an array.
 Constructor getConstructor(Class[] parameterTypes)
           
 Constructor[] getConstructors()
           
 Class[] getDeclaredClasses()
          This returns an array of Classes representing all the named inner classes declared by this class.
 Constructor getDeclaredConstructor(Class[] parameterTypes)
           
 Constructor[] getDeclaredConstructors()
           
 Field getDeclaredField(String name)
           
 Field[] getDeclaredFields()
           
 Method getDeclaredMethod(String name, Class[] parameterTypes)
           
 Method[] getDeclaredMethods()
           
 Field getField(String name)
           
 Field[] getFields()
           
 Class[] getInterfaces()
          Returns an array of interface implemented by this class.
 Method getMethod(String name, Class[] parameterTypes)
           
 Method[] getMethods()
           
 int getModifiers()
           
 String getName()
          Return the name of the class in dot notation (e.g.
 Object[] getSigners()
          This currently always returns an array of zero length as signers are not currently supported.
 Class getSuperclass()
          Return the superclass of the represented class.
 int hashCode()
          Returns a hashCode for the object.
 boolean isArray()
          Returns true if the class represents an array.
 boolean isAssignableFrom(Class other)
          Returns true if the this class is a superclass or superinterface of the specified other class.
 boolean isInstance(Object obj)
          This is the equivalent of the instanceof operator.
 boolean isInterface()
          Returns true if this class represents an interface.
 boolean isPrimitive()
          Checks if this class represents a primitive type.
 Object newInstance()
           
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass
 

Constructor Detail

Class

protected Class()
Method Detail

getName

public String getName()
Return the name of the class in dot notation (e.g. "java.lang.Object")


toString

public String toString()
Description copied from class: Object
Return a String representation of this object.

Overrides:
toString in class Object
Returns:
a String representing this object.

getClassLoader

public ClassLoader getClassLoader()
Under Ewe this will either return a valid ClassLoader or null if the class was loaded by the normal bootstrap (VM) loader. Under other Java implementations it is allowed to return a value other than null for the bootstrap loader.


forName

public static Class forName(String className)
                     throws ClassNotFoundException
This attempts to load a Class given the class name. If the class is not accessable via the system loader it will throw a ClassNotFoundException.

To obtain a Class for an array using forName you must provide a name in the form: "[Java_Type" where Java_Type is one of:

'Z' - boolean
'B' - byte
'C' - char
'S' - short
'I' - int
'J' - long
'D' - double
'F' - float
"Lfull_class_name;" - class (e.g.: Ljava.lang.String)

When specifying an array of Objects using "[Lfull_class_name;" if the class full_class_name could not be found a ClassNotFoundException will be thrown.

To get a Class that represents a primitive type call forName() to get a Class representing the array of the primitive type, and then call getComponentType() on that returned class. For example:

Class intClass = Class.forName("[I").getComponentType();

Throws:
ClassNotFoundException

equals

public boolean equals(Object other)
Description copied from class: Object
Returns if this object is considered equal to the other object.

Overrides:
equals in class Object
Parameters:
other - Another object to compare to.
Returns:
true if this object is considered equal to the other object.

getSuperclass

public Class getSuperclass()
Return the superclass of the represented class. If the class represented is an interface or the Object class, this will return null.


getInterfaces

public Class[] getInterfaces()
Returns an array of interface implemented by this class. If this class represents an interface, it returns an array of interfaces extended by this interface. If the class implements or extends no interfaces, it will return an array of length zero.


isInterface

public boolean isInterface()
Returns true if this class represents an interface.


isAssignableFrom

public boolean isAssignableFrom(Class other)
Returns true if the this class is a superclass or superinterface of the specified other class.


isInstance

public boolean isInstance(Object obj)
This is the equivalent of the instanceof operator. Checks if the specified object is a derived class of this class, or implements the interface represented by this class.


isPrimitive

public boolean isPrimitive()
Checks if this class represents a primitive type.

Returns:
true if this Class represents a primitive type.

isArray

public boolean isArray()
Returns true if the class represents an array.


getComponentType

public Class getComponentType()
Return a Class representing the component type IF this class represents an array.


hashCode

public int hashCode()
Description copied from class: Object
Returns a hashCode for the object. The general contract of hashCode is:
  • An object must return the same hash code for its entire existence.
  • If two objects are considered equal by the equals() method, they should return the same hash code. Not all Objects will do this and you should only use hashCode() from Objects which declare an overrided version of hashCode(). The only Objects which provide consistent and correct hash codes under Ewe are Object, String and Class.

    Overrides:
    hashCode in class Object

  • getSigners

    public Object[] getSigners()
    This currently always returns an array of zero length as signers are not currently supported.


    getModifiers

    public int getModifiers()

    getDeclaredClasses

    public Class[] getDeclaredClasses()
    This returns an array of Classes representing all the named inner classes declared by this class. It returns an empty array if the Class declares no classes.


    newInstance

    public Object newInstance()
                       throws InstantiationException,
                              IllegalAccessException
    Throws:
    InstantiationException
    IllegalAccessException

    getField

    public Field getField(String name)
                   throws NoSuchFieldException,
                          SecurityException
    Throws:
    NoSuchFieldException
    SecurityException

    getDeclaredField

    public Field getDeclaredField(String name)
                           throws NoSuchFieldException,
                                  SecurityException
    Throws:
    NoSuchFieldException
    SecurityException

    getFields

    public Field[] getFields()
                      throws SecurityException
    Throws:
    SecurityException

    getDeclaredFields

    public Field[] getDeclaredFields()
                              throws SecurityException
    Throws:
    SecurityException

    getMethod

    public Method getMethod(String name,
                            Class[] parameterTypes)
                     throws NoSuchMethodException,
                            SecurityException
    Throws:
    NoSuchMethodException
    SecurityException

    getMethods

    public Method[] getMethods()
                        throws SecurityException
    Throws:
    SecurityException

    getDeclaredMethod

    public Method getDeclaredMethod(String name,
                                    Class[] parameterTypes)
                             throws NoSuchMethodException,
                                    SecurityException
    Throws:
    NoSuchMethodException
    SecurityException

    getDeclaredMethods

    public Method[] getDeclaredMethods()
                                throws SecurityException
    Throws:
    SecurityException

    getConstructor

    public Constructor getConstructor(Class[] parameterTypes)
                               throws NoSuchMethodException,
                                      SecurityException
    Throws:
    NoSuchMethodException
    SecurityException

    getConstructors

    public Constructor[] getConstructors()
                                  throws SecurityException
    Throws:
    SecurityException

    getDeclaredConstructor

    public Constructor getDeclaredConstructor(Class[] parameterTypes)
                                       throws NoSuchMethodException,
                                              SecurityException
    Throws:
    NoSuchMethodException
    SecurityException

    getDeclaredConstructors

    public Constructor[] getDeclaredConstructors()
                                          throws SecurityException
    Throws:
    SecurityException