www.sdmetrics.com

com.sdmetrics.math
Class ExpressionNode

java.lang.Object
  extended by com.sdmetrics.math.ExpressionNode

public class ExpressionNode
extends java.lang.Object

Represents a node in the operator tree for a math expression.


Constructor Summary
ExpressionNode(java.lang.String identifier)
          Creates a new node representing an identifier.
 
Method Summary
 ExpressionNode getLeftNode()
          Retrieves the node representing the left hand side of a binary operation, or the operand of a unary operation.
 ExpressionNode getOperand(int index)
          Gets an operand of the node.
 int getOperandCount()
          Gets the number of operands of this node.
 ExpressionNode getRightNode()
          Retrieves the node representing the right hand side of a binary operation.
 java.lang.String getValue()
          Retrieves the value of this node.
 boolean isIdentifier()
          Tests whether this node represents an identifier.
 boolean isNumberConstant()
          Tests whether this node represents a number constant.
 boolean isOperation()
          Tests whether this node represents an operation.
 boolean isStringConstant()
          Tests whether this node represents a string constant.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionNode

public ExpressionNode(java.lang.String identifier)
Creates a new node representing an identifier.

Parameters:
identifier - The identifier
Method Detail

getValue

public java.lang.String getValue()
Retrieves the value of this node. The meaning of the value depends on the node type:

Returns:
value of the node

getOperandCount

public int getOperandCount()
Gets the number of operands of this node.

Returns:
The number of operands of this node
Since:
2.3

getOperand

public ExpressionNode getOperand(int index)
Gets an operand of the node.

Parameters:
index - Index of the operand. Valid indices run from 0 to getOperandCount().
Returns:
The operand at the given index.
Throws:
java.lang.IllegalArgumentException - Index out of range
Since:
2.3

getLeftNode

public ExpressionNode getLeftNode()
Retrieves the node representing the left hand side of a binary operation, or the operand of a unary operation. Convenience method for unary/binary operations.

Returns:
the left node, or null if there is no left operand

getRightNode

public ExpressionNode getRightNode()
Retrieves the node representing the right hand side of a binary operation. Convenience method for binary operations.

Returns:
the right node, or null if there is no right operand

isOperation

public boolean isOperation()
Tests whether this node represents an operation.

Returns:
true if this node represents an operation.

isNumberConstant

public boolean isNumberConstant()
Tests whether this node represents a number constant.

Returns:
true if this node represents a number constant.

isStringConstant

public boolean isStringConstant()
Tests whether this node represents a string constant.

Returns:
true if this node represents a string constant.

isIdentifier

public boolean isIdentifier()
Tests whether this node represents an identifier.

Returns:
true if this node represents an identifier.

www.sdmetrics.com