public class ReflectionManager
extends java.lang.Object
Constructor and Description |
---|
ReflectionManager() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Constructor |
getConstructor(java.lang.Class c,
java.lang.Class[] params)
Retrieves a constructor from a given class.
|
static java.lang.reflect.Field |
getField(java.lang.Class c,
java.lang.String fieldName)
Retrieves a field from a given class.
|
static java.lang.reflect.Method |
getMethod(java.lang.Class c,
java.lang.String methodName)
Retrieves a method of a given class with an empty parameter list.
|
static java.lang.reflect.Method |
getMethod(java.lang.Class c,
java.lang.String methodName,
java.lang.Class[] params)
Retrieves a method of a given class.
|
static java.lang.Object |
getValue(java.lang.Object owner,
java.lang.reflect.Field field)
Returns the value of the given field has in the specified object.
|
static java.lang.Object |
invokeConstructor(java.lang.reflect.Constructor c,
java.lang.Object[] args)
Invokes a constructor.
|
static java.lang.Object |
invokeMethod(java.lang.Object owner,
java.lang.reflect.Method method,
java.lang.Object[] args)
Invokes a method on an object If anything goes wrong a reflect exception
is thrown
|
static void |
setValue(java.lang.Object owner,
java.lang.reflect.Field field,
java.lang.Object value)
Sets the value of the given field of the specified object.
|
public static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String methodName, java.lang.Class[] params) throws ReflectException
c
- the classmethodName
- name of the methodparams
- parameter list of the methodReflectException
public static java.lang.reflect.Method getMethod(java.lang.Class c, java.lang.String methodName) throws ReflectException
c
- the classmethodName
- name of the methodReflectException
public static java.lang.Object invokeMethod(java.lang.Object owner, java.lang.reflect.Method method, java.lang.Object[] args) throws ReflectException
owner
- the object to invoke the method onmethod
- the method to be invokedargs
- arguments of the method callReflectException
public static java.lang.reflect.Constructor getConstructor(java.lang.Class c, java.lang.Class[] params)
c
- the classparams
- the constructor's parameter list.public static java.lang.Object invokeConstructor(java.lang.reflect.Constructor c, java.lang.Object[] args) throws ReflectException
c
- the constructor objectargs
- the arguments for the constructor invocationReflectException
public static java.lang.reflect.Field getField(java.lang.Class c, java.lang.String fieldName) throws ReflectException
c
- the classfieldName
- the field nameReflectException
public static java.lang.Object getValue(java.lang.Object owner, java.lang.reflect.Field field) throws ReflectException
owner
- the object who owns the fieldfield
- the fieldReflectException
public static void setValue(java.lang.Object owner, java.lang.reflect.Field field, java.lang.Object value) throws ReflectException
owner
- the object owning the fieldfield
- the fieldvalue
- the value to set the field toReflectException