|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sourceforge.sqlunit.utils.MethodInvocationUtils
public final class MethodInvocationUtils
The MethodInvocationUtils class allow you to instantiate classes and execute method using reflection.
| Method Summary | |
|---|---|
static java.lang.Object[] |
getArguments(Arg[] args)
Convenience method to extract the argument values into an array of Objects to pass to Method.invoke(). |
static java.lang.Class[] |
getArgumentTypes(Arg[] args)
Convenience method to extract the argument types into a Class array to pass to Method.invoke(). |
static java.lang.reflect.Constructor |
getConstructor(java.lang.String className,
java.lang.Class[] ctorArgTypes)
Returns the constructor method for the specified class and the parameters. |
static java.lang.Object |
getInstance(java.lang.String className)
Convenience method to instantiate a class without constructor args. |
static java.lang.Object |
getInstance(java.lang.String className,
java.lang.Object[] ctorArgs,
java.lang.Class[] ctorArgTypes)
Get an instance of the object whose classname and initialization parameters are supplied. |
static java.lang.String |
getRootCauseMessage(java.lang.Throwable th)
Climbs the exception tree to find the application specific message that was thrown by the method. |
static java.lang.Object |
invoke(java.lang.Object anObject,
java.lang.String methodName)
Convenience method to invoke a method without arguments. |
static java.lang.Object |
invoke(java.lang.Object anObject,
java.lang.String methodName,
java.lang.Object[] arguments,
java.lang.Class[] argumentsType)
Invokes the specified method on the specified object and returns the result. |
static java.lang.Object |
invoke(java.lang.String className,
java.lang.String staticMethodName)
Convenience method to invoke a named method on a named class with no arguments. |
static java.lang.Object |
invoke(java.lang.String className,
java.lang.String staticMethodName,
java.lang.Object[] arguments,
java.lang.Class[] argumentsType)
Invokes a named method on a named class with the specified arguments. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.reflect.Constructor getConstructor(java.lang.String className,
java.lang.Class[] ctorArgTypes)
throws SQLUnitException
className - name of the class for which to build the Constructor.ctorArgTypes - an array of constructor parameter types.
SQLUnitException - if there was a problem.
public static java.lang.Object getInstance(java.lang.String className,
java.lang.Object[] ctorArgs,
java.lang.Class[] ctorArgTypes)
throws SQLUnitException
className - the name of the class to instantiate.ctorArgs - an array of constructor argument values.ctorArgTypes - an array of constructor argument types.
SQLUnitException - if there was a problem with instantiating.
public static java.lang.Object getInstance(java.lang.String className)
throws SQLUnitException
className - the name of the class to instantiate.
SQLUnitException - if there was a problem with instantiating.
public static java.lang.Object invoke(java.lang.Object anObject,
java.lang.String methodName,
java.lang.Object[] arguments,
java.lang.Class[] argumentsType)
throws SQLUnitException
anObject - the object to invoke the method on.methodName - the method name to invoke.arguments - an array of method argument values.argumentsType - an array of method argument types.
SQLUnitException - if there was a problem with invoking method.
public static java.lang.Object invoke(java.lang.Object anObject,
java.lang.String methodName)
throws SQLUnitException
anObject - the object to invoke the method on.methodName - the method name to invoke.
SQLUnitException - if there was a problem with the invocation.
public static java.lang.Object invoke(java.lang.String className,
java.lang.String staticMethodName,
java.lang.Object[] arguments,
java.lang.Class[] argumentsType)
throws SQLUnitException
className - the name of the class to invoke the method on.staticMethodName - the name of the static method to invoke.arguments - an array of Object arguments to the method.argumentsType - an array of Class argument types.
SQLUnitException - if there was a problem.
public static java.lang.Object invoke(java.lang.String className,
java.lang.String staticMethodName)
throws SQLUnitException
className - the name of the class to invoke the method on.staticMethodName - the name of the static method to invoke.
SQLUnitException - if there was a problem.
public static java.lang.Object[] getArguments(Arg[] args)
throws SQLUnitException
args - an Array of Arg objects.
SQLUnitException - if there was a problem.
public static java.lang.Class[] getArgumentTypes(Arg[] args)
throws SQLUnitException
args - an array of Arg objects.
SQLUnitException - if there was a problem.public static java.lang.String getRootCauseMessage(java.lang.Throwable th)
th - the Throwable to look at.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||