jsynoptic.parser
Class ExpressionNode

java.lang.Object
  extended by jsynoptic.parser.SimpleNode
      extended by jsynoptic.parser.ExpressionNode
All Implemented Interfaces:
java.lang.Cloneable, Node
Direct Known Subclasses:
NodeForAddition, NodeForBooleanTest, NodeForFunctionCall, NodeForLogicalOperation, NodeForMultiplication, NodeForNumber, NodeForPower, NodeForUnaryOperation

public abstract class ExpressionNode
extends SimpleNode
implements java.lang.Cloneable

This is the base class for all our nodes It has an evaluate() function, which evaluates the subtree under this node and return a Number value As a commodity to avoid duplicate code, it also has a function to return the list of variables used at any place in the tree


Field Summary
 
Fields inherited from class jsynoptic.parser.SimpleNode
children, id, parent, parser
 
Constructor Summary
ExpressionNode(ExpressionParser p, int i)
          From SimpleNode
ExpressionNode(int i)
          From SimpleNode
 
Method Summary
 java.lang.Object clone()
           
abstract  java.lang.Number evaluate()
          Evaluate the subtree under this node and return the computation result as a number
 java.util.Set getVariables()
          Return the list of variables used at any place in the tree.
 
Methods inherited from class jsynoptic.parser.SimpleNode
dump, jjtAddChild, jjtClose, jjtGetChild, jjtGetNumChildren, jjtGetParent, jjtOpen, jjtSetParent, toString, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExpressionNode

public ExpressionNode(int i)
From SimpleNode

Parameters:
i -

ExpressionNode

public ExpressionNode(ExpressionParser p,
                      int i)
From SimpleNode

Parameters:
p -
i -
Method Detail

evaluate

public abstract java.lang.Number evaluate()
Evaluate the subtree under this node and return the computation result as a number


getVariables

public java.util.Set getVariables()
Return the list of variables used at any place in the tree.

Returns:
The vector of all variable used, of type VariableDefinition. The returned vector may be empty, but not null

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object