public class ClassReference
extends java.lang.Object
| Constructor and Description |
|---|
ClassReference(java.lang.Object o)
Constructor.
|
ClassReference(java.lang.String className)
Contructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Class[] |
getClasses()
Returns all superclasses.
|
java.lang.Object |
getField(java.lang.String field_name)
Returns the field value.
|
java.lang.Object |
invokeMethod(java.lang.String method_name,
java.lang.Object[] params,
java.lang.Class[] params_classes)
Locates method by name and parameter types and executes it.
|
java.lang.Object |
newInstance(java.lang.Object[] params,
java.lang.Class[] params_classes)
Locates constructor by parameter types and creates an instance.
|
void |
setField(java.lang.String field_name,
java.lang.Object newValue)
Change a field's value.
|
void |
startApplication()
Executes class's
main(java.lang.String[]) method
with a zero-length java.lang.String array
as a parameter. |
void |
startApplication(java.lang.String[] params)
Executes class's
main(java.lang.String[]) method. |
public ClassReference(java.lang.Object o)
o - Object to work with.public ClassReference(java.lang.String className)
throws java.lang.ClassNotFoundException
className - name of classjava.lang.ClassNotFoundExceptionpublic void startApplication()
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException
main(java.lang.String[]) method
with a zero-length java.lang.String array
as a parameter.java.lang.NoSuchMethodExceptionjava.lang.reflect.InvocationTargetExceptionpublic void startApplication(java.lang.String[] params)
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException
main(java.lang.String[]) method.params - The java.lang.String array to pass
to main(java.lang.String[]).java.lang.NoSuchMethodExceptionjava.lang.reflect.InvocationTargetExceptionpublic java.lang.Object invokeMethod(java.lang.String method_name,
java.lang.Object[] params,
java.lang.Class[] params_classes)
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException
method_name - Name of method.params - Method parameters.params_classes - Method parameters types.method_name method is void, null is returned.method_name method returns a primitive type, then
return wrapper class instance.java.lang.reflect.InvocationTargetException - when the invoked method throws an exception.java.lang.NoSuchMethodException - when the method cannot be found.java.lang.IllegalAccessException - when access to the class or method is lacking.java.lang.SecurityException - if access to the package or method is denied.java.lang.IllegalAccessExceptionjava.lang.NoSuchMethodExceptionjava.lang.reflect.InvocationTargetExceptionpublic java.lang.Object newInstance(java.lang.Object[] params,
java.lang.Class[] params_classes)
throws java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
params - An array of Method parameters.params_classes - An array of Method parameter types.java.lang.reflect.InvocationTargetException - when the invoked constructor throws an exception.java.lang.NoSuchMethodException - when the constructor cannot be found.java.lang.IllegalAccessException - when access to the class or constructor is lacking.java.lang.InstantiationException - when the constructor is for an abstract class.java.lang.SecurityException - if access to the package or constructor is denied.java.lang.IllegalAccessExceptionjava.lang.NoSuchMethodExceptionjava.lang.InstantiationExceptionjava.lang.reflect.InvocationTargetExceptionpublic java.lang.Object getField(java.lang.String field_name)
throws java.lang.NoSuchFieldException,
java.lang.IllegalAccessException
field_name - The name of the field.java.lang.NoSuchFieldException - when the field cannot be found.java.lang.IllegalAccessException - when access to the class or constructor is lacking.java.lang.SecurityException - if access to the package or field is denied.java.lang.IllegalAccessExceptionjava.lang.NoSuchFieldExceptionsetField(java.lang.String, java.lang.Object)public void setField(java.lang.String field_name,
java.lang.Object newValue)
throws java.lang.NoSuchFieldException,
java.lang.IllegalAccessException
field_name - The name of the field.newValue - The fields new value.java.lang.NoSuchFieldException - when the field cannot be found.java.lang.IllegalAccessException - when access to the class or constructor is lacking.java.lang.SecurityException - if access to the package or field is denied.java.lang.IllegalAccessExceptionjava.lang.NoSuchFieldExceptiongetField(java.lang.String)public java.lang.Class[] getClasses()
java.lang.Object.