org.apache.tools.ant.util
Class ReflectWrapper
java.lang.Object
org.apache.tools.ant.util.ReflectWrapper
public class ReflectWrapper
extends java.lang.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.
ReflectWrapper(ClassLoader loader, String name) - Construct a wrapped object using the no arg constructor.
|
ReflectWrapper(Object obj) - Constructor using a passed in object.
|
Object | getObject()
|
Object | invoke(String methodName) - Call a method on the object with no parameters.
|
Object | invoke(String methodName, Class argType, Object arg) - Call a method on the object with one argument.
|
Object | invoke(String methodName, Class argType1, Object arg1, Class argType2, Object arg2) - Call a method on the object with one argument.
|
ReflectWrapper
public ReflectWrapper(ClassLoader loader,
String name)
Construct a wrapped object using the no arg constructor.
loader
- the classloader to use to construct the class.name
- the classname of the object to construct.
ReflectWrapper
public ReflectWrapper(Object obj)
Constructor using a passed in object.
obj
- the object to wrap.
getObject
public Object getObject()
invoke
public Object invoke(String methodName)
Call a method on the object with no parameters.
methodName
- the name of the method to call
- the object returned by the method
invoke
public Object invoke(String methodName,
Class argType,
Object arg)
Call a method on the object with one argument.
methodName
- the name of the method to callargType
- the type of argument.arg
- the value of the argument.
- the object returned by the method
invoke
public Object invoke(String methodName,
Class argType1,
Object arg1,
Class argType2,
Object arg2)
Call a method on the object with one argument.
methodName
- the name of the method to callargType1
- the type of the first argument.arg1
- the value of the first argument.argType2
- the type of the second argument.arg2
- the value of the second argument.
- the object returned by the method