Top Description Fields Constructors Methods
org.apache.tools.ant.util

public Class ReflectWrapper

extends Object
Class Inheritance
Imports
java.lang.reflect.Constructor

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.

Field Summary

Modifier and TypeField and Description
private Object

Constructor Summary

AccessConstructor and Description
public
ReflectWrapper(ClassLoader
the classloader to use to construct the class.
loader
,
String
the classname of the object to construct.
name
)

Construct a wrapped object using the no arg constructor.

public
ReflectWrapper(Object
the object to wrap.
obj
)

Constructor using a passed in object.

Method Summary

Modifier and TypeMethod and Description
public <
desired type
T
>
T

Returns:

the wrapped object.
getObject
()

public <
desired type
T
>
T

Returns:

the object returned by the method
invoke
(String
the name of the method to call
methodName
)

Call a method on the object with no parameters.

public <
desired type
T
>
T

Returns:

the object returned by the method
invoke
(String
the name of the method to call
methodName
,
Class<?>
the type of argument.
argType
,
Object
the value of the argument.
arg
)

Call a method on the object with one argument.

public <
desired type
T
>
T

Returns:

the object returned by the method
invoke
(String
the name of the method to call
methodName
,
Class<?>
the type of the first argument.
argType1
,
Object
the value of the first argument.
arg1
,
Class<?>
the type of the second argument.
argType2
,
Object
the value of the second argument.
arg2
)

Call a method on the object with one argument.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

objback to summary
private Object obj

Constructor Detail

ReflectWrapperback to summary
public ReflectWrapper(ClassLoader loader, String name)

Construct a wrapped object using the no arg constructor.

Parameters
loader:ClassLoader

the classloader to use to construct the class.

name:String

the classname of the object to construct.

ReflectWrapperback to summary
public ReflectWrapper(Object obj)

Constructor using a passed in object.

Parameters
obj:Object

the object to wrap.

Method Detail

getObjectback to summary
public <T> T getObject()
Parameters
<T>
desired type
Returns:T

the wrapped object.

Annotations
@SuppressWarnings:unchecked
invokeback to summary
public <T> T invoke(String methodName)

Call a method on the object with no parameters.

Parameters
<T>
desired type
methodName:String

the name of the method to call

Returns:T

the object returned by the method

invokeback to summary
public <T> T invoke(String methodName, Class<?> argType, Object arg)

Call a method on the object with one argument.

Parameters
<T>
desired type
methodName:String

the name of the method to call

argType:Class<?>

the type of argument.

arg:Object

the value of the argument.

Returns:T

the object returned by the method

invokeback to summary
public <T> T invoke(String methodName, Class<?> argType1, Object arg1, Class<?> argType2, Object arg2)

Call a method on the object with one argument.

Parameters
<T>
desired type
methodName:String

the name of the method to call

argType1:Class<?>

the type of the first argument.

arg1:Object

the value of the first argument.

argType2:Class<?>

the type of the second argument.

arg2:Object

the value of the second argument.

Returns:T

the object returned by the method