|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tools.ant.util.ReflectUtil
public class ReflectUtil
Utility class to handle reflection on java objects. The class contains static methods to call reflection methods, catch any exceptions, converting them to BuildExceptions.
Method Summary | |
---|---|
static java.lang.Object |
getField(java.lang.Object obj,
java.lang.String fieldName)
Get the value of a field in an object. |
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.String methodName)
Call a method on the object with no parameters. |
static java.lang.Object |
invoke(java.lang.Object obj,
java.lang.String methodName,
java.lang.Class argType,
java.lang.Object arg)
Call a method on the object with one argument. |
static java.lang.Object |
invoke(java.lang.Object obj,
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 two argument. |
static void |
throwBuildException(java.lang.Exception t)
A method to convert an invocationTargetException to a buildexception and throw it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName)
obj
- the object to invoke the method on.methodName
- the name of the method to call
public static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType, java.lang.Object arg)
obj
- the object to invoke the method on.methodName
- the name of the method to callargType
- the type of argument.arg
- the value of the argument.
public static java.lang.Object invoke(java.lang.Object obj, java.lang.String methodName, java.lang.Class argType1, java.lang.Object arg1, java.lang.Class argType2, java.lang.Object arg2)
obj
- the object to invoke the method on.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.
public static java.lang.Object getField(java.lang.Object obj, java.lang.String fieldName) throws BuildException
obj
- the object to look at.fieldName
- the name of the field in the object.
BuildException
- if there is an error.public static void throwBuildException(java.lang.Exception t) throws BuildException
t
- the invocation target exception.
BuildException
- the converted exception.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |