net.percederberg.tetris
Class Configuration
java.lang.Object
|
+--net.percederberg.tetris.Configuration
- public class Configuration
- extends java.lang.Object
A program configuration. This class provides static methods for
simplifying the reading of configuration parameters. It also
provides some methods for transforming string values into more
useful objects.
- Version:
- 1.2
- Author:
- Per Cederberg, per@percederberg.net
Method Summary |
static java.awt.Color |
getColor(java.lang.String key,
java.lang.String def)
Returns the color configured for the specified key. |
static java.lang.String |
getValue(java.lang.String key)
Returns a configuration parameter value. |
static java.lang.String |
getValue(java.lang.String key,
java.lang.String def)
Returns a configuration parameter value. |
static void |
setValue(java.lang.String key,
java.lang.String value)
Sets a configuration parameter value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Configuration
public Configuration()
getValue
public static java.lang.String getValue(java.lang.String key)
- Returns a configuration parameter value.
- Parameters:
key
- the configuration parameter key- Returns:
- the configuration parameter value, or
null if not set
getValue
public static java.lang.String getValue(java.lang.String key,
java.lang.String def)
- Returns a configuration parameter value. If the configuration
parameter is not set, a default value will be returned instead.
- Parameters:
key
- the configuration parameter keydef
- the default value to use- Returns:
- the configuration parameter value, or
the default value if not set
setValue
public static void setValue(java.lang.String key,
java.lang.String value)
- Sets a configuration parameter value.
- Parameters:
key
- the configuration parameter keyvalue
- the configuration parameter value
getColor
public static java.awt.Color getColor(java.lang.String key,
java.lang.String def)
- Returns the color configured for the specified key. The key
will be prepended with "tetris.color." and the value will be
read from the system properties. The color value must be
specified in hexadecimal web format, i.e. in the "#RRGGBB"
format. If the default color isn't in a valid format, white
will be returned.
- Parameters:
key
- the configuration parameter keydef
- the default value- Returns:
- the color specified in the configuration, or
a default color value