DATA
- the generic typeDATA_VARIABLE
- the generic typeUSER_DATA_TYPE
- the generic typepublic 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)
Instantiates a new object evaluator.
|
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)
Evaluate node.
|
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)
visitor
- the visitorpublic DATA evaluateNode(ASTNode node)
DATA
value.node
- abstract syntax tree nodepublic DATA evaluateNode(ASTNode node, USER_DATA_TYPE data)
node
- the nodedata
- the datapublic void defineVariable(String variableName, DATA_VARIABLE value)
variableName
- the variable namevalue
- the valuepublic DATA_VARIABLE getVariable(String variableName)
null
if this map contains no mapping for the
variableName.variableName
- the variable namepublic void defineVariable(String variableName, BooleanVariable value)
variableName
- the variable namevalue
- the valuepublic void clearVariables()
public ASTNode optimizeFunction(FunctionNode functionNode)
functionNode
into an
ASTNode
.functionNode
- the function nodepublic DATA evaluate(String expression)
String
and evaluate it to a
DATA
value.expression
- the expressionSyntaxError
- the syntax errorpublic DATA evaluate()
expression
(possibly after a new Variable
assignment).SyntaxError
- the syntax errorCopyright © 2018. All rights reserved.