org.apache.xml.utils.synthetic
Class Class

java.lang.Object
  extended byorg.apache.xml.utils.synthetic.Class
All Implemented Interfaces:
Serializable

public class Class
extends Object
implements Serializable

org.apache.xml.utils.synthetic.Class is a mutable equivalent of java.lang.Class. Instances represent classes and interfaces in a running Java application, or class descriptions under construction. In the former case, org.apache.xml.utils.synthetic.Class operates as a proxy for the "real" java.lang.Class object; in the latter, it consults data structures defined in the org.apache.xml.utils.synthetic.reflection.* package.

Unlike java.lang.Class, org.apache.xml.utils.synthetic.Class has a pair of factories (fromName and fromClass). It can also be switched from synthetic to proxy operation after construction, by setting the realClass property; this is intended to allow these definitions to be "compiled in place".

For convenient use, org.apache.xml.utils.synthetic.Class implements an extended version of the java.lang.Class API -- but is not a subclass thereof, since java.lang.Class is Final (presumably for security reasons).

DEVELOPMENT NOTE: Methods not yet implemented will throw IllegalStateException

I've added code to convert primitive names into their TYPEs, to accept foo[] as a synonym for [Lfoo, and to generate the right thing on output (getJava[Short]Name). Useful extension for code generation from Java-like source. We may want to factor these and toSource out, making org.apache.xml.utils.synthetic.Class addess only the JVM level and providing subclasses or access tools that handle language syntax (Java source, NetRexx source, etc.)

Since:
2000/2/10
See Also:
Serialized Form

Field Summary
private  Class[] allclasses
          Field allclasses: an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object.
private  Constructor[] allconstructors
          Field allconstructors: an array containing Constructor objects reflecting all the constructors of the class represented by this Class object.
private  Field[] allfields
          Field allfields.
private  Method[] allmethods
          Field allmethods.
private  Class[] declaredclasses
          Field declaredclasses: an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object.
private  Constructor[] declaredconstructors
          Field declaredconstructors: an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object.
private  Field[] declaredfields
          Field declaredfields.
private  Method[] declaredmethods
          Field declaredmethods.
private  Class declaringclass
          Field declaringclass: If this object represents an inner class, the Class object that represents the class that declared it.
private static Hashtable global_classtable
          Class descriptions currently existing.
private  Class[] innerclasses
          Field innerclasses.
private  Class[] interfaces
          Field interfaces: A list of all interfaces implemented by the class or interface represented by this object.
private  boolean isInterface
          Field isInterface: True if the Class object represents an interface type.
(package private) static String[] kwd
          Field kwd
private  int modifiers
          Field modifiers: Java language modifiers for this class or interface, encoded in an integer.
private  String name
          fully-qualified path.classname.
private  Class realclass
          Actual Java class object.
private  Class superclass
          Field superclass: If this object represents the class Object, this is null.
(package private) static int[] val
          Field val
 
Constructor Summary
(package private) Class(Class realclass)
          Construct a synthetic class as proxy/wrapper for an existing Java Class.
(package private) Class(String fullname)
          Construct a named-but-empty synthetic Class object.
 
Method Summary
 void addExtends(Class newclass)
          Adds an "extends" description for the class or interface represented by this Class object
 void addImplements(Class newclass)
          Adds an "implements" description for the class or interface represented by this Class object
private  void addInnerClass(Class newclass)
          Declare that this class is an inner class of another.
static Class declareClass(String className)
          Start to create a synthetic Class with the given fully-qualified name.
 Constructor declareConstructor()
          Adds a Constructor description for the class or interface represented by this Class object
 Field declareField(String name)
          Adds a Field description for the class or interface represented by this Class object
 Class declareInnerClass(String className)
          Declare a class contained within this class.
 Class declareInterface(Class newifce)
          State that this class implements a specified interface.
 Method declareMethod(String name)
          Adds a Method description for the class or interface represented by this Class object
static Class forClass(Class cls)
          Returns the synthetic Class object associated with the "real" class specified, creating one if it didn't already exist.
static Class forName(String className)
          Returns the synthetic Class object associated with the class with the given fully-qualified name.
 Class forNameInContext(String classname)
          Like forName, but if the classname doesn't have a package prefix we first attempt to look it up as one of our own inner clases.
 Class[] getClasses()
          Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object.
 ClassLoader getClassLoader()
          Determines the class loader for the class.
 Class getComponentType()
          If this class represents an array type, returns the Class object representing the component type of the array; otherwise returns null.
 Constructor getConstructor(Class[] parameterTypes)
          Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object.
 Constructor[] getConstructors()
          Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.
 Class[] getDeclaredClasses()
          This method is not implemented in VAJAVA 3.0 Returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object.
 Constructor getDeclaredConstructor(Class[] parameterTypes)
          Returns a Constructor object that reflects the specified declared constructor of the class or interface represented by this Class object.
 Constructor[] getDeclaredConstructors()
          Returns an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object.
 Field getDeclaredField(String name)
          Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object.
 Field[] getDeclaredFields()
          Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object.
 Method getDeclaredMethod(String name, Class[] parameterTypes)
          Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object.
 Method[] getDeclaredMethods()
          Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object.
 Class getDeclaringClass()
          This method is not implemented in VAJava 3.0 If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class of which it is a member (its declaring class).
 Field getField(String name)
          Returns a Field object that reflects the specified public member field of the class or interface represented by this Class object.
 Field[] getFields()
          Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class object.
 Class[] getInnerClasses()
          Fetch a list of classes contained within this class.
 Class[] getInterfaces()
          Determines the interfaces implemented by the class or interface represented by this object.
 String getJavaName()
          Like getName, but back-convert array notation escapes. ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!
 String getJavaShortName()
          Like getShortName, but back-convert array notation escapes. ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!
 Method getMethod(String name, Class[] parameterTypes)
          Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object.
 Method[] getMethods()
          Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class object, 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.
 String getName()
          Retrieve the fully-qualified classname.
 String getPackageName()
          Extract the package name for this class. ***** I don't think this handles array classes properly yet.
 Class getRealClass()
          If this synthetic class is a wrapper for a "real" java.lang.Class -- either because it was instantiated as such or because it has been compiled -- this method will return that class.
 URL getResource(String name)
          Finds a resource with the specified name.
 InputStream getResourceAsStream(String name)
          Finds a resource with a given name.
 String getShortName()
          Extract just the local name of this class, minus the package prefix. ***** I don't think this handles array types properly yet.
 Object[] getSigners()
          Get the signers of this class.
 Class getSuperclass()
          If this object represents any class other than the class Object, then the object that represents the superclass of that class is returned.
 boolean isArray()
          If this Class object represents an array type, returns true, otherwise returns false.
 boolean isAssignableFrom(Class cls)
          Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.
 boolean isAssignableFrom(Class cls)
          Determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter.
 boolean isInstance(Object obj)
          This method is the dynamic equivalent of the Java language instanceof operator.
 boolean isInterface()
          Determines if the specified Class object represents an interface type.
 void isInterface(boolean isInterface)
          Assert that the specified Class object represents an interface type.
 boolean isPrimitive()
          Determines if the specified Class object represents a primitive Java type.
static int modifierFromString(String t)
          Method modifierFromString
static int modifiersFromString(String s)
          Method modifiersFromString
 Object newInstance()
          Creates a new instance of a class.
static Class reallyDeclareClass(String className)
          Start to create a synthetic Class with the given fully-qualified name.
 void setModifiers(int modifiers)
          Set the Java language modifiers for this class or interface, encoded in an integer.
 void setRealClass(Class realclass)
          This call is intended to allow an existing org.apache.xml.utils.synthetic.Class to be switched from purely descriptive mode to proxy mode ("reified").
 void setSuperClass(Class superclass)
          Set the superclass for this synthetic class.
 void setSuperClass(Class superclass)
          Set the superclass for this synthetic class.
private  String tabset(int depth)
          Method tabset
 void toSource(OutputStream out, int depth)
          Convenience for writing to, eg, System.out
 void toSource(PrintWriter out, int depth)
          Converts the object to a Java code stream.
 String toString()
          Converts the object to a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

global_classtable

private static Hashtable global_classtable
Class descriptions currently existing.


name

private String name
fully-qualified path.classname.


realclass

private Class realclass
Actual Java class object. When present, all interactions are redirected to it. Allows our Class to function as a wrapper for the Java version (in lieu of subclassing or a shared Interface), and allows "in-place compilation" to replace a generated description with an directly runnable class.


modifiers

