net.sf.antcontrib.util
Class Reflector
java.lang.Objectnet.sf.antcontrib.util.Reflector
public class Reflector
extends java.lang.Object
Utility class to handle reflection on java objects.
Its main purpose is to allow ant-contrib classes
to compile under ant1.5 but allow the classes to
use ant1.6 classes and code if present.
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.
Reflector(Object obj)- Constructor using a passed in object.
|
Reflector(String name)- Constructor for the wrapper using a classname
|
Object | call(String methodName)- Call a method on the object with no parameters.
|
Object | call(String methodName, Object o)- Call a method with one parameter.
|
Object | call(String methodName, Object o1, Object o2)- Call a method with two parameters.
|
Object | callExplicit(String methodName, Class classType, Object o)- Call a method with an object using a specific
type as for the method parameter.
|
Object | callExplicit(String methodName, String className, Object o)- Call a method with an object using a specific
type as for the method parameter.
|
Object | getObject()
|
Reflector
public Reflector(Object obj)
Constructor using a passed in object.
obj - the object to wrap.
Reflector
public Reflector(String name)
Constructor for the wrapper using a classname
name - the classname of the object to construct.
call
public Object call(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
call
public Object call(String methodName,
Object o) Call a method with one parameter.
methodName - the name of the method to callo - the object to use as the parameter, this must
be of the same type as the method parameter (not a subclass).
- the object returned by the method
call
public Object call(String methodName,
Object o1,
Object o2) Call a method with two parameters.
methodName - the name of the method to callo1 - the object to use as the first parameter, this must
be of the same type as the method parameter (not a subclass).o2 - the object to use as the second parameter, this must
be of the same type as the method parameter (not a subclass).
- the object returned by the method
callExplicit
public Object callExplicit(String methodName,
Class classType,
Object o) Call a method with an object using a specific
type as for the method parameter.
methodName - the name of the methodclassType - the class of the parameter of the methodo - the object to use as the argument of the method
- the object returned by the method
callExplicit
public Object callExplicit(String methodName,
String className,
Object o) Call a method with an object using a specific
type as for the method parameter.
methodName - the name of the methodclassName - the name of the class of the parameter of the methodo - the object to use as the argument of the method
- the object returned by the method
getObject
public Object getObject()