com.plotnix.jex.adapters
Class CompilingInterpreter

java.lang.Object
  |
  +--com.plotnix.jex.Interpreter
        |
        +--com.plotnix.jex.adapters.CompilingInterpreter

public class CompilingInterpreter
extends Interpreter

A wrapper for a compiler that makes it behave like an interpreter. Each expression evaluation method first compiles the expression and then invokes the resulting compiled expression.

The syntax checking methods invoke the compiler and throw away the resulting compiled expression.

Version:
$Revision$
Author:
Dmitri Plotnikov

Constructor Summary
CompilingInterpreter(Compiler compiler)
           
 
Method Summary
 void assign(Context context, java.lang.String expression, java.lang.Object value, java.lang.Object[] arguments)
          Modifies a value in the specified context according to the expression and the supplied arguments.
 java.lang.Object evaluate(Context context, java.lang.String expression, java.lang.Object[] arguments)
          Evaluates the expression in the supplied context.
 java.lang.Object evaluate(Context context, java.lang.String expression, java.lang.Object[] arguments, java.lang.Class valueType)
          Evaluates the expression and casts the result to the supplied type.
 java.util.Iterator iterate(Context context, java.lang.String expression, java.lang.Object[] arguments)
          Produces the iterator described by the expression in the specified context.
 void validateExpression(java.lang.String expression)
          Checks the syntax of an expression intended for evaluation with evaluate and throws an exception if there is an error.
 void validateIterationExpression(java.lang.String expression)
          Checks the syntax of an expression intended for evaluation with iterate and throws an exception if there is an error.
 void validateVariableExpression(java.lang.String expression)
          Checks the syntax of an expression intended for evaluation with assign and throws an exception if there is an error.
 
Methods inherited from class com.plotnix.jex.Interpreter
getInterpreter, getInterpreterImplementation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompilingInterpreter

public CompilingInterpreter(Compiler compiler)
Parameters:
compiler - is the compiler that needs to be wrapped
Method Detail

evaluate

public java.lang.Object evaluate(Context context,
                                 java.lang.String expression,
                                 java.lang.Object[] arguments)
Description copied from class: Interpreter
Evaluates the expression in the supplied context.
Overrides:
evaluate in class Interpreter
See Also:
Interpreter.evaluate(Context, String, Object[])

evaluate

public java.lang.Object evaluate(Context context,
                                 java.lang.String expression,
                                 java.lang.Object[] arguments,
                                 java.lang.Class valueType)
Description copied from class: Interpreter
Evaluates the expression and casts the result to the supplied type.
Overrides:
evaluate in class Interpreter
See Also:
Interpreter.evaluate(Context, String, Object[], Class)

iterate

public java.util.Iterator iterate(Context context,
                                  java.lang.String expression,
                                  java.lang.Object[] arguments)
Description copied from class: Interpreter
Produces the iterator described by the expression in the specified context.
Overrides:
iterate in class Interpreter
See Also:
Interpreter.iterate(Context, String, Object[])

assign

public void assign(Context context,
                   java.lang.String expression,
                   java.lang.Object value,
                   java.lang.Object[] arguments)
Description copied from class: Interpreter
Modifies a value in the specified context according to the expression and the supplied arguments. Casts the type of the value if necessary.
Overrides:
assign in class Interpreter
See Also:
Interpreter.assign(Context, String, Object, Object[])

validateExpression

public void validateExpression(java.lang.String expression)
Description copied from class: Interpreter
Checks the syntax of an expression intended for evaluation with evaluate and throws an exception if there is an error.
Overrides:
validateExpression in class Interpreter
See Also:
Interpreter.validateExpression(String)

validateIterationExpression

public void validateIterationExpression(java.lang.String expression)
Description copied from class: Interpreter
Checks the syntax of an expression intended for evaluation with iterate and throws an exception if there is an error.
Overrides:
validateIterationExpression in class Interpreter
See Also:
Interpreter.validateIterationExpression(String)

validateVariableExpression

public void validateVariableExpression(java.lang.String expression)
Description copied from class: Interpreter
Checks the syntax of an expression intended for evaluation with assign and throws an exception if there is an error.
Overrides:
validateVariableExpression in class Interpreter
See Also:
Interpreter.validateVariableExpression(String)


Copyright (c) 2002 - Plotnix, Inc