private int modifiers
Field modifiers: Java language modifiers for this class or interface, encoded in an integer.


isInterface

private boolean isInterface
Field isInterface: True if the Class object represents an interface type.


superclass

private Class superclass
Field superclass: If this object represents the class Object, this is null. Otherwise, the Class object that represents the superclass of that class. In proxy mode this is determined when needed. In synthesis mode it's explicitly set by the user, and if null the superclass will be assumed to be Object.


declaringclass

private Class declaringclass
Field declaringclass: If this object represents an inner class, the Class object that represents the class that declared it. Otherwise null.


interfaces

private Class[] interfaces
Field interfaces: A list of all interfaces implemented by the class or interface represented by this object.


allclasses

private Class[] allclasses
Field allclasses: an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object.


declaredclasses

private Class[] declaredclasses
Field declaredclasses: an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object. Excludes inherited classes and interfaces.


allconstructors

private Constructor[] allconstructors
Field allconstructors: an array containing Constructor objects reflecting all the constructors of the class represented by this Class object. An array of length 0 is returned if the class has no public constructors. In proxy mode only public constructors will be displayed; in synthesis mode, all declared constructors will be displayed.


declaredconstructors

private Constructor[] declaredconstructors
Field declaredconstructors: an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object. Includes non-public constructors, but excludes inherited ones.


allmethods

private Method[] allmethods
Field allmethods.


declaredmethods

private Method[] declaredmethods
Field declaredmethods.


allfields

private Field[] allfields
Field allfields.


declaredfields

private Field[] declaredfields
Field declaredfields.


innerclasses

private Class[] innerclasses
Field innerclasses.


val

static final int[] val
Field val


kwd

static final String[] kwd
Field kwd

Constructor Detail

Class

Class(Class realclass)
Construct a synthetic class as proxy/wrapper for an existing Java Class. Non-public; most folks should use .forName and .forClass to request these wrappers, so they get the shared instances.

Creation date: (12-25-99 12:16:15 PM)

Parameters:
realclass - java.lang.Class

Class

Class(String fullname)
Construct a named-but-empty synthetic Class object. Non-public; most folks should use .forName and .forClass to request these wrappers, so they get the shared instances.

Creation date: (12-25-99 12:15:23 PM)

Parameters:
fullname - full name of the class that is synthetized.
Method Detail

forClass

public static Class forClass(Class cls)
Returns the synthetic Class object associated with the "real" class specified, creating one if it didn't already exist.

For example, the following code fragment returns the runtime Class descriptor for the class named mypackage.MyClass. Class t = Class.forName(java.lang.Class.forName("mypackage.MyClass"))

Note that if the user has manually created a org.apache.xml.utils.synthetic.Class with the same name before this call is issued, that object will be found instead. See also the declareClass call.

We need a better way to declare/define array classes, given a class object (synthetic or not).

Parameters:
cls - the desired Java class.
Returns:
the synthetic Class descriptor for the specified class.

forNameInContext

public Class forNameInContext(String classname)
                       throws ClassNotFoundException
Like forName, but if the classname doesn't have a package prefix we first attempt to look it up as one of our own inner clases. As with forName, if this can not be resolved we throw an exception.

Parameters:
classname - the full or partial class name.
Returns:
The Class name that matches the argument.
Throws:
ClassNotFoundException

forName

public static Class forName(String className)
                     throws ClassNotFoundException
Returns the synthetic Class object associated with the class with the given fully-qualified name. If there isn't one, this method attempts to locate, load and link the standard java Class. If it succeeds, it returns a wrapped version of the Class object representing the class. If it fails, the method throws a ClassNotFoundException.

For example, the following code fragment returns the runtime Class descriptor for the class named mypackage.MyClass -- either as a synthetic or as a standard Java class. Class t = Class.forName("mypackage.MyClass")

I've added support for arrays -- assuming any name that ends with ']' is an array. It probably needs to be made smarter, possibly via a subclass of org.apache.xml.utils.synthetic.Class.

Parameters:
className - the fully qualified name of the desired class.
Returns:
the synthetic Class descriptor for the class with the specified name.
Throws:
ClassNotFoundException - if the class could not be found.

declareClass

public static Class declareClass(String className)
                          throws SynthesisException
Start to create a synthetic Class with the given fully-qualified name. If a Class by that name already exists, and it is not reified, it will be returned instead. If a reified Class _does_ exist, we throw a synthesis exception.

