|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.plotnix.jex.Interpreter
An interpreter directly evaluates an expression string. It validates the syntax of the expression and throws an exception if the syntax is invalid.
In order to introduce a new interpreter, create a class called "com.plotnix.jex.language-prefix.Interpreter" that inherits from this class. Jex will find the class by the language prefix and invoke it to interpret expressions in that language.
Constructor Summary | |
Interpreter()
|
Method Summary | |
abstract 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. |
abstract java.lang.Object |
evaluate(Context context,
java.lang.String expression,
java.lang.Object[] arguments)
Evaluates the expression in the supplied context. |
abstract 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. |
static Interpreter |
getInterpreter(java.lang.String language)
Locates and returns an Interpreter for the specified language. |
protected static Interpreter |
getInterpreterImplementation(java.lang.String language)
Locates and returns an Interpreter for the specified language. |
abstract 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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Interpreter()
Method Detail |
public static final Interpreter getInterpreter(java.lang.String language)
language
- is the name of an expression language (no colon
at the end)protected static final Interpreter getInterpreterImplementation(java.lang.String language)
language
- is the name of an expression language (no colon
at the end)public abstract java.lang.Object evaluate(Context context, java.lang.String expression, java.lang.Object[] arguments)
context
- is an evaluation context.expression
- is the expression to be evaluatedarguments
- are argument of the expression. Can be null
if the expression does not take any arguments.public abstract java.lang.Object evaluate(Context context, java.lang.String expression, java.lang.Object[] arguments, java.lang.Class valueType)
evaluate(Context, String, Object[])
public abstract java.util.Iterator iterate(Context context, java.lang.String expression, java.lang.Object[] arguments)
context
- is an evaluation context.expression
- is the expression to be evaluatedarguments
- are argument of the expression. Can be null
if the expression does not take any arguments.public abstract void assign(Context context, java.lang.String expression, java.lang.Object value, java.lang.Object[] arguments)
context
- is an evaluation context.expression
- is the expression to be evaluatedvalue
- is the new valuearguments
- are argument of the expression. Can be null
if the expression does not take any arguments.public void validateExpression(java.lang.String expression)
evaluate
and throws an exception
if there is an error.expression
- is the expression to be checkedpublic void validateIterationExpression(java.lang.String expression)
iterate
and throws an exception
if there is an error.expression
- is the expression to be checkedpublic void validateVariableExpression(java.lang.String expression)
assign
and throws an exception
if there is an error.expression
- is the expression to be checked
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |