Class MethodExecutor
java.lang.Object
org.apache.commons.jexl3.internal.introspection.AbstractExecutor
org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Method
org.apache.commons.jexl3.internal.introspection.MethodExecutor
- All Implemented Interfaces:
JexlMethod
Specialized executor to invoke a method on an object.
- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
AbstractExecutor.Get, AbstractExecutor.Method, AbstractExecutor.Set
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>
If this method is a vararg method, vaClass is the component type of the vararg array.private final int
If this method is a vararg method, vaStart is the last argument index.Fields inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Method
key
Fields inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
method, objectClass, TRY_FAILED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
MethodExecutor
(Class<?> c, Method m, MethodKey k) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodExecutor
discover
(Introspector is, Object obj, String method, Object[] args) Discovers aMethodExecutor
.private Object[]
handleVarArg
(Object[] args) Reassembles arguments if the method is a vararg method.Invocation method, called when the method invocation should be performed and a value returned.Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.Methods inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Method
getReturnType, getTargetProperty
Methods inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
castInteger, castString, classOf, equals, equals, getMethod, getMethodName, getTargetClass, hashCode, initMarker, isAlive, isCacheable, makeArgs, tryFailed
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.commons.jexl3.introspection.JexlMethod
isCacheable, tryFailed
-
Field Details
-
vaStart
private final int vaStartIf this method is a vararg method, vaStart is the last argument index. -
vaClass
If this method is a vararg method, vaClass is the component type of the vararg array.
-
-
Constructor Details
-
MethodExecutor
Creates a new instance.- Parameters:
c
- the class this executor applies tom
- the methodk
- the MethodKey
-
-
Method Details
-
discover
Discovers aMethodExecutor
.If the object is an array, an attempt will be made to find the method in a List (see
ArrayListWrapper
)If the object is a class, an attempt will be made to find the method as a static method of that class.
- Parameters:
is
- the introspector used to discover the methodobj
- the object to introspectmethod
- the name of the method to findargs
- the method arguments- Returns:
- a filled up parameter (may contain a null method)
-
invoke
public Object invoke(Object o, Object... args) throws IllegalAccessException, InvocationTargetException Description copied from interface:JexlMethod
Invocation method, called when the method invocation should be performed and a value returned.- Parameters:
o
- the objectargs
- method parameters.- Returns:
- the result
- Throws:
IllegalAccessException
InvocationTargetException
-
tryInvoke
Description copied from interface:JexlMethod
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.- Parameters:
name
- the method nameobj
- the object to invoke the method uponargs
- the method arguments- Returns:
- the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.
-
handleVarArg
Reassembles arguments if the method is a vararg method.- Parameters:
args
- The actual arguments being passed to this method- Returns:
- The actual parameters adjusted for the varargs in order to fit the method declaration.
-