All Implemented Interfaces:
JexlMethod

public final class MethodExecutor extends AbstractExecutor.Method
Specialized executor to invoke a method on an object.
Since:
2.0
  • Constructor Details

    • MethodExecutor

      public MethodExecutor(Introspector is, Object obj, String name, Object[] args)
      Creates a new instance.
      Parameters:
      is - the introspector used to discover the method
      obj - the object to find the method in
      name - the method name
      args - the method arguments
  • Method Details

    • execute

      Invokes the method to be executed.
      Specified by:
      execute in class AbstractExecutor.Method
      Parameters:
      o - the object to invoke the method upon
      args - the method arguments
      Returns:
      the result of the method invocation
      Throws:
      IllegalAccessException - Method is inaccessible.
      InvocationTargetException - Method body throws an exception.
    • tryExecute

      public Object tryExecute(String name, Object obj, Object[] args)
      Tries to reuse this executor, checking that it is compatible with the actual set of arguments.
      Overrides:
      tryExecute in class AbstractExecutor.Method
      Parameters:
      name - the method name
      obj - the object to invoke the method upon
      args - the method arguments
      Returns:
      the result of the method invocation or TRY_FAILED if checking failed.
    • handleVarArg

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