jmathlib.core.interpreter
Class VariableList

java.lang.Object
  extended by jmathlib.core.interpreter.VariableList
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class VariableList
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Class used to store all the declared variables within a context

See Also:
Serialized Form

Constructor Summary
VariableList()
          Sets up the ArrayList of variables
VariableList(VariableList _variables)
          Create a duplicate of a VariableList
 
Method Summary
 void clear()
          remove all variables from the list
 java.lang.Object clone()
          Create a duplicate of this Variable List
 Variable createVariable(java.lang.String name)
          creates a variable, if it doesn't already exist.
 java.util.Iterator getIterator()
           
 int getSize()
           
 Variable getVariable(java.lang.String name)
           
 boolean isVariable(java.lang.String name)
          Check wether or not a variable with the given name exists.
 void listVariables()
          Lists all the currently declared variables to the console and a log file
 void loadVariables(java.lang.String fileName)
          loads the list of variables
 void remove(java.lang.String name)
          Remove a variable from the list
 void saveVariables(java.lang.String fileName)
          saves the list of variables
 void setVariable(java.lang.String name, OperandToken value)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableList

public VariableList()
Sets up the ArrayList of variables


VariableList

public VariableList(VariableList _variables)
Create a duplicate of a VariableList

Parameters:
parent - = the previous variable context
Method Detail

getIterator

public java.util.Iterator getIterator()
Returns:
an iterator for the key/value pairs of the list

getSize

public int getSize()
Returns:
the number of variables

remove

public void remove(java.lang.String name)
Remove a variable from the list

Parameters:
variable-string - = the variable to remove

clear

public void clear()
remove all variables from the list


setVariable

public void setVariable(java.lang.String name,
                        OperandToken value)
Parameters:
name - = the name of the variable
value - = the value to set it to

getVariable

public Variable getVariable(java.lang.String name)
Parameters:
name - = the name of the variable
Returns:
the variable represented with the name name

isVariable

public boolean isVariable(java.lang.String name)
Check wether or not a variable with the given name exists.

Parameters:
name - = the name of a variable

listVariables

public void listVariables()
Lists all the currently declared variables to the console and a log file


createVariable

public Variable createVariable(java.lang.String name)
creates a variable, if it doesn't already exist. it returns the created variable

Parameters:
name - = the name of the variable to create
Returns:
the variable with that name

saveVariables

public void saveVariables(java.lang.String fileName)
saves the list of variables

Parameters:
fileName - = the name of the file to save to

loadVariables

public void loadVariables(java.lang.String fileName)
loads the list of variables

Parameters:
fileName - = the name of the file to load from

clone

public java.lang.Object clone()
Create a duplicate of this Variable List

Overrides:
clone in class java.lang.Object