Package org.netbeans.jemmy
Class ClassReference
- java.lang.Object
-
- org.netbeans.jemmy.ClassReference
-
public class ClassReference extends java.lang.ObjectAllows access to classes by reflection.- Author:
- Alexandre Iline (alexandre.iline@sun.com)
-
-
Constructor Summary
Constructors Constructor Description ClassReference(java.lang.Object o)Constructor.ClassReference(java.lang.String className)Contructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class[]getClasses()Returns all superclasses.java.lang.ObjectgetField(java.lang.String field_name)Returns the field value.java.lang.ObjectinvokeMethod(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.ObjectnewInstance(java.lang.Object[] params, java.lang.Class[] params_classes)Locates constructor by parameter types and creates an instance.voidsetField(java.lang.String field_name, java.lang.Object newValue)Change a field's value.voidstartApplication()Executes class'smain(java.lang.String[])method with a zero-lengthjava.lang.Stringarray as a parameter.voidstartApplication(java.lang.String[] params)Executes class'smain(java.lang.String[])method.
-
-
-
Constructor Detail
-
ClassReference
public ClassReference(java.lang.Object o)
Constructor.- Parameters:
o- Object to work with.
-
ClassReference
public ClassReference(java.lang.String className) throws java.lang.ClassNotFoundExceptionContructor. The object created by this constructor can be used to access static methods and fields only.- Parameters:
className- name of class- Throws:
java.lang.ClassNotFoundException
-
-
Method Detail
-
startApplication
public void startApplication() throws java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodExceptionExecutes class'smain(java.lang.String[])method with a zero-lengthjava.lang.Stringarray as a parameter.- Throws:
java.lang.NoSuchMethodExceptionjava.lang.reflect.InvocationTargetException
-
startApplication
public void startApplication(java.lang.String[] params) throws java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodExceptionExecutes class'smain(java.lang.String[])method.- Parameters:
params- Thejava.lang.Stringarray to pass tomain(java.lang.String[]).- Throws:
java.lang.NoSuchMethodExceptionjava.lang.reflect.InvocationTargetException
-
invokeMethod
public 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.IllegalAccessExceptionLocates method by name and parameter types and executes it.- Parameters:
method_name- Name of method.params- Method parameters.params_classes- Method parameters types.- Returns:
- the return value from an invocation of the Method.
Ifmethod_namemethod is void,nullis returned.
Ifmethod_namemethod returns a primitive type, then return wrapper class instance. - Throws:
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.InvocationTargetException
-
newInstance
public 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.InstantiationExceptionLocates constructor by parameter types and creates an instance.- Parameters:
params- An array of Method parameters.params_classes- An array of Method parameter types.- Returns:
- a new class instance.
- Throws:
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.InvocationTargetException
-
getField
public java.lang.Object getField(java.lang.String field_name) throws java.lang.NoSuchFieldException, java.lang.IllegalAccessExceptionReturns the field value.- Parameters:
field_name- The name of the field.- Returns:
- the field value
- Throws:
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.NoSuchFieldException- See Also:
setField(java.lang.String, java.lang.Object)
-
setField
public void setField(java.lang.String field_name, java.lang.Object newValue) throws java.lang.NoSuchFieldException, java.lang.IllegalAccessExceptionChange a field's value.- Parameters:
field_name- The name of the field.newValue- The fields new value.- Throws:
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.NoSuchFieldException- See Also:
getField(java.lang.String)
-
getClasses
public java.lang.Class[] getClasses()
Returns all superclasses.- Returns:
- an array of superclasses, starting with the reference class
and ending with
java.lang.Object.
-
-