acm.util
Class OptionTable

java.lang.Object
  |
  +--java.util.AbstractMap
        |
        +--java.util.HashMap
              |
              +--acm.util.OptionTable

public class OptionTable extends HashMap


 
Constructor Summary
OptionTable(Map 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.
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.
 

Constructor Detail

public OptionTable(Map map)

Creates a new OptionTable from an existing map. Most clients will not need to use this method.

 
Usage: OptionTable options = new OptionTable(map); 
Parameter: 
map  An existing key/value mapping
 

public OptionTable(String str)

Creates a new OptionTable and initializes it from the specified string. The options in str are in two possible forms:
  1. key
  2. key=value
The first option sets the value associated with the key to the empty string; the second supplies the value explicitly.

 
Usage: OptionTable options = new OptionTable(str); 
Parameter: 
str  The option string that is parsed to initialize the table
 

public 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. If keys is null, checking is disabled.

 
Usage: OptionTable options = new OptionTable(str, keys); 
Parameters: 
str  The option string that is parsed to initialize the table
keys  An array of strings indicating the legal keys
 
Method Detail

public double getDoubleOption(String key)

Returns the double value associated with key in the option table, or 0.0 if no such value exists.

 
Usage: double value = options.getDoubleOption(key); 
Parameter: 
key  The key
Returns: The corresponding option value parsed as a double
 

public 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.

 
Usage: double value = options.getDoubleOption(key, defValue); 
Parameters: 
key  The key
defValue  The default to use if the key is not found
Returns: The corresponding option value
 

public int getIntOption(String key)

Returns the integer value associated with key in the option table, or 0 if no such value exists.

 
Usage: int value = options.getIntOption(key); 
Parameter: 
key  The key
Returns: The corresponding option value parsed as an integer
 

public 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.

 
Usage: int value = options.getIntOption(key, defValue); 
Parameters: 
key  The key
defValue  The default to use if the key is not found
Returns: The corresponding option value
 

public String getOption(String key)

Returns the value associated with key in the option table, or null if no such value exists.

 
Usage: String value = options.getOption(key); 
Parameter: 
key  The key
Returns: The corresponding option value
 

public 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.

 
Usage: String value = options.getOption(key, defValue); 
Parameters: 
key  The key
defValue  The default to use if the key is not found
Returns: The corresponding option value
 

public boolean isSpecified(String key)

Returns true if the key has been specified in the option table.

 
Usage: if (options.isSpecified(key)) . . . 
Parameter: 
key  The key being checked
Returns: true if key was specified in the option string