Package net.sf.jnati.config
Class Configuration
- java.lang.Object
-
- net.sf.jnati.config.Configuration
-
public class Configuration extends java.lang.ObjectImplements a multi-layered configuration. There are three layers of configuration - in order of increasing precedence: defaults, configuration and runtime. Defaults and configured properties can be loaded (from a .properties file) or set (from a Map), while runtime properties are retrieved from System.getProperties().- Author:
- Sam Adams
-
-
Constructor Summary
Constructors Constructor Description Configuration()Construct a new configuration with no parameters.Configuration(java.util.Map<java.lang.String,java.lang.String> params)Construct a new configuration with the specified parameters.Configuration(Configuration parentConfig, java.util.Map<java.lang.String,java.lang.String> params, java.util.Properties configuration)Construct a new configuration with the specified parent configuration, and parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetProperty(java.lang.String key)Gets the property's value.voidloadConfiguration(java.io.InputStream in)Load the configured properties.voidloadDefaults(java.io.InputStream in)Load the default property values.voidsetConfiguration(java.util.Map<java.lang.String,java.lang.String> config)Sets the configured properties.voidsetDefaults(java.util.Map<java.lang.String,java.lang.String> defaults)Sets the default property values.
-
-
-
Constructor Detail
-
Configuration
public Configuration()
Construct a new configuration with no parameters.
-
Configuration
public Configuration(java.util.Map<java.lang.String,java.lang.String> params)
Construct a new configuration with the specified parameters.- Parameters:
params-
-
Configuration
public Configuration(Configuration parentConfig, java.util.Map<java.lang.String,java.lang.String> params, java.util.Properties configuration)
Construct a new configuration with the specified parent configuration, and parameters.- Parameters:
parentConfig-params-
-
-
Method Detail
-
loadDefaults
public void loadDefaults(java.io.InputStream in) throws java.io.IOExceptionLoad the default property values. Existing defaults with the same name will be overridden. Invokes java.util.Properties.load().- Parameters:
in-- Throws:
java.io.IOException
-
setDefaults
public void setDefaults(java.util.Map<java.lang.String,java.lang.String> defaults)
Sets the default property values. Existing defaults with the same name will be overridden.- Parameters:
defaults-
-
loadConfiguration
public void loadConfiguration(java.io.InputStream in) throws java.io.IOExceptionLoad the configured properties. Invokes java.util.Properties.load().- Parameters:
in-- Throws:
java.io.IOException
-
setConfiguration
public void setConfiguration(java.util.Map<java.lang.String,java.lang.String> config)
Sets the configured properties.- Parameters:
config-
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Gets the property's value.- Parameters:
key-- Returns:
- The value for the specified key, or null if no property of that name exists.
-
-