Top Description Fields Constructors Methods
org.apache.commons.jexl2.internal

public final Class MethodExecutor

extends Method
Class Inheritance
Imports
java.lang.reflect.Array, .InvocationTargetException, org.apache.commons.jexl2.internal.introspection.MethodKey

Specialized executor to invoke a method on an object.
Since
2.0

Field Summary

Modifier and TypeField and Description
private final boolean
isVarArgs

Whether this method handles varargs.

Inherited from org.apache.commons.jexl2.internal.AbstractExecutor.Method:
key

Constructor Summary

AccessConstructor and Description
public
MethodExecutor(Introspector
the introspector used to discover the method
is
,
Object
the object to find the method in
obj
,
String
the method name
name
,
Object[]
the method arguments
args
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
private static AbstractExecutor.Method.Parameter

Returns:

a filled up parameter (may contain a null method)
discover
(Introspector
the introspector used to discover the method
is
,
Object
the object to introspect
obj
,
String
the name of the method to find
method
,
Object[]
the method arguments
args
)

Discovers a method for a MethodExecutor.

public Object

Returns:

the result of the method invocation
execute
(Object
the object to invoke the method upon
o
,
Object[]
the method arguments
args
)

Implements abstract org.apache.commons.jexl2.internal.AbstractExecutor.Method.execute.

Invokes the method to be executed.
protected Object[]

Returns:

The actual parameters adjusted for the varargs in order to fit the method declaration.
handleVarArg
(Class<?>
The vararg class type (aka component type of the expected array arg)
type
,
int
The index of the vararg in the method declaration (This will always be one less than the number of expected arguments.)
index
,
Object[]
The actual parameters being passed to this method
actual
)

Reassembles arguments if the method is a vararg method.

private static boolean

Returns:

true if method is vararg, false otherwise
isVarArgMethod
(Method
a the method to check
m
)

Determines if a method can accept a variable number of arguments.

public Object
tryExecute(String
the method name
name
,
Object
the object to invoke the method upon
obj
,
Object[]
the method arguments
args
)

Overrides org.apache.commons.jexl2.internal.AbstractExecutor.Method.tryExecute.

Tries to reuse this executor, checking that it is compatible with the actual set of arguments.
Inherited from org.apache.commons.jexl2.internal.AbstractExecutor.Method:
getReturnTypegetTargetPropertyinvoketryInvoke

Field Detail

isVarArgsback to summary
private final boolean isVarArgs

Whether this method handles varargs.

Constructor Detail

MethodExecutorback to summary
public MethodExecutor(Introspector is, Object obj, String name, Object[] args)

Creates a new instance.

Parameters
is:Introspector

the introspector used to discover the method

obj:Object

the object to find the method in

name:String

the method name

args:Object[]

the method arguments

Method Detail

discoverback to summary
private static AbstractExecutor.Method.Parameter discover(Introspector is, Object obj, String method, Object[] args)

Discovers a method for a MethodExecutor.

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:Introspector

the introspector used to discover the method

obj:Object

the object to introspect

method:String

the name of the method to find

args:Object[]

the method arguments

Returns:AbstractExecutor.Method.Parameter

a filled up parameter (may contain a null method)

executeback to summary
public Object execute(Object o, Object[] args) throws IllegalAccessException, InvocationTargetException

Implements abstract org.apache.commons.jexl2.internal.AbstractExecutor.Method.execute.

Invokes the method to be executed.

Parameters
o:Object

the object to invoke the method upon

args:Object[]

the method arguments

Returns:Object

the result of the method invocation

Annotations
@Override
Exceptions
IllegalAccessException:
Method is inaccessible.
InvocationTargetException:
Method body throws an exception.
handleVarArgback to summary
protected Object[] handleVarArg(Class<?> type, int index, Object[] actual)

Reassembles arguments if the method is a vararg method.

Parameters
type:Class<?>

The vararg class type (aka component type of the expected array arg)

index:int

The index of the vararg in the method declaration (This will always be one less than the number of expected arguments.)

actual:Object[]

The actual parameters being passed to this method

Returns:Object[]

The actual parameters adjusted for the varargs in order to fit the method declaration.

isVarArgMethodback to summary
private static boolean isVarArgMethod(Method m)

Determines if a method can accept a variable number of arguments.

Parameters
m:Method

a the method to check

Returns:boolean

true if method is vararg, false otherwise

tryExecuteback to summary
public Object tryExecute(String name, Object obj, Object[] args)

Overrides org.apache.commons.jexl2.internal.AbstractExecutor.Method.tryExecute.

Doc from org.apache.commons.jexl2.internal.AbstractExecutor.Method.tryExecute.

Tries to reuse this executor, checking that it is compatible with the actual set of arguments.

Parameters
name:String

the method name

obj:Object

the object to invoke the method upon

args:Object[]

the method arguments

Returns:Object

the result of the method invocation or TRY_FAILED if checking failed.

Annotations
@Override