Class StructureNode
java.lang.Object
com.singularsys.jep.parser.SimpleNode
com.singularsys.extensions.structure.StructureNode
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
ControlNode,IfNode,LoopNode,SequenceNode
Base class for all structure nodes, defines an
eval method.- Author:
- Richard Morris
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.singularsys.jep.parser.Node
Node.HookKey -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ObjectEvaluate the nodegetName()Return the name associated with the node (if any).Return the operator associated with a Node (if any)getPFMC()Return the pfmc of a node (if any)getValue()Return the value associated with the node (if any).getVar()Return the variable associated with a Node (if any)protected static booleantestCondition(Object val) Convert a value to boolean, for use in condition testsMethods inherited from class com.singularsys.jep.parser.SimpleNode
childIterator, children, childrenAccept, dump, getChildren, getHook, getId, hookKeys, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, removeHook, setHook, toString
-
Constructor Details
-
StructureNode
public StructureNode(int i)
-
-
Method Details
-
eval
Evaluate the node- Parameters:
ev- The evaluator theEvaluator.eval(com.singularsys.jep.parser.Node)can be used to evaluate children.- Returns:
- result of evaluation
- Throws:
EvaluationException- if evaluation cannot be performed
-
getName
Description copied from interface:NodeReturn the name associated with the node (if any).- Returns:
- the name if an ASTVarNode, ASTFunNode, ASTOpNode, null otherwise
-
getOperator
Description copied from interface:NodeReturn the operator associated with a Node (if any)- Returns:
- The Operator for ASTOpNodes, null otherwise
-
getPFMC
Description copied from interface:NodeReturn the pfmc of a node (if any)- Returns:
- the PostfixMathCommand for ASTFunNode and ASTOpNode, null otherwise
-
getValue
Description copied from interface:NodeReturn the value associated with the node (if any).- Returns:
- the value if an ASTConstant, ASTVarNode, null otherwise
-
getVar
Description copied from interface:NodeReturn the variable associated with a Node (if any)- Returns:
- The Variable for ASTVarNodes, null otherwise
-
testCondition
Convert a value to boolean, for use in condition tests- Parameters:
val- value to test, a Number or Boolean- Returns:
- val converted to a boolean
- Throws:
EvaluationException- if val cannot be converted to a boolean
-