Venice 0.751beta

nz.org.venice.parser
Class Variables

java.lang.Object
  extended bynz.org.venice.parser.Variables

public class Variables
extends java.lang.Object

A collection of variables.


Constructor Summary
Variables()
          Create a new empty collection of variables.
 
Method Summary
 void add(java.lang.String name, int type, boolean isConstant)
          Add a new variable.
 void add(java.lang.String name, int type, boolean isConstant, boolean isFunction, double value)
          Add a new variable.
 void add(java.lang.String name, int type, boolean isConstant, double value)
          Add a new variable.
 void add(java.lang.String name, int type, boolean isConstant, int value)
          Add a new variable.
 java.lang.Object clone()
          Creates a deep clone of variables.
 boolean contains(java.lang.String name)
          Return whether the collection contains the given variable.
 java.lang.Object copyVariables()
          Creates a deep clone of variables and also clones the variables as well.
 void dump()
           
 Variable get(java.lang.String name)
          Get the variable of the given name.
static java.util.List getDifferences(Variables vars1, Variables vars2)
          Compare the two sets of variables and return any differences.
 int getSize()
           
 int getType(java.lang.String name)
          Get the type of the variable.
 double getValue(java.lang.String name)
          Get the value of the variable.
 void setValue(java.lang.String name, double value)
          Set the value of the given variable.
 void setValue(java.lang.String name, int value)
          Set the value of the given variable.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variables

public Variables()
Create a new empty collection of variables.

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a deep clone of variables.

Returns:
a clone.
Throws:
java.lang.CloneNotSupportedException - this should never happen.

copyVariables

public java.lang.Object copyVariables()
                               throws java.lang.CloneNotSupportedException
Creates a deep clone of variables and also clones the variables as well.

Returns:
a clone, with variables cloned as well.
Throws:
java.lang.CloneNotSupportedException - this should never happen.

contains

public boolean contains(java.lang.String name)
Return whether the collection contains the given variable.

Parameters:
name - the name of the variable o query.

add

public void add(java.lang.String name,
                int type,
                boolean isConstant)
Add a new variable. The variable will be initialised to zero if numeric or FALSE if boolean.

Parameters:
name - the name of the variable.
type - the type of the variable.
isConstant - set to TRUE if the variable is a constant.

add

public void add(java.lang.String name,
                int type,
                boolean isConstant,
                double value)
Add a new variable.

Parameters:
name - the name of the variable.
type - the type of the variable.
isConstant - set to TRUE if the variable is a constant.
value - the initial value.

add

public void add(java.lang.String name,
                int type,
                boolean isConstant,
                int value)
Add a new variable.

Parameters:
name - the name of the variable.
type - the type of the variable.
isConstant - set to TRUE if the variable is a constant.
value - the initial value.

add

public void add(java.lang.String name,
                int type,
                boolean isConstant,
                boolean isFunction,
                double value)
Add a new variable.

Parameters:
name - the name of the variable.
type - the type of the variable.
isConstant - set to TRUE if the variable is a constant.
isFunction - set to TRUE if the variable is a function.
value - the initial value.

setValue

public void setValue(java.lang.String name,
                     double value)
Set the value of the given variable.

Parameters:
name - the name of the variable.
value - the new value of the variable.

setValue

public void setValue(java.lang.String name,
                     int value)
Set the value of the given variable.

Parameters:
name - the name of the variable.
value - the new value of the variable.

getValue

public double getValue(java.lang.String name)
Get the value of the variable.

Parameters:
name - the name of the variable.
Returns:
the variable's value.

getType

public int getType(java.lang.String name)
Get the type of the variable.

Parameters:
name - the name of the variable.
Returns:
the variable's type.

get

public Variable get(java.lang.String name)
Get the variable of the given name.

Parameters:
name - the name of the variable.
Returns:
the variable.

getSize

public int getSize()

dump

public void dump()

getDifferences

public static java.util.List getDifferences(Variables vars1,
                                            Variables vars2)
Compare the two sets of variables and return any differences. A difference is any two variables with the same name but different values or any variables which exist in the first set, but not the second and vice versa.

Parameters:
vars1 - The first set of variables
vars2 - The second set of variables
Returns:
a list of the differences found.

Venice 0.751beta