vmm.functions
Class Variable

java.lang.Object
  extended by vmm.functions.Variable

public class Variable
extends java.lang.Object

A real-valued variable. A Variable can be added to a Parser so that it can be used in the defintion of functions and expressions that are parsed by that parser. It is possible to change the value of a variable with the setVal(double) method, which will affect the value of any expressions and functions in which it is used.


Constructor Summary
Variable(double x)
          Create a Variable with a specified initial value and with name initially equal to null.
Variable(java.lang.String name)
          Create a variable with initial value zero.
Variable(java.lang.String name, double x)
          Create a variable with a specified name and initial value.
 
Method Summary
 java.lang.String getName()
          Gets the name of this variable.
 double getVal()
          Returns the current value of this variable.
 void setName(java.lang.String name)
          Sets the name of this variable.
 void setVal(double x)
          Sets the value of this variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Variable

public Variable(java.lang.String name,
                double x)
Create a variable with a specified name and initial value.

Parameters:
name - the name of the variable. This can be null. If the variable is to be added to a Parser, then the name must be non-null and should be a legal identifier (starting with a letter and containing only letters, digits and the underscore character).
x - the initial value of the variable.

Variable

public Variable(java.lang.String name)
Create a variable with initial value zero.


Variable

public Variable(double x)
Create a Variable with a specified initial value and with name initially equal to null.

Method Detail

getVal

public double getVal()
Returns the current value of this variable.


setVal

public void setVal(double x)
Sets the value of this variable.


getName

public java.lang.String getName()
Gets the name of this variable. This can be null.


setName

public void setName(java.lang.String name)
Sets the name of this variable. The name should not be changed after the variable has been added to a Parser; even if the name is changed, the Parser will continue to use it under the name it had at the time it was added to the parser.