public class VarMap extends Object
VarMap maps a name to a value. A VarMap is used in the eval method of an Expression object. This class can be used as the default variable-map.
During the evaluation of an expression, if a variable is not supported then a RuntimeException is thrown. Case sensitivity can only be specified in the constructor (for consistency). When case sensitivity is false, the String.equalsIgnoreCase method is used. When case sensitivity is true, the String.equals method is used. By default, case sensitivity is true.
Modifier and Type | Method and Description |
---|---|
double |
getValue(String varName)
Returns the value associated with the specified variable name.
|
double[] |
getValues()
Returns an array of exact length of the values stored in this map.
|
String[] |
getVariableNames()
Returns an array of exact length of the variable names stored in this map.
|
boolean |
isCaseSensitive()
Returns true if the case of the variable names is considered.
|
void |
remove(String varName)
Removes the variable-name from the map.
|
void |
setValue(String varName,
double val)
Assigns the value to the specified variable name.
|
public double getValue(String varName)
RuntimeException
- If a matching variable name cannot be found.public void setValue(String varName, double val)
IllegalArgumentException
- If the variable name is null.public boolean isCaseSensitive()
public String[] getVariableNames()
public double[] getValues()
public void remove(String varName)
Copyright © 2024. All rights reserved.