|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.executor.SingleMethodExecutor
public class SingleMethodExecutor
A single Executable
method.
Invokes a single method on given object when executed
.
Field Summary | |
---|---|
protected java.lang.Object[] |
arguments
Arguments for prepare/finalize method |
protected java.lang.reflect.Method |
method
Method to call before/after execution |
protected java.lang.Object |
object
Object on which invoke the prepare/finalize method |
protected java.lang.Object |
returnedValue
Returned value from the executed method |
Constructor Summary | |
---|---|
SingleMethodExecutor(java.lang.reflect.Method method,
java.lang.Object[] possibleObjects,
java.lang.Object[] arguments)
Creates a new instance of SingleMethodExecutor. |
|
SingleMethodExecutor(java.lang.reflect.Method method,
java.lang.Object object,
java.lang.Object[] arguments)
Creates a new instance of SingleMethodExecutor. |
|
SingleMethodExecutor(java.lang.Object object,
java.lang.String methodName,
java.lang.Object... arguments)
Creates a new instance of SingleMethodExecutor. |
Method Summary | ||
---|---|---|
void |
execute()
Invoke the method represented by this object |
|
|
getArgument(java.lang.Class<E> argClass)
Returns executed argument that has a specified class. |
|
java.lang.Object |
getArgument(int index)
Returns the index-th argument of the executed method. |
|
int |
getArgumentCount()
Returns the number of executed arguments. |
|
java.lang.Object[] |
getArguments()
Returns the array of all arguments of the executed method. |
|
static java.lang.reflect.Method |
getDeclaredMethod(java.lang.Class<?> classType,
java.lang.String name,
java.lang.Class[] parameterTypes)
Returns a declared method (i.e. public, protected or private) that matches the given name and parameter types. |
|
java.lang.Object |
getReturnedValue()
Returns value returned by the executed method. |
|
static java.lang.Object |
chooseExecutionObject(java.lang.reflect.Method method,
java.lang.Object[] objects)
Searches a list of instances for an instance that is compatible with the given method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.lang.reflect.Method method
protected final java.lang.Object object
protected final java.lang.Object[] arguments
protected java.lang.Object returnedValue
Constructor Detail |
---|
public SingleMethodExecutor(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object[] arguments)
method
- the method to executeobject
- the instance on which to execute the methodarguments
- the arguments for the methodpublic SingleMethodExecutor(java.lang.reflect.Method method, java.lang.Object[] possibleObjects, java.lang.Object[] arguments) throws java.lang.NoSuchMethodException
method
- the method to executepossibleObjects
- the list of instances on which to execute the method
(the correct one is selected using chooseExecutionObject(java.lang.reflect.Method, java.lang.Object[])
)arguments
- the arguments for the method
java.lang.NoSuchMethodException
- if there was no instance compatible with the given methodpublic SingleMethodExecutor(java.lang.Object object, java.lang.String methodName, java.lang.Object... arguments) throws java.lang.NoSuchMethodException
object
- the instance on which to execute the methodmethodName
- the name of the method to executearguments
- the arguments for the method
java.lang.NoSuchMethodException
- if there was no method compatible with the given parametersMethod Detail |
---|
public static java.lang.Object chooseExecutionObject(java.lang.reflect.Method method, java.lang.Object[] objects) throws java.lang.NoSuchMethodException
method
- the method for which to search a compatible instanceobjects
- the list of instances to search
java.lang.NoSuchMethodException
- if there was no instance compatible with the given methodpublic static java.lang.reflect.Method getDeclaredMethod(java.lang.Class<?> classType, java.lang.String name, java.lang.Class[] parameterTypes) throws java.lang.NoSuchMethodException
classType
- the class in which to start the searchname
- the name of the methodparameterTypes
- the types of parameters of the method
java.lang.NoSuchMethodException
- if there was no method that matches the given parameterspublic int getArgumentCount()
public java.lang.Object getArgument(int index)
index
- the index (zero-based) of the argument to return
public java.lang.Object[] getArguments()
public <E> E getArgument(java.lang.Class<E> argClass) throws java.util.NoSuchElementException
E
- the distinguishing class of the argumentargClass
- the distinguishing class of the argument
java.util.NoSuchElementException
- if a parameter with the argClass class was not foundpublic java.lang.Object getReturnedValue()
public void execute() throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
execute
in interface Executable
java.lang.NoSuchMethodException
- if there is no code to execute
java.lang.reflect.InvocationTargetException
- if there was an exception during executing the code
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |