public class ConfigParameters extends Object
In accordance with the Strategy design pattern the retrieval of
a key-value pair is delegated to an instance of
ConfigData
.
Constructor and Description |
---|
ConfigParameters(ConfigData configData)
Creates an instance from the specified ConfigData object.
|
Modifier and Type | Method and Description |
---|---|
String |
get(String key)
Returns the string value associated with the specified key.
|
String |
get(String key,
String defaultValue)
Returns the string value associated with the specified key or
defaultValue if undefined.
|
boolean |
getBoolean(String key)
Returns the boolean associated with the specified key.
|
boolean |
getBoolean(String key,
boolean defaultValue)
Returns the boolean associated with the specified key.
|
Color |
getColor(String key)
Returns the color associated with the specified key.
|
Color |
getColor(String key,
Color defaultValue)
Returns the color associated with the specified key or the specified
default value if no key-value pair exists for the specified key.
|
double |
getDouble(String key)
Returns the double associated with the specified key.
|
double |
getDouble(String key,
double defaultValue)
Returns the double associated with the specified key or
defaultValue if no key-value pair exists for the specified key.
|
double[] |
getDoubleArray(String key)
Returns the array of doubles associated with the specified key.
|
double[] |
getDoubleArray(String key,
double[] defaultValue)
Returns the array of doubles associated with the specified key
or defaultValue if no key-value pair exists for
the specified key.
|
String |
getFullKey(String key)
Returns the full key.
|
int |
getInt(String key)
Returns the integer associated with the specified key.
|
int |
getInt(String key,
int defaultValue)
Returns the integer associated with the specified key or
defaultValue if no key-value pair exists for the specified key.
|
ConfigParameters |
getNode(String key)
Returns the child node associated with the specified key.
|
public ConfigParameters(ConfigData configData)
public String getFullKey(String key)
ConfigData.getFullKey(java.lang.String)
public String get(String key)
key
- The (relative) key. null is not allowed.IllegalArgumentException
- if no value exists for key.
The exception message is the full key.public String get(String key, String defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.public boolean getBoolean(String key)
key
- The (relative) key. null is not allowed.IllegalArgumentException
- if no value exists for key.
The exception message is the full key.NumberFormatException
- if the value is neither "true" nor "false".public boolean getBoolean(String key, boolean defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.NumberFormatException
- if the value is neither "true" nor "false".public int getInt(String key)
key
- The (relative) key. null is not allowed.IllegalArgumentException
- if no value exists for key.
The exception message is the full key.NumberFormatException
- if the value is not a number.
The exception message contains the full key and the invalid value.public int getInt(String key, int defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.NumberFormatException
- if the value exists but is not a number.
The exception message contains the full key and the invalid value.public double getDouble(String key)
key
- The (relative) key. null is not allowed.IllegalArgumentException
- if no value exists for key.
The exception message is the full key.NumberFormatException
- if the value is not a valid number.
The exception message contains the full key and the invalid value.public double getDouble(String key, double defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.NumberFormatException
- if the value exists but is not a valid
number.
The exception message contains the full key and the invalid value.public double[] getDoubleArray(String key)
key
- The (relative) key. null is not allowed.IllegalArgumentException
- if no value exists for key.
The exception message is the full key.NumberFormatException
- if the value exists but is not a
sequence of number. The exception message contains
the full key and the invalid value.public double[] getDoubleArray(String key, double[] defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.NumberFormatException
- if the value exists but is not a
sequence of number. The exception message contains
the full key and the invalid value.public Color getColor(String key)
key
- The (relative) key. null is not allowed.NumberFormatException
- if the value exists but is not a number.
The exception message contains the full key and the invalid value.public Color getColor(String key, Color defaultValue)
key
- The (relative) key. null is not allowed.defaultValue
- The default value. Can be null.NumberFormatException
- if the value exists but is not a number.
The exception message contains the full key and the invalid value.public ConfigParameters getNode(String key)
key
- The (relative) key. null is not allowed.Copyright © 2015. All Rights Reserved.