com.wutka.util
Class Config
java.lang.Object
|
+--com.wutka.util.Config
- public class Config
- extends java.lang.Object
Provides a central location for getting configuration information.
Config includes system properties but changes the keys to be
case-insensitive. In addition, you can specify a configFile parameter
in the system parameters to read in additional config information.
Information specified in the system properties takes priority over
config files. This allows you to override parameters in the config
file at runtime.
|
Field Summary |
protected static boolean |
loadedMainConfig
Indicates whether the config class has tried to read in the file
named by the configFile system property. |
protected static java.util.Properties |
props
The set of configuration items read in from files. |
protected static java.util.Properties |
systemProps
System properties with caseless keys |
|
Method Summary |
protected static void |
addProps(java.util.Properties baseProps,
java.util.Properties newProps)
Adds the properties in newProps to baseProps while converting the
keys to be case-free. |
static java.lang.String |
getConfigItem(java.lang.String key)
Retrieves the config item corresponding to the key, or null
if there is no config item for the key. |
static void |
loadConfig(java.lang.String filename)
Loads configuration information from the named file. |
protected static void |
loadMainConfig()
Uses the system property configFile as the name of a file to
read in config information. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
props
protected static java.util.Properties props
- The set of configuration items read in from files.
systemProps
protected static java.util.Properties systemProps
- System properties with caseless keys
loadedMainConfig
protected static boolean loadedMainConfig
- Indicates whether the config class has tried to read in the file
named by the configFile system property.
Config
public Config()
addProps
protected static void addProps(java.util.Properties baseProps,
java.util.Properties newProps)
- Adds the properties in newProps to baseProps while converting the
keys to be case-free.
- Parameters:
baseProps - The current set of propertiesnewProps - The set of properties to be added to the base set
loadConfig
public static void loadConfig(java.lang.String filename)
throws java.io.IOException
- Loads configuration information from the named file. The syntax for
the config information is the same as for Java properties files.
- Parameters:
filename - The name of the file to read config items from
loadMainConfig
protected static void loadMainConfig()
- Uses the system property configFile as the name of a file to
read in config information.
getConfigItem
public static java.lang.String getConfigItem(java.lang.String key)
- Retrieves the config item corresponding to the key, or null
if there is no config item for the key.
- Parameters:
key - The name of the config item to fetch- Returns:
- The config item, or null if there is no item