Parameters:
className - the fully qualified name of the desired class.
Returns:
the synthetic Class descriptor for the class with the specified name.
Throws:
SynthesisException - if the class has been reified.

reallyDeclareClass

public static Class reallyDeclareClass(String className)
Start to create a synthetic Class with the given fully-qualified name. If a Class by that name already exists,whether reified or not, it will be removed from the table and replaced by the new synthesis. NOTE THAT the replacement will not affect classes which have already refernced the old version. We could change that by having everyone reference everyone else via an indirection table.

Parameters:
className - the fully qualified name of the desired class.
Returns:
the synthetic Class descriptor for the class with the specified name.

getClasses

public Class[] getClasses()
Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. Returns an array of length 0 if the class has no public member classes or interfaces, or if this Class object represents a primitive type.

NOTE: In a significant number of existing Java environments, this method is not implemented by the official Class object and always returns an empty array. So if you don't get any useful information from a proxied java.lang.Class, don't be surprised. I'm not sure if someone decided it was a potential security issue, or if Sun was lazy and everyone else followed suit.

ALSO NOTE: The above spec, as taken from java.lang.Class, doesn't provide any good way to distinguish the immediate superclass from all other superclasses. That makes it only marginally useful, which is no doubt one of the reasons folks have declined to implement it.

Returns:
an array of classes.

getClassLoader

public ClassLoader getClassLoader()
Determines the class loader for the class. the class loader that created the class or interface represented by this object, or null if the org.apache.xml.utils.synthetic.Class was not created by a class loader.


getComponentType

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

NOTE: Since org.apache.xml.utils.synthetic.Class doesn't yet attempt to model array types, this will currently return false unless we are proxying such a type.

Returns:
the Class object representing the component type of the array, otherwise returns null.

getConstructor

public Constructor getConstructor(Class[] parameterTypes)
                           throws NoSuchMethodException,
                                  SecurityException,
                                  SynthesisException
Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object. The parameterTypes parameter is an array of Class 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 Class object for a public constructor with the exactly the same formal parameter types.

Parameters:
parameterTypes - array of Class objects that identify the constructor's formal parameter types, in declared order.
Returns:
a Constructor object that reflects the specified public constructor of the class represented by this Class object.
Throws:
NoSuchMethodException - if a matching method is not found.
SecurityException - if access to the information is denied.
SynthesisException

getConstructors

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

Returns:
an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.
Throws:
SecurityException - if access to the information is denied.

getDeclaredClasses

public Class[] getDeclaredClasses()
                           throws SecurityException
This method is not implemented in VAJAVA 3.0

Returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object. This includes public, protected, default (package) access, and private classes and interfaces declared by the class, but excludes inherited classes and interfaces. Returns an array of length 0 if the class declares no classes or interfaces as members, or if this Class object represents a primitive type.

Returns:
an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object.
Throws:
SecurityException - if access to the information is denied.

addExtends

public void addExtends(Class newclass)
                throws SynthesisException
Adds an "extends" description for the class or interface represented by this Class object

Parameters:
newclass - The class that this class extends.
Throws:
SynthesisException - if the class has been reified.

getDeclaredConstructor

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

Parameters:
parameterTypes - array of Class objects that identify the constructor's formal parameter types, in declared order.
Returns:
a Constructor object that reflects the specified declared constructor of the class or interface represented by this Class object.
Throws:
NoSuchMethodException - if a matching method is not found.
SecurityException - if access to the information is denied.

declareConstructor

public Constructor declareConstructor()
                               throws SynthesisException
Adds a Constructor description for the class or interface represented by this Class object

Returns:
The constructor object.
Throws:
SynthesisException - if the class has been reified.

declareInterface

public Class declareInterface(Class newifce)
                       throws SynthesisException
State that this class implements a specified interface. This does not yet update allMethods or otherwise attempt to inherit data.

Parameters:
newifce - org.apache.xml.utils.synthetic.Class representing the interface we want to add.
Returns:
The new interface class.
Throws:
SynthesisException - if the Class isn't an interface

getDeclaredConstructors

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

See The Java Language Specification, section 8.2.

Returns:
an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object.
Throws:
SecurityException - if access to the information is denied.

getDeclaredField

public Field getDeclaredField(String name)
                       throws NoSuchFieldException,
                              SecurityException
