Package net.sf.antcontrib.util
Class Reflector
- java.lang.Object
-
- net.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.- Author:
- Peter Reilly
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
call(java.lang.String methodName)
Call a method on the object with no parameters.java.lang.Object
call(java.lang.String methodName, java.lang.Object o)
Call a method with one parameter.java.lang.Object
call(java.lang.String methodName, java.lang.Object o1, java.lang.Object o2)
Call a method with two parameters.java.lang.Object
callExplicit(java.lang.String methodName, java.lang.Class classType, java.lang.Object o)
Call a method with an object using a specific type as for the method parameter.java.lang.Object
callExplicit(java.lang.String methodName, java.lang.String className, java.lang.Object o)
Call a method with an object using a specific type as for the method parameter.java.lang.Object
getObject()
-
-
-
Constructor Detail
-
Reflector
public Reflector(java.lang.String name)
Constructor for the wrapper using a classname- Parameters:
name
- the classname of the object to construct.
-
Reflector
public Reflector(java.lang.Object obj)
Constructor using a passed in object.- Parameters:
obj
- the object to wrap.
-
-
Method Detail
-
getObject
public java.lang.Object getObject()
- Returns:
- the wrapped object.
-
call
public java.lang.Object call(java.lang.String methodName)
Call a method on the object with no parameters.- Parameters:
methodName
- the name of the method to call- Returns:
- the object returned by the method
-
callExplicit
public java.lang.Object callExplicit(java.lang.String methodName, java.lang.String className, java.lang.Object o)
Call a method with an object using a specific type as for the method parameter.- Parameters:
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- Returns:
- the object returned by the method
-
callExplicit
public java.lang.Object callExplicit(java.lang.String methodName, java.lang.Class classType, java.lang.Object o)
Call a method with an object using a specific type as for the method parameter.- Parameters:
methodName
- the name of the methodclassType
- the class of the parameter of the methodo
- the object to use as the argument of the method- Returns:
- the object returned by the method
-
call
public java.lang.Object call(java.lang.String methodName, java.lang.Object o)
Call a method with one parameter.- Parameters:
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).- Returns:
- the object returned by the method
-
call
public java.lang.Object call(java.lang.String methodName, java.lang.Object o1, java.lang.Object o2)
Call a method with two parameters.- 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).- Returns:
- the object returned by the method
-
-