Interface JexlExpression

  • All Known Implementing Classes:
    Closure, Script

    public interface JexlExpression
    Represents a single JEXL expression.

    This simple interface provides access to the underlying textual expression through getSourceText().

    An expression is different than a script - it is simply a reference to a single expression, not to multiple statements. This implies 'if','for','while','var' and blocks '{'... '}'are not allowed in expressions.

    Do not create classes that implement this interface; delegate or compose instead.

    Since:
    1.0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context)
      Creates a Callable from this expression.
      java.lang.Object evaluate​(JexlContext context)
      Evaluates the expression with the variables contained in the supplied JexlContext.
      java.lang.String getParsedText()
      Recreates the source text of this expression from the internal syntactic tree.
      java.lang.String getSourceText()
      Returns the source text of this expression.
    • Method Detail

      • callable

        java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context)
        Creates a Callable from this expression.

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

        The interpreter will handle interruption/cancellation gracefully if needed.

        Parameters:
        context - the context
        Returns:
        the callable
        Since:
        3.1
      • evaluate

        java.lang.Object evaluate​(JexlContext context)
        Evaluates the expression with the variables contained in the supplied JexlContext.
        Parameters:
        context - A JexlContext containing variables.
        Returns:
        The result of this evaluation
        Throws:
        JexlException - on any error
      • getParsedText

        java.lang.String getParsedText()
        Recreates the source text of this expression from the internal syntactic tree.
        Returns:
        the source text
      • getSourceText

        java.lang.String getSourceText()
        Returns the source text of this expression.
        Returns:
        the source text