DATA
- DATA_VARIABLE
- USER_DATA_TYPE
- public class ObjectEvaluator<DATA,DATA_VARIABLE,USER_DATA_TYPE> extends Object
String
or
ASTNode
) into a DATA
object type. For example
the ComplexEvaluator
class uses the Complex
class data type.ComplexEvaluator
,
Complex
Modifier and Type | Field and Description |
---|---|
protected ASTNode |
fNode |
protected IASTVisitor<DATA,DATA_VARIABLE,USER_DATA_TYPE> |
fVisitor |
Constructor and Description |
---|
ObjectEvaluator(IASTVisitor<DATA,DATA_VARIABLE,USER_DATA_TYPE> visitor) |
Modifier and Type | Method and Description |
---|---|
void |
clearVariables()
Clear all defined variables for this evaluator.
|
void |
defineVariable(String variableName,
BooleanVariable value)
Define a boolean value for a given variable name.
|
void |
defineVariable(String variableName,
DATA_VARIABLE value)
Define a value for a given variable name.
|
DATA |
evaluate()
Reevaluate the
expression (possibly after a new Variable
assignment) |
DATA |
evaluate(String expression)
Parse the given expression
String and evaluate it to a
DATA value. |
DATA |
evaluateNode(ASTNode node)
Evaluate an already parsed in abstract syntax tree node into a
DATA value. |
DATA |
evaluateNode(ASTNode node,
USER_DATA_TYPE data) |
DATA_VARIABLE |
getVariable(String variableName)
Returns the data variable value to which the specified variableName is
mapped, or
null if this map contains no mapping for the
variableName. |
ASTNode |
optimizeFunction(FunctionNode functionNode)
Optimize an already parsed in
functionNode into an
ASTNode . |
protected ASTNode fNode
protected IASTVisitor<DATA,DATA_VARIABLE,USER_DATA_TYPE> fVisitor
public ObjectEvaluator(IASTVisitor<DATA,DATA_VARIABLE,USER_DATA_TYPE> visitor)
public DATA evaluateNode(ASTNode node)
DATA
value.node
- abstract syntax tree nodepublic DATA evaluateNode(ASTNode node, USER_DATA_TYPE data)
public void defineVariable(String variableName, DATA_VARIABLE value)
variableName
- value
- public DATA_VARIABLE getVariable(String variableName)
null
if this map contains no mapping for the
variableName.variableName
- public void defineVariable(String variableName, BooleanVariable value)
variableName
- value
- public void clearVariables()
public ASTNode optimizeFunction(FunctionNode functionNode)
functionNode
into an
ASTNode
.functionNode
- public DATA evaluate(String expression)
String
and evaluate it to a
DATA
value.expression
- SyntaxError
public DATA evaluate()
expression
(possibly after a new Variable
assignment)expression
- SyntaxError
Copyright © 2016. All rights reserved.