|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.crosswire.common.util.ReflectionUtil
public final class ReflectionUtil
Various utilities for calling constructors and methods via introspection.
for license details.
The copyright to this program is held by it's authors.
Constructor Summary | |
---|---|
private |
ReflectionUtil()
Prevent instantiation |
Method Summary | |
---|---|
static Object |
construct(String className)
Build an object using its default constructor. |
static Object |
construct(String className,
Object[] params)
Build an object using the supplied parameters. |
static Object |
construct(String className,
Object[] params,
Class[] paramTypes)
Build an object using the supplied parameters. |
private static Class[] |
describeParameters(Object[] params)
Construct a parallel array of class objects for each element in params. |
private static Method |
getMethod(Class clazz,
String methodName,
Class[] calledTypes)
|
static Object |
invoke(Class clazz,
Object obj,
String methodName,
Object[] params)
Call a method on an object, or statically, with the supplied parameters. |
static Object |
invoke(Class clazz,
Object obj,
String methodName,
Object[] params,
Class[] paramTypes)
Call a method on an object, or statically, with the supplied parameters. |
static Object |
invoke(Object base,
String methodName,
Object[] params)
Call a method on a class given a sting |
static Object |
invoke(String call,
Object[] params)
Call a static method on a class given a string |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private ReflectionUtil()
Method Detail |
---|
public static Object construct(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException
className
- the full class name of the object
ClassNotFoundException
IllegalAccessException
InstantiationException
public static Object construct(String className, Object[] params) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException
className
- the full class name of the objectparams
- the constructor's arguments
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
InstantiationException
public static Object construct(String className, Object[] params, Class[] paramTypes) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException
className
- the full class name of the objectparams
- the constructor's argumentsparamTypes
- the types of the parameters
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
InstantiationException
public static Object invoke(Object base, String methodName, Object[] params) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
base
- The object to invoke a method onmethodName
- The text of the invocation, for example "getName"params
- For example new Object[] { ...}
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Object invoke(String call, Object[] params) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException
call
- The text of the invocation, for example "java.lang.String.getName"params
- For example new Object[] { ...}
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Object invoke(Class clazz, Object obj, String methodName, Object[] params) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
clazz
- the class of the objectobj
- the object having the method, or null to call a static methodmethodName
- the method to be calledparams
- the parameters
NoSuchMethodException
IllegalAccessException
InvocationTargetException
public static Object invoke(Class clazz, Object obj, String methodName, Object[] params, Class[] paramTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
clazz
- the class of the objectobj
- the object having the method, or null to call a static methodmethodName
- the method to be calledparams
- the parametersparamTypes
- the types of each of the parameters
NoSuchMethodException
IllegalAccessException
InvocationTargetException
private static Class[] describeParameters(Object[] params)
params
- the types to describe
private static Method getMethod(Class clazz, String methodName, Class[] calledTypes) throws NoSuchMethodException
NoSuchMethodException
|
Copyright ยจ 2003-2007 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |