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
public final class MethodExecutor extends AbstractExecutor.Method
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
Fields Modifier and Type Field Description private java.lang.Class<?>
vaClass
If this method is a vararg method, vaClass is the component type of the vararg array.private int
vaStart
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
Constructors Modifier Constructor Description private
MethodExecutor(java.lang.Class<?> c, java.lang.reflect.Method m, MethodKey k)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MethodExecutor
discover(Introspector is, java.lang.Object obj, java.lang.String method, java.lang.Object[] args)
Discovers aMethodExecutor
.private java.lang.Object[]
handleVarArg(java.lang.Object[] args)
Reassembles arguments if the method is a vararg method.java.lang.Object
invoke(java.lang.Object o, java.lang.Object... oArgs)
Invocation method, called when the method invocation should be performed and a value returned.java.lang.Object
tryInvoke(java.lang.String name, java.lang.Object obj, java.lang.Object... args)
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
-
-
-
-
Constructor Detail
-
MethodExecutor
private MethodExecutor(java.lang.Class<?> c, java.lang.reflect.Method m, MethodKey k)
Creates a new instance.- Parameters:
c
- the class this executor applies tom
- the methodk
- the MethodKey
-
-
Method Detail
-
discover
public static MethodExecutor discover(Introspector is, java.lang.Object obj, java.lang.String method, java.lang.Object[] args)
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)
-
handleVarArg
private java.lang.Object[] handleVarArg(java.lang.Object[] args)
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.
-
invoke
public java.lang.Object invoke(java.lang.Object o, java.lang.Object... oArgs) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Description copied from interface:JexlMethod
Invocation method, called when the method invocation should be performed and a value returned.- Parameters:
o
- the objectoArgs
- method parameters.- Returns:
- the result
- Throws:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
-
tryInvoke
public java.lang.Object tryInvoke(java.lang.String name, java.lang.Object obj, java.lang.Object... args)
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.
-
-