Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.jexl2
Class ExpressionImpl

    java.lang.Object
      org.apache.commons.jexl2.ExpressionImpl

All Implemented Interfaces:
  Expression, Script

    public class ExpressionImpl

extends Object
implements Expression, Script

Instances of ExpressionImpl are created by the `JexlEngine`, and this is the default implementation of the `Expression` and `Script` interface.

Since:
  1.0
Version:
  $Id: ExpressionImpl.java 885754 2009-12-01 12:47:00Z henrib $
Author:
  Geir Magnusson Jr.

Field Summary
`protected 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
`protected` | `ExpressionImpl(JexlEngine engine, String expr, ASTJexlScript ref)` Do not let this be generally instantiated with a 'new'.

Method Summary
`String` | `dump()` Returns the JEXL expression by reconstructing it from the parsed tree.
`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`.
`String` | `getExpression()` Returns the JEXL expression this Expression was created with.
`String` | `getText()` Returns the text of this Script.
`String` | `toString()` Provide a string representation of the 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 String expression

  Original expression stripped from leading & trailing spaces.

### script

    protected final ASTJexlScript script

  The resulting AST we can interpret.

Constructor Detail

### ExpressionImpl

    protected ExpressionImpl(JexlEngine engine,
                             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 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 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 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 String toString()

  Provide a string representation of the expression.

  Overrides:
    `toString` in class `Object`
  Returns:
    the expression or blank if it's null.

### getText

    public String getText()

  Returns the text of this Script.

  Specified by:
    `getText` in interface `Script`
  Returns:
    The script to be executed.

### execute

    public 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.