org.apache.commons.jexl2
Class UnifiedJEXL.Expression

java.lang.Object
  extended by org.apache.commons.jexl2.UnifiedJEXL.Expression
Enclosing class:
UnifiedJEXL

public abstract class UnifiedJEXL.Expression
extends Object

The abstract base class for all expressions, immediate '${...}' and deferred '#{...}'.


Field Summary
protected  UnifiedJEXL.Expression source
          The source of this expression (see prepare(org.apache.commons.jexl2.JexlContext)).
 
Method Summary
 String asString()
          Generates this expression's string representation.
abstract  Object evaluate(JexlContext context)
          Evaluates this expression.
 UnifiedJEXL.Expression getSource()
          Retrieves this expression's source expression.
 boolean isDeferred()
          Checks whether this expression is deferred.
 boolean isImmediate()
          Checks whether this expression is immediate.
abstract  UnifiedJEXL.Expression prepare(JexlContext context)
          When the expression is dependant upon immediate and deferred sub-expressions, evaluates the immediate sub-expressions with the context passed as parameter and returns this expression deferred form.
 String toString()
          Formats this expression, adding its source string representation in comments if available: 'expression /*= source *\/'' .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected final UnifiedJEXL.Expression source
The source of this expression (see prepare(org.apache.commons.jexl2.JexlContext)).

Method Detail

toString

public String toString()
Formats this expression, adding its source string representation in comments if available: 'expression /*= source *\/'' .

Overrides:
toString in class Object
Returns:
the formatted expression string

asString

public String asString()
Generates this expression's string representation.

Returns:
the string representation

prepare

public abstract UnifiedJEXL.Expression prepare(JexlContext context)
When the expression is dependant upon immediate and deferred sub-expressions, evaluates the immediate sub-expressions with the context passed as parameter and returns this expression deferred form.

In effect, this binds the result of the immediate sub-expressions evaluation in the context, allowing to differ evaluation of the remaining (deferred) expression within another context. This only has an effect to nested & composite expressions that contain differed & immediate sub-expressions.

If the underlying JEXL engine is silent, errors will be logged through its logger as warning.

Parameters:
context - the context to use for immediate expression evaluations
Returns:
an expression or null if an error occurs and the JexlEngine is silent
Throws:
UnifiedJEXL.Exception - if an error occurs and the JexlEngine is not silent

evaluate

public abstract Object evaluate(JexlContext context)
Evaluates this expression.

If the underlying JEXL engine is silent, errors will be logged through its logger as warning.

Parameters:
context - the variable context
Returns:
the result of this expression evaluation or null if an error occurs and the JexlEngine is silent
Throws:
UnifiedJEXL.Exception - if an error occurs and the JexlEngine is not silent

isImmediate

public boolean isImmediate()
Checks whether this expression is immediate.

Returns:
true if immediate, false otherwise

isDeferred

public final boolean isDeferred()
Checks whether this expression is deferred.

Returns:
true if deferred, false otherwise

getSource

public final UnifiedJEXL.Expression getSource()
Retrieves this expression's source expression. If this expression was prepared, this allows to retrieve the original expression that lead to it. Other expressions return themselves.

Returns:
the source expression


Copyright © 2001-2011 Apache Software Foundation. All Rights Reserved.