Class MethodExecutor

All Implemented Interfaces:
JexlMethod

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

    • vaStart

      private final int vaStart
      If this method is a vararg method, vaStart is the last argument index.
    • vaClass

      private final Class<?> vaClass
      If this method is a vararg method, vaClass is the component type of the vararg array.
  • Constructor Details

    • MethodExecutor

      private MethodExecutor(Class<?> c, Method m, MethodKey k)
      Creates a new instance.
      Parameters:
      c - the class this executor applies to
      m - the method
      k - the MethodKey
  • Method Details

    • discover

      public static MethodExecutor discover(Introspector is, Object obj, String method, Object[] args)
      Discovers 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 - the introspector used to discover the method
      obj - the object to introspect
      method - the name of the method to find
      args - the method arguments
      Returns:
      a filled up parameter (may contain a null method)
    • handleVarArg

      private Object[] handleVarArg(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

      Description copied from interface: JexlMethod
      Invocation method, called when the method invocation should be performed and a value returned.
      Parameters:
      o - the object
      oArgs - method parameters.
      Returns:
      the result
      Throws:
      IllegalAccessException
      InvocationTargetException
    • tryInvoke

      public Object tryInvoke(String name, Object obj, 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 name
      obj - the object to invoke the method upon
      args - the method arguments
      Returns:
      the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.