Class ExpressionImpl

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String expression
      Original expression stripped from leading & trailing spaces.
      protected JexlEngine jexl
      The engine for this expression.
      protected ASTJexlScript script
      The resulting AST we can interpret.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ExpressionImpl​(JexlEngine engine, java.lang.String expr, ASTJexlScript ref)
      Do not let this be generally instantiated with a 'new'.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context)
      Creates a Callable from this script.
      java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context, java.lang.Object... args)
      Creates a Callable from this script.
      java.lang.String dump()
      Returns the JEXL expression by reconstructing it from the parsed tree.
      java.lang.Object evaluate​(JexlContext context)
      Evaluates the expression with the variables contained in the supplied JexlContext.
      java.lang.Object execute​(JexlContext context)
      Executes the script with the variables contained in the supplied JexlContext.
      java.lang.Object execute​(JexlContext context, java.lang.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.
      java.lang.String getExpression()
      Returns the JEXL expression this Expression was created with.
      java.lang.String[] getLocalVariables()
      Gets this script local variables.
      java.lang.String[] getParameters()
      Gets this script parameters.
      java.lang.String getText()
      Returns the text of this Script.
      java.util.Set<java.util.List<java.lang.String>> getVariables()
      Gets this script variables.
      java.lang.String toString()
      Provide a string representation of this expression.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • jexl

        protected final JexlEngine jexl
        The engine for this expression.
      • expression

        protected final java.lang.String expression
        Original expression stripped from leading & trailing spaces.
    • Constructor Detail

      • ExpressionImpl

        protected ExpressionImpl​(JexlEngine engine,
                                 java.lang.String expr,
                                 ASTJexlScript ref)
        Do not let this be generally instantiated with a 'new'.
        Parameters:
        engine - the interpreter to evaluate the expression
        expr - the expression.
        ref - the parsed expression.
    • Method Detail

      • evaluate

        public java.lang.Object evaluate​(JexlContext context)
        Evaluates the expression with the variables contained in the supplied JexlContext.
        Specified by:
        evaluate in interface Expression
        Parameters:
        context - A JexlContext containing variables.
        Returns:
        The result of this evaluation
      • dump

        public java.lang.String dump()
        Returns the JEXL expression by reconstructing it from the parsed tree.
        Specified by:
        dump in interface Expression
        Returns:
        the JEXL expression
      • getExpression

        public java.lang.String getExpression()
        Returns the JEXL expression this Expression was created with.
        Specified by:
        getExpression in interface Expression
        Returns:
        The JEXL expression to be evaluated
      • toString

        public java.lang.String toString()
        Provide a string representation of this expression.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the expression or blank if it's null.
      • getText

        public java.lang.String getText()
        Returns the text of this Script.
        Specified by:
        getText in interface Script
        Returns:
        The script to be executed.
      • execute

        public java.lang.Object execute​(JexlContext context)
        Executes the script with the variables contained in the supplied JexlContext.
        Specified by:
        execute in interface Script
        Parameters:
        context - A JexlContext containing variables.
        Returns:
        The result of this script, usually the result of the last statement.
      • execute

        public java.lang.Object execute​(JexlContext context,
                                        java.lang.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.
        Specified by:
        execute in interface Script
        Parameters:
        context - A JexlContext containing variables.
        args - the arguments
        Returns:
        The result of this script, usually the result of the last statement.
        Since:
        2.1
      • getParameters

        public java.lang.String[] getParameters()
        Gets this script parameters.
        Specified by:
        getParameters in interface Script
        Returns:
        the parameters or null
        Since:
        2.1
      • getLocalVariables

        public java.lang.String[] getLocalVariables()
        Gets this script local variables.
        Specified by:
        getLocalVariables in interface Script
        Returns:
        the local variables or null
        Since:
        2.1
      • getVariables

        public java.util.Set<java.util.List<java.lang.String>> getVariables()
        Gets this script variables.

        Note that since variables can be in an ant-ish form (ie foo.bar.quux), each variable is returned as a list of strings where each entry is a fragment of the variable ({"foo", "bar", "quux"} in the example.

        Specified by:
        getVariables in interface Script
        Returns:
        the variables or null
        Since:
        2.1
      • callable

        public java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context)
        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 Script
        Parameters:
        context - the context
        Returns:
        the callable
        Since:
        2.1
      • callable

        public java.util.concurrent.Callable<java.lang.Object> callable​(JexlContext context,
                                                                        java.lang.Object... args)
        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 Script
        Parameters:
        context - the context
        args - the script arguments
        Returns:
        the callable
        Since:
        2.1