Class AbstractExecutor.Method
java.lang.Object
org.apache.commons.jexl2.internal.AbstractExecutor
org.apache.commons.jexl2.internal.AbstractExecutor.Method
- All Implemented Interfaces:
JexlMethod
- Direct Known Subclasses:
MethodExecutor
- Enclosing class:
AbstractExecutor
Abstract class that is used to execute an arbitrary method.
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classA helper class to pass the method & parameters.Nested classes/interfaces inherited from class AbstractExecutor
AbstractExecutor.Get, AbstractExecutor.Method, AbstractExecutor.Set -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final MethodKeyThe method key discovered from the arguments.Fields inherited from class AbstractExecutor
method, objectClass, TRY_FAILED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMethod(Class<?> c, AbstractExecutor.Method.Parameter km) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract ObjectInvokes the method to be executed.final Class<?> Returns the return type of the method invoked.Gets the property targeted by this executor.final ObjectInvocation method, called when the method invocation should be performed and a value returned.tryExecute(String name, Object obj, Object[] args) Tries to reuse this executor, checking that it is compatible with the actual set of arguments.final ObjectAttempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.Methods inherited from class AbstractExecutor
equals, equals, getMethod, getMethodName, getTargetClass, hashCode, isAlive, isCacheable, tryFailedMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JexlMethod
isCacheable, tryFailed
-
Field Details
-
key
-
-
Constructor Details
-
Method
Creates a new instance.- Parameters:
c- the class this executor applies tokm- the method and MethodKey to encapsulate.
-
-
Method Details
-
invoke
Invocation method, called when the method invocation should be performed and a value returned.- Specified by:
invokein interfaceJexlMethod- Parameters:
obj- the objectparams- method parameters.- Returns:
- the result
- Throws:
Exception- on any error.
-
tryInvoke
Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments. Related to isCacheable since this method is often used with cached JexlMethod instances.- Specified by:
tryInvokein interfaceJexlMethod- Parameters:
name- the method nameobj- the object to invoke the method uponparams- the method arguments- Returns:
- the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.
-
getTargetProperty
Gets the property targeted by this executor.- Overrides:
getTargetPropertyin classAbstractExecutor- Returns:
- the target property
-
getReturnType
Returns the return type of the method invoked.- Specified by:
getReturnTypein interfaceJexlMethod- Returns:
- return type
-
execute
public abstract Object execute(Object obj, Object[] args) throws IllegalAccessException, InvocationTargetException Invokes the method to be executed.- Parameters:
obj- the object to invoke the method uponargs- the method arguments- Returns:
- the result of the method invocation
- Throws:
IllegalAccessException- Method is inaccessible.InvocationTargetException- Method body throws an exception.
-
tryExecute
Tries to reuse this executor, checking that it is compatible with the actual set of arguments.- Parameters:
name- the method nameobj- the object to invoke the method uponargs- the method arguments- Returns:
- the result of the method invocation or TRY_FAILED if checking failed.
-