|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--SimKit.Arguments
A data structure class that supports add and retreive
operations. Records consist of a key and a value; both
are strings. This class can be used to encapsulate pairs
of command line arguments where the first item is a key
(or simulation variable name) and the second represents
the key's value.
Implementation: The implementation is slow
as snot, but shouldn't matter too much for small number
of parameters. A hashtable might be better :-( in case
used for lotsa things.
Constructor Summary | |
Arguments()
Standard constructor - for normal usage |
|
Arguments(java.lang.String tupleString)
Construct the object with a string that contains key-value pairs, seperated by spaces. |
|
Arguments(java.lang.String[] argv)
Construct the object with an array of strings. |
Method Summary | |
void |
add(java.lang.String key)
Add a boolean valued key-value record to the data structure. |
void |
add(java.lang.String key,
java.lang.String value)
Add a key-value record to the data structure. |
boolean |
exists(java.lang.String key)
Search for a key in the database. |
void |
remove(java.lang.String key)
Remove a key-value record from the data structure. |
java.lang.String |
retrieve(java.lang.String key)
Retrieve a key from the database. |
double |
retrieve(java.lang.String key,
double dDefault)
Retrieve a key from the database. |
double |
retrieve(java.lang.String key,
double dDefault,
double min,
double max)
Retrieve a key from the database. |
java.lang.String |
retrieve(java.lang.String key,
java.lang.String sDefault)
Retrieve a key from the database. |
java.lang.String |
toString()
Generate a textual summary of what arguments are currently in the database. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Arguments(java.lang.String tupleString)
tupleString
- A string consisting of an even number
of tokens seperated by spaces. It will be parsed into
key-value pairs. Strings with quotes will not be
parsed as a single token unfortunately.public Arguments(java.lang.String[] argv)
argv
- The array of strings to initialize the object with.
java.lang.IndexOutOfBoundsException
- Thrown if there are
not an even number of command line arguments.public Arguments()
Method Detail |
public void add(java.lang.String key, java.lang.String value)
key
- The key of the record to add.value
- The value of the record to add.public void add(java.lang.String key)
key
- The key of the record to add.public void remove(java.lang.String key)
key
- The key of the record to remove.public boolean exists(java.lang.String key)
key
- The key of the record to find
public java.lang.String retrieve(java.lang.String key)
key
- The key of the record to find
public java.lang.String retrieve(java.lang.String key, java.lang.String sDefault)
key
- The key of the record to findsDefault
- The default value of the double.
retrieve(String)
public double retrieve(java.lang.String key, double dDefault)
key
- The key of the record to finddDefault
- The default value of the double.
retrieve(String)
public double retrieve(java.lang.String key, double dDefault, double min, double max)
key
- The key of the record to finddDefault
- The default value of the double.min
- The minimum value that can be returned.max
- The maximum value that can be returned.
retrieve(String)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |