public class OptionTable
extends java.lang.Object
Constructor and Description |
---|
OptionTable(java.util.Map<java.lang.String,java.lang.String> map)
Creates a new
OptionTable from an existing map. |
OptionTable(java.lang.String str)
Creates a new
OptionTable and initializes it from the specified
string. |
OptionTable(java.lang.String str,
java.lang.String[] keys)
Creates a new
OptionTable from the specified string, checking to
make sure that all keys exist in the string array keys . |
Modifier and Type | Method and Description |
---|---|
double |
getDoubleOption(java.lang.String key)
Returns the
double value associated with key in the
option table, or 0.0 if no such value exists. |
double |
getDoubleOption(java.lang.String key,
double defValue)
Returns the
double value associated with key in the
option table or the specified default value if no such binding exists. |
int |
getIntOption(java.lang.String key)
Returns the integer value associated with
key in the option
table, or 0 if no such value exists. |
int |
getIntOption(java.lang.String key,
int defValue)
Returns the integer value associated with
key in the option
table or the specified default value if no such binding exists. |
java.util.HashMap<java.lang.String,java.lang.String> |
getMap()
Returns the
HashMap used to associate keys and options. |
java.lang.String |
getOption(java.lang.String key)
Returns the value associated with
key in the option table, or
null if no such value exists. |
java.lang.String |
getOption(java.lang.String key,
java.lang.String defValue)
Returns the value associated with
key in the option table or the
specified default value if no such binding exists. |
boolean |
isSpecified(java.lang.String key)
Returns true if the key has been specified in the option table.
|
public OptionTable(java.lang.String str)
OptionTable
and initializes it from the specified
string. The options in str
are in two possible forms:
str
- The option string that is parsed to initialize the tablepublic OptionTable(java.lang.String str, java.lang.String[] keys)
OptionTable
from the specified string, checking to
make sure that all keys exist in the string array keys
. If
keys
is null
, checking is disabled.str
- The option string that is parsed to initialize the tablekeys
- An array of strings indicating the legal keyspublic OptionTable(java.util.Map<java.lang.String,java.lang.String> map)
OptionTable
from an existing map. Most clients
will not need to use this method.map
- An existing key/value mappingpublic boolean isSpecified(java.lang.String key)
key
- The key being checkedtrue
if key
was specified in the option
stringpublic java.lang.String getOption(java.lang.String key)
key
in the option table, or
null
if no such value exists.key
- The keypublic java.lang.String getOption(java.lang.String key, java.lang.String defValue)
key
in the option table or the
specified default value if no such binding exists.key
- The keydefValue
- The default to use if the key is not foundpublic int getIntOption(java.lang.String key)
key
in the option
table, or 0 if no such value exists.key
- The keypublic int getIntOption(java.lang.String key, int defValue)
key
in the option
table or the specified default value if no such binding exists.key
- The keydefValue
- The default to use if the key is not foundpublic double getDoubleOption(java.lang.String key)
double
value associated with key
in the
option table, or 0.0 if no such value exists.key
- The keydouble
public double getDoubleOption(java.lang.String key, double defValue)
double
value associated with key
in the
option table or the specified default value if no such binding exists.key
- The keydefValue
- The default to use if the key is not foundpublic java.util.HashMap<java.lang.String,java.lang.String> getMap()
HashMap
used to associate keys and options.HashMap
used to associate keys and options