ReflectWrapperpublic class ReflectWrapper extends Object Utility class to handle reflection on java objects.
The class is a holder class for an object and
uses java reflection to call methods on the objects.
If things go wrong, BuildExceptions are thrown. |
Fields Summary |
---|
private Object | obj |
Constructors Summary |
---|
public ReflectWrapper(ClassLoader loader, String name)Construct a wrapped object using the no arg constructor.
try {
Class clazz;
clazz = Class.forName(name, true, loader);
Constructor constructor;
constructor = clazz.getConstructor((Class[]) null);
obj = constructor.newInstance((Object[]) null);
} catch (Exception t) {
ReflectUtil.throwBuildException(t);
}
| public ReflectWrapper(Object obj)Constructor using a passed in object.
this.obj = obj;
|
Methods Summary |
---|
public java.lang.Object | getObject()
return obj;
| public java.lang.Object | invoke(java.lang.String methodName)Call a method on the object with no parameters.
return ReflectUtil.invoke(obj, methodName);
| public java.lang.Object | invoke(java.lang.String methodName, java.lang.Class argType, java.lang.Object arg)Call a method on the object with one argument.
return ReflectUtil.invoke(obj, methodName, argType, arg);
| public java.lang.Object | invoke(java.lang.String methodName, java.lang.Class argType1, java.lang.Object arg1, java.lang.Class argType2, java.lang.Object arg2)Call a method on the object with one argument.
return ReflectUtil.invoke(
obj, methodName, argType1, arg1, argType2, arg2);
|
|