org.apache.commons.jexl3.internal

## Class Closure

- java.lang.Object
- - org.apache.commons.jexl3.internal.Script
  - - org.apache.commons.jexl3.internal.Closure

- All Implemented Interfaces:
    JexlExpression, JexlScript

      public class Closure
      extends Script

  A Script closure.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.commons.jexl3.internal.Script

      `Script.Curried`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Scope.Frame` | `frame` The frame.

    - ### Fields inherited from class org.apache.commons.jexl3.internal.Script

      `jexl, script, source, version`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Closure(Interpreter theCaller, ASTJexlLambda lambda)` Creates a closure.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Callable<Object>` | `callable(JexlContext context, Object... args)` Creates a Callable from this script.
    `boolean` | `equals(Object obj)`
    `Object` | `evaluate(JexlContext context)` Evaluates the expression with the variables contained in the supplied `JexlContext`.
    `Object` | `execute(JexlContext context)` Executes the script with the variables contained in the supplied `JexlContext`.
    `Object` | `execute(JexlContext context, Object... args)` Executes the script with the variables contained in the supplied `JexlContext` and a set of arguments corresponding to the parameters used during parsing.
    `String` | `getParsedText()` Recreates the source text of this expression from the internal syntactic tree.
    `int` | `hashCode()`
    `void` | `setHoisted(int symbol, Object value)` Sets the hoisted index of a given symbol, ie the target index of a parent hoisted symbol in this closure's frame.
    `String` | `toString()`

    - ### Methods inherited from class org.apache.commons.jexl3.internal.Script

      `callable, checkCacheVersion, createFrame, createInterpreter, curry, getEngine, getLocalVariables, getParameters, getParsedText, getPragmas, getSourceText, getVariables`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### frame

          protected final Scope.Frame frame

      The frame.

  - ### Constructor Detail

    - #### Closure

          protected Closure(Interpreter theCaller,
                 ASTJexlLambda lambda)

      Creates a closure.
      Parameters:
        `theCaller` - the calling interpreter
        `lambda` - the lambda

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Script`

    - #### getParsedText

          public String getParsedText()

      Description copied from class: `Script`
      Recreates the source text of this expression from the internal syntactic tree.
      Specified by:
        `getParsedText` in interface `JexlExpression`
      Specified by:
        `getParsedText` in interface `JexlScript`
      Overrides:
        `getParsedText` in class `Script`
      Returns:
        the source text

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Script`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Script`

    - #### setHoisted

          public void setHoisted(int symbol,
                        Object value)

      Sets the hoisted index of a given symbol, ie the target index of a parent hoisted symbol in this closure's frame.

      This is meant to allow a locally defined function to "see" and call itself as a local (hoisted) variable; in other words, this allows recursive call of a function.

      Parameters:
        `symbol` - the symbol index (in the caller of this closure)
        `value` - the value to set in the local frame

    - #### evaluate

          public Object evaluate(JexlContext context)

      Description copied from class: `Script`
      Evaluates the expression with the variables contained in the supplied `JexlContext`.
      Specified by:
        `evaluate` in interface `JexlExpression`
      Overrides:
        `evaluate` in class `Script`
      Parameters:
        `context` - A JexlContext containing variables.
      Returns:
        The result of this evaluation

    - #### execute

          public Object execute(JexlContext context)

      Description copied from class: `Script`
      Executes the script with the variables contained in the supplied `JexlContext`.
      Specified by:
        `execute` in interface `JexlScript`
      Overrides:
        `execute` in class `Script`
      Parameters:
        `context` - A JexlContext containing variables.
      Returns:
        The result of this script, usually the result of the last statement.

    - #### execute

          public Object execute(JexlContext context,
                       Object... args)

      Description copied from class: `Script`
      Executes the script with the variables contained in the supplied `JexlContext` and a set of arguments corresponding to the parameters used during parsing.
      Specified by:
        `execute` in interface `JexlScript`
      Overrides:
        `execute` in class `Script`
      Parameters:
        `context` - A JexlContext containing variables.
        `args` - the arguments
      Returns:
        The result of this script, usually the result of the last statement.

    - #### callable

          public Callable<Object> callable(JexlContext context,
                                  Object... args)

      Description copied from class: `Script`
      Creates a Callable from this script.

      This allows to submit it to an executor pool and provides support for asynchronous calls.

      The interpreter will handle interruption/cancellation gracefully if needed.

      Specified by:
        `callable` in interface `JexlScript`
      Overrides:
        `callable` in class `Script`
      Parameters:
        `context` - the context
        `args` - the script arguments
      Returns:
        the callable

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.