public interface Evaluator
| Modifier and Type | Method and Description |
|---|---|
Object |
evaluate(LinkedList<Object> queue)
Evaluates a postfix token queue.
|
Object |
evaluate(String expression)
Evaluates an infix expression.
|
Object |
evaluate(SyntaxTree syntaxTree)
Evaluates a syntax tree.
|
Object |
get(Variable v)
Gets the value of a variable.
|
ExpressionParser |
getParser()
Gets the parser used when evaluating expressions.
|
boolean |
isStrict()
Gets whether the evaluator is operating in strict mode.
|
void |
set(Variable v,
Object value)
Sets the value of a variable.
|
void |
setAll(Map<? extends String,? extends Object> map)
Assigns variables en masse.
|
void |
setStrict(boolean strict)
Sets whether the evaluator is operating in strict mode.
|
default Object |
value(Object token)
Gets the value of a token.
|
default Variable |
var(Object token)
Casts the given token to a variable.
|
ExpressionParser getParser()
boolean isStrict()
setStrict(boolean)void setStrict(boolean strict)
When evaluating strictly, usage of an unassigned variable token in a place
where its value is needed will generate an IllegalArgumentException
with an "Unknown variable" message; in non-strict mode, such a variable
will instead be resolved to an object of type Unresolved with the
same name as the original variable.
In cases such as assignment, this may be sufficient to complete the
evaluation; for example, the expression foo=bar will complete
successfully in non-strict mode, with the variable foo containing
an object of type Unresolved and token value "bar". But in
cases where the unresolved value is needed as an input for additional
operations, the evaluation may still ultimately fail of the operation in
question is not defined for unresolved values. For example, the
DefaultStackEvaluator will fail with an "Unsupported binary
operator" exception when given the expression foo+bar, since
foo and bar are unresolved variables, and the +
operator cannot handle such objects.
strict - True iff the evaluator should operate in strict mode.Object evaluate(String expression)
expression - The infix expression to evaluate.Object evaluate(LinkedList<Object> queue)
queue - The postfix token queue to evaluate.Object evaluate(SyntaxTree syntaxTree)
syntaxTree - The syntax tree to evaluate.default Object value(Object token)
token - The token whose value you want.default Variable var(Object token)
token - The token to cast to a Variable.Variable representation of the token.IllegalArgumentException - if the given token is not a
Variable.Object get(Variable v)
v - The variable whose value you want.IllegalArgumentException - If the variable's value is not set, and
the evaluator is operating in strict mode.void set(Variable v, Object value)
v - The variable whose value you want to set.value - The value to assign to the variable.Copyright © 2015–2021 SciJava. All rights reserved.