com.raritantechnologies.utils.program
Class Value

java.lang.Object
  extended bycom.raritantechnologies.utils.program.Value

public class Value
extends java.lang.Object

This class represents a value to be resolved during program execution


Field Summary
static long MILLISECONDS_IN_A_DAY
           
static boolean NOT_A_BOOLEAN
           
static java.util.Date NOT_A_DATE
           
static java.lang.String NOT_A_STRING
           
static int NOT_AN_INT
           
 
Constructor Summary
Value(java.lang.String name, int type)
          constructor for variables
Value(Token t, Lexer l)
          Constructor which performs a symbol table lookup if the symbol is not found, assume it is a word.
Value(Value v)
          Constructor which copies a Value
 
Method Summary
 java.lang.Object clone()
          Clones a tree (or sub-tree) and returns the root of the new tree.
 boolean evaluate(java.util.HashMap localVars)
          evaluates an expression tree and returns true or false from the top
 Value[] getArgs()
          Returns the args
 int getArity()
          Returns the arity of this node.
 boolean getBool()
          Returns the boolean
 boolean getBooleanValue(java.util.HashMap localVars)
          Returns the boolean value of this node.
 java.util.Date getDate()
          Returns the date
 java.util.Date getDateValue(java.util.HashMap localVars)
          Returns the date value of this node.
 int getIntValue(java.util.HashMap localVars)
          Returns the int value of this node.
 Value getLeft()
          Get the left child of this node.
 java.lang.String getName()
          Returns the string for the human readable name of the symbol.
 int getNum()
          Returns the int
 int getParenLevel()
          Returns the depth that this node is nested within parens.
 Value getParent()
          Get the parent of this node.
 int getPrecedence()
          Returns the precedence of this node.
 Value getRight()
          Get the right child of this node.
 java.lang.String getString()
          Returns the String
 java.lang.String getStringValue(java.util.HashMap localVars)
          Returns the string value of this node.
 int getType()
          Returns the type of this node.
 Value insertValue(Value newValue, Value current)
          Inserts a node starting at current level, then bubbles up to the proper precedence level.
 boolean isBoolean()
          Checks whether this is a boolean returning value.
 boolean isDate()
          Checks whether this is a date returning value.
 boolean isInt()
          Checks whether this is a integer returning value.
 boolean isString()
          Checks whether this is a string returning value.
 java.lang.String probeParentField()
          Scans the tree from this point to find a "parent" field.
 void setArgs(Value[] a)
          Returns the args
 void setArity(int a)
          Set the arity of this node.
 void setBooleanValue(boolean b)
          Set the boolean value of this node.
 void setDateValue(java.util.Date d)
          Set the date value of this node.
 void setIntValue(int n)
          Set the int value of this node.
 void setLeft(Value n)
          Set the left child of this node.
 void setName(java.lang.String n)
          Sets the name string.
 void setParenLevel(int l)
          Sets the level or parenthesis depth .
 void setParent(Value n)
          Set the parent of this node.
 void setPrecedence(int p)
          Sets the precedence of this node.
 void setRight(Value n)
          Set the right child of this node.
 void setStringValue(java.lang.String s)
          Set the string value of this node.
 void setType(int t)
          Set the type of this node.
 java.lang.String toTreeString()
           
 java.lang.String toTreeString(int level)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLISECONDS_IN_A_DAY

public static final long MILLISECONDS_IN_A_DAY
See Also:
Constant Field Values

NOT_AN_INT

public static final int NOT_AN_INT
See Also:
Constant Field Values

NOT_A_STRING

public static final java.lang.String NOT_A_STRING

NOT_A_DATE

public static final java.util.Date NOT_A_DATE

NOT_A_BOOLEAN

public static final boolean NOT_A_BOOLEAN
See Also:
Constant Field Values
Constructor Detail

Value

public Value(Token t,
             Lexer l)
Constructor which performs a symbol table lookup if the symbol is not found, assume it is a word.

Parameters:
l - the instance of the lexer.

Value

public Value(Value v)
Constructor which copies a Value


Value

public Value(java.lang.String name,
             int type)
constructor for variables

Method Detail

getName

public java.lang.String getName()
Returns the string for the human readable name of the symbol.


setName

public void setName(java.lang.String n)
Sets the name string.


getType

public int getType()
Returns the type of this node.


setType

public void setType(int t)
Set the type of this node.


getParenLevel

public int getParenLevel()
Returns the depth that this node is nested within parens.


setParenLevel

public void setParenLevel(int l)
Sets the level or parenthesis depth .


getPrecedence

public int getPrecedence()
Returns the precedence of this node.


setPrecedence

public void setPrecedence(int p)
Sets the precedence of this node.


getParent

public Value getParent()
Get the parent of this node.


setParent

public void setParent(Value n)
Set the parent of this node.


getLeft

public Value getLeft()
Get the left child of this node.


setLeft

public void setLeft(Value n)
Set the left child of this node.


getRight

public Value getRight()
Get the right child of this node.


setRight

public void setRight(Value n)
Set the right child of this node.


isInt

public boolean isInt()
Checks whether this is a integer returning value.


isString

public boolean isString()
Checks whether this is a string returning value.


isBoolean

public boolean isBoolean()
Checks whether this is a boolean returning value.


isDate

public boolean isDate()
Checks whether this is a date returning value.


getBooleanValue

public boolean getBooleanValue(java.util.HashMap localVars)
Returns the boolean value of this node.


setBooleanValue

public void setBooleanValue(boolean b)
Set the boolean value of this node.


getIntValue

public int getIntValue(java.util.HashMap localVars)
Returns the int value of this node.


setIntValue

public void setIntValue(int n)
Set the int value of this node.


getDateValue

public java.util.Date getDateValue(java.util.HashMap localVars)
Returns the date value of this node.


setDateValue

public void setDateValue(java.util.Date d)
Set the date value of this node.


getStringValue

public java.lang.String getStringValue(java.util.HashMap localVars)
Returns the string value of this node.


setStringValue

public void setStringValue(java.lang.String s)
Set the string value of this node.


getString

public java.lang.String getString()
Returns the String


getNum

public int getNum()
Returns the int


getDate

public java.util.Date getDate()
Returns the date


getBool

public boolean getBool()
Returns the boolean


setArgs

public void setArgs(Value[] a)
Returns the args


getArgs

public Value[] getArgs()
Returns the args


getArity

public int getArity()
Returns the arity of this node.


setArity

public void setArity(int a)
Set the arity of this node.


insertValue

public Value insertValue(Value newValue,
                         Value current)
Inserts a node starting at current level, then bubbles up to the proper precedence level. returns the new root node or null if root hasn't changed


probeParentField

public java.lang.String probeParentField()
Scans the tree from this point to find a "parent" field.


clone

public java.lang.Object clone()
Clones a tree (or sub-tree) and returns the root of the new tree.


evaluate

public boolean evaluate(java.util.HashMap localVars)
evaluates an expression tree and returns true or false from the top


toTreeString

public java.lang.String toTreeString()

toTreeString

public java.lang.String toTreeString(int level)