|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object acm.util.OptionTable
public class OptionTable
This class implements a simple tool for parsing key/value pairs from a string.
Constructor Summary | |
---|---|
OptionTable(Map<String,String> map)
Creates a new OptionTable from an existing map. |
|
OptionTable(String str)
Creates a new OptionTable and initializes it
from the specified string. |
|
OptionTable(String str,
String[] keys)
Creates a new OptionTable from the specified string,
checking to make sure that all keys exist in the string array
keys . |
Method Summary | |
---|---|
double |
getDoubleOption(String key)
Returns the double value associated with key
in the option table, or 0.0 if no such value exists. |
double |
getDoubleOption(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(String key)
Returns the integer value associated with key in the option
table, or 0 if no such value exists. |
int |
getIntOption(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. |
HashMap<String,String> |
getMap()
Returns the HashMap used to associate keys and options. |
String |
getOption(String key)
Returns the value associated with key in the option
table, or null if no such value exists. |
String |
getOption(String key,
String defValue)
Returns the value associated with key in the option
table or the specified default value if no such binding exists. |
boolean |
isSpecified(String key)
Returns true if the key has been specified in the option table. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public OptionTable(Map<String,String> map)
OptionTable
from an existing map.
Most clients will not need to use this method.
map
- An existing key/value mappingpublic OptionTable(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(String str, 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 keysMethod Detail |
---|
public double getDoubleOption(String key)
double
value associated with key
in the option table, or 0.0 if no such value exists.
key
- The key
double
public double getDoubleOption(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 found
public int getIntOption(String key)
key
in the option
table, or 0 if no such value exists.
key
- The key
public int getIntOption(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 found
public HashMap<String,String> getMap()
HashMap
used to associate keys and options.
HashMap
used to associate keys and optionspublic String getOption(String key)
key
in the option
table, or null
if no such value exists.
key
- The key
public String getOption(String key, 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 found
public boolean isSpecified(String key)
key
- The key being checked
true
if key
was specified in the option string
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |