net.scheinerman.phoenix.interpreter.parser
Class DataNode

java.lang.Object
  extended by net.scheinerman.phoenix.interpreter.parser.DataNode
All Implemented Interfaces:
ParserTreeNode

public class DataNode
extends java.lang.Object
implements ParserTreeNode

Represents a variable or a literal in the parsing of Phoenix expression tree.

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman

Field Summary
private  Variable data
          The data held by this node.
private  boolean parenthesized
          Whether or not this node was encapsulated by parentheses.
 
Constructor Summary
DataNode(Variable data)
          Creates a new data node which holds a variable as a piece of data to be used in the parsing tree.
 
Method Summary
 int getPrecedence()
          Returns the precedence of the node in the order of operations, when it should be evaluated in the tree.
 boolean isParenthesized()
          Returns true or false based on whether or not this node was encapsulated by parentheses.
 ParserTreeNode left()
          Should be implemented to return the left child node of the current node.
 Variable operate()
          Returns the data encapsulated by this node.
 ParserTreeNode right()
          Should be implemented to return the right child node of the current node.
 void setParenthesized(boolean parenthesized)
          Sets whether or not this node is encapsulated by parentheses.
 java.lang.String toString()
          Returns a string version of the data held by this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parenthesized

private boolean parenthesized
Whether or not this node was encapsulated by parentheses.


data

private Variable data
The data held by this node.

Constructor Detail

DataNode

public DataNode(Variable data)
Creates a new data node which holds a variable as a piece of data to be used in the parsing tree.

Parameters:
data - - The variable datum to be held by this node.
Method Detail

isParenthesized

public boolean isParenthesized()
Description copied from interface: ParserTreeNode
Returns true or false based on whether or not this node was encapsulated by parentheses.

Specified by:
isParenthesized in interface ParserTreeNode
Returns:
Whether or not this node was encapsulated by parentheses.

setParenthesized

public void setParenthesized(boolean parenthesized)
Description copied from interface: ParserTreeNode
Sets whether or not this node is encapsulated by parentheses.

Specified by:
setParenthesized in interface ParserTreeNode
Parameters:
parenthesized - - true if this node is surrounded by parentheses, false if not.

left

public final ParserTreeNode left()
Description copied from interface: ParserTreeNode
Should be implemented to return the left child node of the current node.

Specified by:
left in interface ParserTreeNode
Returns:
null

right

public final ParserTreeNode right()
Description copied from interface: ParserTreeNode
Should be implemented to return the right child node of the current node.

Specified by:
right in interface ParserTreeNode
Returns:
null

operate

public final Variable operate()
Returns the data encapsulated by this node.

Specified by:
operate in interface ParserTreeNode
Returns:
The variable held by this node.

toString

public final java.lang.String toString()
Returns a string version of the data held by this node.

Overrides:
toString in class java.lang.Object

getPrecedence

public final int getPrecedence()
Description copied from interface: ParserTreeNode
Returns the precedence of the node in the order of operations, when it should be evaluated in the tree. The precedence is an integer, the higher the integer, the higher the precedence, meaning that this node will be evaluated sooner than those of lower precedence.

Specified by:
getPrecedence in interface ParserTreeNode
Returns:
-1