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
public abstract class StructureNode extends SimpleNode
Base class for all structure nodes, defines aneval
method.- Author:
- Richard Morris
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.singularsys.jep.parser.Node
Node.HookKey
-
-
Constructor Summary
Constructors Constructor Description StructureNode(int i)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.Object
eval(Evaluator ev)
Evaluate the nodejava.lang.String
getName()
Return the name associated with the node (if any).Operator
getOperator()
Return the operator associated with a Node (if any)PostfixMathCommandI
getPFMC()
Return the pfmc of a node (if any)java.lang.Object
getValue()
Return the value associated with the node (if any).Variable
getVar()
Return the variable associated with a Node (if any)protected static boolean
testCondition(java.lang.Object val)
Convert a value to boolean, for use in condition tests-
Methods inherited from class com.singularsys.jep.parser.SimpleNode
childIterator, children, childrenAccept, dump, getHook, getId, hookKeys, jjtAccept, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, removeHook, setHook, toString
-
-
-
-
Method Detail
-
eval
public abstract java.lang.Object eval(Evaluator ev) throws EvaluationException
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
public java.lang.String getName()
Description copied from interface:Node
Return the name associated with the node (if any).- Returns:
- the name if an ASTVarNode, ASTFunNode, ASTOpNode, null otherwise
-
getOperator
public Operator getOperator()
Description copied from interface:Node
Return the operator associated with a Node (if any)- Returns:
- The Operator for ASTOpNodes, null otherwise
-
getPFMC
public PostfixMathCommandI getPFMC()
Description copied from interface:Node
Return the pfmc of a node (if any)- Returns:
- the PostfixMathCommand for ASTFunNode and ASTOpNode, null otherwise
-
getValue
public java.lang.Object getValue()
Description copied from interface:Node
Return the value associated with the node (if any).- Returns:
- the value if an ASTConstant, ASTVarNode, null otherwise
-
getVar
public Variable getVar()
Description copied from interface:Node
Return the variable associated with a Node (if any)- Returns:
- The Variable for ASTVarNodes, null otherwise
-
testCondition
protected static boolean testCondition(java.lang.Object val) throws EvaluationException
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 cannot be converted to a boolean
-
-