Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
Object
org.apache.xml.utils.synthetic.Class
Method Summary | |
void |
|
void |
|
static Class |
|
Constructor |
|
Field |
|
Class |
|
Class |
|
Method |
|
static Class | |
static Class |
|
Class |
|
ClassLoader |
|
Class[] |
|
Class |
|
Constructor |
|
Constructor[] |
|
Class[] |
|
Constructor |
|
Constructor[] |
|
Field |
|
Field[] |
|
Method |
|
Method[] |
|
Class |
|
Field |
|
Field[] |
|
Class[] |
|
Class[] |
|
String |
|
String |
|
Method |
|
Method[] |
|
int |
|
String |
|
String |
|
Class |
|
URL |
|
InputStream |
|
String |
|
Object[] |
|
Class |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
boolean |
|
static int |
|
static int |
|
Object |
|
static Class |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
String |
|
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.
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.
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.
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.
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.
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
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
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.
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.
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.
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.
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.
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.
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.
public Constructor getConstructor(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:
- Returns:
- a Constructor object that reflects the specified public constructor of the class represented by this Class object.
- Throws:
SynthesisException
-
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.
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.
public Constructor getDeclaredConstructor(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:
- Returns:
- a Constructor object that reflects the specified declared constructor of the class or interface represented by this Class object.
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.
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.
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.
public Method getDeclaredMethod(String name, 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.
- Returns:
- Method object that reflects the specified declared method of the class or interface represented by this Class object.
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.
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.
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
-
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.
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
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.
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
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
public Method getMethod(String name, 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
-
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.
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
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
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
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
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.
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.
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
public Object[] getSigners()
Get the signers of this class.
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.
public boolean isArray()
If this Class object represents an array type, returns true, otherwise returns false.
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
-
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
-
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
public boolean isInterface()
Determines if the specified Class object represents an interface type. true if this object represents an interface; false otherwise.
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
-
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.
public static int modifierFromString(String t)
Method modifierFromString
- Parameters:
t
- (modifierFromString) @return
public static int modifiersFromString(String s)
Method modifiersFromString
- Parameters:
s
- (modifiersFromString) @return
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.
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.
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
-
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
-
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
-
- Throws:
SynthesisException
-
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
-
- Throws:
SynthesisException
-
public void toSource(OutputStream out, int depth)
Convenience for writing to, eg, System.out
- Parameters:
out
-depth
-
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
-
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?
- Returns:
- a string representation of this class object.