Returns a Field object that reflects the specified declared field of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired field.

Parameters:
name - String that specifies the simple name of the desired field.
Returns:
a Field object that reflects the specified declared field of the class or interface represented by this Class object.
Throws:
NoSuchFieldException - if a field with the specified name is not found.
SecurityException - if access to the information is denied.

declareField

public Field declareField(String name)
                   throws SynthesisException
Adds a Field description for the class or interface represented by this Class object

Parameters:
name - The name of the field.
Returns:
The field description.
Throws:
SynthesisException - if the class has been reified.

getDeclaredFields

public Field[] getDeclaredFields()
                          throws SecurityException
Returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class 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 Class object represents a primitive type. See The Java Language Specification, sections 8.2 and 8.3.

Returns:
array of Field objects reflecting all the fields declared by the class or interface represented by this Class object.
Throws:
SecurityException - if access to the information is denied.

getDeclaredMethod

public Method getDeclaredMethod(String name,
                                Class[] parameterTypes)
                         throws NoSuchMethodException,
                                SecurityException
Returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. The name parameter is a String that specifies the simple name of the desired method, and the parameterTypes parameter is an array of Class objects that identify the method's formal parameter types, in declared order.

Parameters:
name - String that specifies the simple name of the desired method.
parameterTypes - array of Class objects that identify the method's formal parameter types, in declared order.
Returns:
Method object that reflects the specified declared method of the class or interface represented by this Class object.
Throws:
NoSuchMethodException - if a matching method is not found.
SecurityException - if access to the information is denied.

declareMethod

public Method declareMethod(String name)
                     throws SynthesisException
Adds a Method description for the class or interface represented by this Class object

Parameters:
name - Name of method.
Returns:
The method object.
Throws:
SynthesisException - if the class has been reified.

getDeclaredMethods

public Method[] getDeclaredMethods()
                            throws SecurityException
Returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class 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 Class object represents a primitive type.

See The Java Language Specification, section 8.2.

Returns:
array of Method objects reflecting all the methods declared by the class or interface represented by this Class object.
Throws:
SecurityException - if access to the information is denied.

getDeclaringClass

public Class getDeclaringClass()
This method is not implemented in VAJava 3.0

If the class or interface represented by this Class object is a member of another class, returns the Class object representing the class of which it is a member (its declaring class). Returns null if this class or interface is not a member of any other class.


addInnerClass

private void addInnerClass(Class newclass)
                    throws SynthesisException
Declare that this class is an inner class of another.

Parameters:
newclass -
Throws:
SynthesisException

declareInnerClass

public Class declareInnerClass(String className)
                        throws SynthesisException
Declare a class contained within this class. This doesn't address anonymous classes (those go inside method bodies and similar code), just local classes.

***** This requires lookup methods that operate in the context of a specific class, and per-class registries!

Parameters:
className - Local name of inner class to create. This should _not_ be a qualified name, unlike the normal forName() call. Its hierarchy is established by the class within which it is created.
Returns:
org.apache.xml.utils.synthetic.Class object for the contained class.
Throws:
SynthesisException - if class could not be created.
SynthesisException
Since:
2/2000

getInnerClasses

public Class[] getInnerClasses()
Fetch a list of classes contained within this class. This doesn't address anonymous classes (those go inside method bodies and similar code), just local classes.

Returns:
org.apache.xml.utils.synthetic.Class[] object for the contained classes. This may be empty if none such exist, or if the class is reified (since reflection doesn't report this information).
Since:
3/2000

getField

public Field getField(String name)
               throws NoSuchFieldException,
                      SecurityException
Returns a Field object that reflects the specified public member field of the class or interface represented by this Class 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 Class object for a public field with the specified name.

See The Java Language Specification, sections 8.2 and 8.3.

Parameters:
name -
Throws:
NoSuchFieldException - if a field with the specified name is not found.
SecurityException - if access to the information is denied.

getFields

public Field[] getFields()
                  throws SecurityException
Returns an array containing Field objects reflecting all the accessible public fields of the class or interface represented by this Class 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 Class object represents a class, returns the public fields of this class and of all its superclasses. If this Class object represents an interface, returns the fields of this interface and of all its superinterfaces. If this Class 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.

Throws:
SecurityException - if access to the information is denied.

getInterfaces

public Class[] getInterfaces()
Determines the interfaces implemented by the class or interface represented by this object.

If this object represents a class, the return value is an array containing objects representing all interfaces implemented by the class. The order of the interface objects in the array corresponds to the order of the interface names in the implements clause of the declaration of the class represented by this object.

If this object represents an interface, the array contains objects representing all interfaces extended by the interface. The order of the interface objects in the array corresponds to the order of the interface names in the extends clause of the declaration of the interface represented by this object.

If the class or interface implements no interfaces, the method returns an array of length 0. an array of interfaces implemented by this class.


addImplements

public void addImplements(Class newclass)
                   throws SynthesisException
Adds an "implements" description for the class or interface represented by this Class object

Parameters:
newclass -
Throws:
SynthesisException - if the class has been reified.

getMethod

public Method getMethod(String name,
                        Class[] parameterTypes)
                 throws NoSuchMethodException,
                        SecurityException
Returns a Method object that reflects the specified public member method of the class or interface represented by this Class object. The name parameter is a String specifying the simple name the desired method, and the parameterTypes parameter is an array of Class 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 Class 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.

Parameters:
name -
parameterTypes -
Throws:
NoSuchMethodException - if a matching method is not found.
SecurityException - if access to the information is denied.

getMethods

public Method[] getMethods()
                    throws SecurityException
Returns an array containing Method objects reflecting all the public member methods of the class or interface represented by this Class 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.

Throws:
SecurityException - if access to the information is denied.

getModifiers

public int getModifiers()
Returns the Java language modifiers for this class or interface, encoded in an integer. The modifiers 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: java.lang.reflect.Modifier


setModifiers

public void setModifiers(int modifiers)
                  throws SynthesisException
Set the Java language modifiers for this class or interface, encoded in an integer. The modifiers 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: java.lang.reflect.Modifier

Parameters:
modifiers -
Throws:
SynthesisException

getName

public String getName()
Retrieve the fully-qualified classname. If it's an array, it will be returned in JVM syntax, not Java syntax.

Returns:
java.lang.String
Since:
12/95

getJavaName

public String getJavaName()
Like getName, but back-convert array notation escapes. ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!

Returns:
java.lang.String
Since:
3/2000

getShortName

public String getShortName()
Extract just the local name of this class, minus the package prefix. ***** I don't think this handles array types properly yet.

Returns:
java.lang.String
Since:
12/99

getJavaShortName

public String getJavaShortName()
Like getShortName, but back-convert array notation escapes. ***** DOESN'T YET HANDLE ARRAYS OF PRIMITIVES!

Returns:
java.lang.String
Since:
3/2000

getPackageName

public String getPackageName()
Extract the package name for this class. ***** I don't think this handles array classes properly yet.

Returns:
java.lang.String
Since:
12/95

getRealClass

public Class getRealClass()
If this synthetic class is a wrapper for a "real" java.lang.Class -- either because it was instantiated as such or because it has been compiled -- this method will return that class. Otherwise it returns null. Creation date: (12-25-99 12:26:01 PM)

Returns:
org.apache.xml.utils.synthetic.Class

setRealClass

public void setRealClass(Class realclass)
                  throws SynthesisException
This call is intended to allow an existing org.apache.xml.utils.synthetic.Class to be switched from purely descriptive mode to proxy mode ("reified"). The primary intent is to allow a org.apache.xml.utils.synthetic.Class to be "compiled in place"

This should have the side-effect of limiting further mutation of the org.apache.xml.utils.synthetic.Class to things which can not be obtained from the real Class object, to avoid "lying" to the user

NOTE: Not all information defined by the Java libraries is in fact available in all Java environments. We assume the calls will work; if they return null or empty lists, there's nothing we can do about it. Note that this may mean that a reified class tells us less about itself than the synthetic description used to generate it.

Creation date: (12-25-99 12:26:01 PM)

Parameters:
realclass -
Throws:
SynthesisException

setSuperClass

public void setSuperClass(Class superclass)
                   throws SynthesisException
Set the superclass for this synthetic class. Object is equivalent to Null. Creation date: (12-25-99 12:26:01 PM)

Parameters:
superclass -
Returns:
org.apache.xml.utils.synthetic.Class
Throws:
SynthesisException

setSuperClass

public void setSuperClass(Class superclass)
                   throws ClassNotFoundException,
                          SynthesisException
Set the superclass for this synthetic class. Creation date: (12-25-99 12:26:01 PM)

Parameters:
superclass -
Returns:
org.apache.xml.utils.synthetic.Class
Throws:
ClassNotFoundException
SynthesisException

getResource

public URL getResource(String name)
Finds a resource with the specified name. The rules for searching for resources associated with a given class are implemented by the class loader of the class.

The Class methods delegate to ClassLoader methods, after applying a naming convention: if the resource name starts with "/", it is used as is. Otherwise, the name of the package is prepended, after converting "." to "/".

Parameters:
name - - the string representing the resource to be found. the URL object having the specified name, or null if no resource with the specified name is found.

getResourceAsStream

public InputStream getResourceAsStream(String name)
Finds a resource with a given name. Will return null if no resource with this name is found. The rules for searching a resources associated with a given class are implemented by the ClassLoader of the class.

The Class methods delegate to ClassLoader methods, after applying a naming convention: if the resource name starts with "/", it is used as is. Otherwise, the name of the package is prepended, after converting "." to "/".

Parameters:
name - - the string representing the resource to be found the InputStream object having the specified name, or null if no resource with the specified name is found.

getSigners

public Object[] getSigners()
Get the signers of this class.


getSuperclass

public Class getSuperclass()
If this object represents any class other than the class Object, then the object that represents the superclass of that class is returned.

If this object is the one that represents the class Object or this object represents an interface, null is returned. the superclass of the class represented by this object.


isArray

public boolean isArray()
If this Class object represents an array type, returns true, otherwise returns false.


isAssignableFrom

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

Specifically, this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class 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 details.

Parameters:
cls -
Throws:
NullPointerException - if the specified Class parameter is null.

isAssignableFrom

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

Specifically, this method tests whether the type represented by the specified Class parameter can be converted to the type represented by this Class 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 details.

Parameters:
cls -
Throws:
NullPointerException - if the specified Class parameter is null.

isInstance

public boolean isInstance(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 Class object without raising a ClassCastException. It returns false otherwise.

Specifically, if this Class 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 Class 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 Class object represents an interface, returns true if the class or any superclass of the specified Object argument implements this interface; false otherwise. If this Class object represents a primitive type, returns false.

Parameters:
obj - The object to check

isInterface

public boolean isInterface()
Determines if the specified Class object represents an interface type. true if this object represents an interface; false otherwise.


isInterface

public void isInterface(boolean isInterface)
                 throws SynthesisException
Assert that the specified Class object represents an interface type. Can't be changed after real class loaded.

Parameters:
isInterface -
Throws:
SynthesisException

isPrimitive

public boolean isPrimitive()
Determines if the specified Class object represents a primitive Java type.

There are nine predefined Class 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 Class objects for which this method returns true.


newInstance

public Object newInstance()
                   throws InstantiationException,
                          IllegalAccessException
Creates a new instance of a class. a newly allocated instance of the class represented by this object. This is done exactly as if by a new expression with an empty argument list.

Throws:
IllegalAccessException - if the class or initializer is not accessible.
InstantiationException - if an application tries to instantiate an abstract class or an interface, or if the instantiation fails for some other reason.

toString

public String toString()
Converts the object to a string. The string representation is the string "class" or "interface" followed by a space and then the fully qualified name of the class. If this Class object represents a primitive type, returns the name of the primitive type.

Should this say "synthetic" as well as "class" or "interface"? Or should that be gated on whether we're proxy to a realclass?

Overrides:
toString in class Object
Returns:
a string representation of this class object.

toSource

public void toSource(OutputStream out,
                     int depth)
Convenience for writing to, eg, System.out

Parameters:
out -
depth -

toSource

public void toSource(PrintWriter out,
                     int depth)
Converts the object to a Java code stream. The string representation is as full a Java definition of the class as we are able to achieve. If this Class object represents a primitive type, returns the name of the primitive type.

Parameters:
out -
depth -

tabset

private String tabset(int depth)
Method tabset

Parameters:
depth - (tabset) @return

modifierFromString

public static int modifierFromString(String t)
Method modifierFromString

Parameters:
t - (modifierFromString) @return

modifiersFromString

public static int modifiersFromString(String s)
Method modifiersFromString

Parameters:
s - (modifiersFromString) @return