org.apache.beehive.netui.script
Interface ExpressionEvaluator


public interface ExpressionEvaluator

An interface for evaluating expressions in NetUI. Different languages may implement this to expose the language for use in the NetUI JSP tags.


Method Summary
 String changeContext(String expression, String oldContext, String newContext, int lookupIndex)
          Change the evaluation context of an expression.
 boolean containsExpression(String expression)
          Checks to see if a particular expression contains an expression.
 Object evaluateStrict(String expression, VariableResolver variableResolver)
          Evaluate an expression and return the result.
 boolean isExpression(String expression)
          Checks to see if a particular String is exactly an expression.
 Expression parseExpression(String expression)
          Parse an atomic expression into a common parsed expression representation.
 String qualify(String contextName, String expression)
          Qualify the expression into the given context.
 void update(String expression, Object value, VariableResolver variableResolver, boolean requestParameter)
          Update an expression with the given value.
 

Method Detail

evaluateStrict

Object evaluateStrict(String expression,
                      VariableResolver variableResolver)
                      throws ExpressionEvaluationException
Evaluate an expression and return the result.

Parameters:
expression - the expression to evaluate
variableResolver - the set of contexts that may be used in expression evaluation. This set is not necessarily complete as some objects that can be used as top-level expression contexts may be contained within an object available in this JavaBean.
Throws:
ExpressionEvaluationException - when an error occurs

update

void update(String expression,
            Object value,
            VariableResolver variableResolver,
            boolean requestParameter)
            throws ExpressionUpdateException
Update an expression with the given value. This will apply the parameter value to the object referenced by the expression expression. The requestParameter flag is used by a caller to restrict the set of contexts into which an update can occur on the request.

Parameters:
expression - the expression whose value to update
value - the new value for the update
variableResolver - the set of contexts that may be used in expression evaluation. This set is not necessarily complete as some objects that can be used as top-level expression contexts may be contained within an object available in this JavaBean.
requestParameter - a boolean that marks this update as occurring from data in the request, if true or simply as a regular update.
Throws:
ExpressionUpdateException

changeContext

String changeContext(String expression,
                     String oldContext,
                     String newContext,
                     int lookupIndex)
                     throws ExpressionEvaluationException
Change the evaluation context of an expression. This is used to rewrite some expressions that need to be qualified into a different context for evaluation. The context of an expression is its first identifier, up to the first delimiter.

Parameters:
expression - the expression whose context to change
oldContext - the old context to replace, if present
newContext - the new context to replace if the expression starts with the oldContext
lookupIndex - an index used to qualify an expression into an array look-up.
Throws:
ExpressionEvaluationException

qualify

String qualify(String contextName,
               String expression)
               throws ExpressionEvaluationException
Qualify the expression into the given context. This will take the expression and simply qualify it into the new context contextName.

Parameters:
contextName - the new context
expression - the expression to qualify
Throws:
ExpressionEvaluationException

isExpression

boolean isExpression(String expression)
Checks to see if a particular String is exactly an expression.

Parameters:
expression - the expression to check
Returns:
true if the expression is exactly an expression; false otherwise.
Throws:
IllegalExpressionException - if the given expression expression is not legal.

containsExpression

boolean containsExpression(String expression)
Checks to see if a particular expression contains an expression. This method will return true if there is an expression surrounded by whitespace, other expressions, or literal text.

Parameters:
expression - the expression to check
Returns:
true if the expression contains an expression; false otherwise.

parseExpression

Expression parseExpression(String expression)
Parse an atomic expression into a common parsed expression representation.

Parameters:
expression - the String expression to parse
Returns:
the parsed expression