|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.executor.MethodExecutor
messif.executor.MethodNameExecutor
public class MethodNameExecutor
This class allows to execute a methods on a specified object. First, methods must be registered. This is done through constructor, where also an instance of the target object must be provided. The second parameter specify the required argument types that the method must have. Then the method execute method can be called. This method invokes the method of the instance (provided in constructor), which is appropriate for the provided arguments. Method backgroundExecute can be called to invoke the method in a new thread. A returned thread can be used for wait calls to test, whether the execution has finished and also to retrieve the data.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class messif.executor.MethodExecutor |
---|
MethodExecutor.ExecutableMethod |
Field Summary |
---|
Fields inherited from class messif.executor.MethodExecutor |
---|
executionObject |
Constructor Summary | |
---|---|
MethodNameExecutor(java.lang.Object executionObject,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodNameExecutor and search for operation methods. |
|
MethodNameExecutor(java.lang.Object executionObject,
int nameArgIndex,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodNameExecutor and search for operation methods. |
Method Summary | |
---|---|
protected java.util.Map<java.lang.String,java.lang.reflect.Method> |
createRegisteredMethods(java.lang.Class classToSearch,
boolean staticOnly,
java.lang.Class<?>[] methodPrototype)
Search the classToSearch for methods that are matching the given
methodPrototype . |
java.util.List<java.lang.String> |
getDifferentiatingNames(java.lang.String regexp)
Returns the list of method names that this executor supports and that match the specified regular expression. |
static int |
getFirstStringClass(java.lang.Class<?>[] array)
Search array for first String class. |
protected java.lang.reflect.Method |
getMethod(java.lang.Object[] arguments)
Returns the method that is appropriate for the provided arguments. |
protected java.util.Collection<java.lang.reflect.Method> |
getRegisteredMethods()
Returns all methods that are registered within this executor. |
static java.lang.String |
getStringObject(java.lang.Object[] array,
int index)
Get string from array at specified position. |
Methods inherited from class messif.executor.MethodExecutor |
---|
backgroundExecute, backgroundExecute, backgroundExecute, execute, execute, printUsage, printUsage, printUsage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MethodNameExecutor(java.lang.Object executionObject, int nameArgIndex, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations onmethodPrototype
- list of argument types for the registered methodsnameArgIndex
- the index of an argument from methodPrototype, which will hold the method name
java.lang.IllegalArgumentException
- if either the method prototype or named argument index is invalid or the executionObject is nullpublic MethodNameExecutor(java.lang.Object executionObject, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
first string class
in the given methodPrototype
is expected to hold the method name.
executionObject
- an instance of the object to execute the operations onmethodPrototype
- list of argument types for the registered methods
java.lang.IllegalArgumentException
- if either the method prototype or named argument index is invalid or the executionObject is nullMethod Detail |
---|
protected java.util.Map<java.lang.String,java.lang.reflect.Method> createRegisteredMethods(java.lang.Class classToSearch, boolean staticOnly, java.lang.Class<?>[] methodPrototype)
classToSearch
for methods that are matching the given
methodPrototype
. The search is recursive starting from the
top-level (excluding Object
) class to classToSearch
.
classToSearch
- the class to searchstaticOnly
- the flag if only static methods are addedmethodPrototype
- the prototype of the methods to search for
public static int getFirstStringClass(java.lang.Class<?>[] array)
array
- the array to search
public static java.lang.String getStringObject(java.lang.Object[] array, int index) throws java.lang.ClassCastException, java.lang.IndexOutOfBoundsException
array
- the array of argumentsindex
- the index of the argument to get
java.lang.ClassCastException
- if the array item at the specified position is not a string
java.lang.IndexOutOfBoundsException
- if the specified position is invalidprotected java.lang.reflect.Method getMethod(java.lang.Object[] arguments) throws java.lang.NoSuchMethodException
MethodExecutor
getMethod
in class MethodExecutor
arguments
- the arguments for the method
java.lang.NoSuchMethodException
- if there is no method that can process the provided arguments in this executorpublic java.util.List<java.lang.String> getDifferentiatingNames(java.lang.String regexp)
regexp
- the regular expression for matching method names
protected java.util.Collection<java.lang.reflect.Method> getRegisteredMethods()
MethodExecutor
getRegisteredMethods
in class MethodExecutor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |