com.parabon.ec.util
Class ParameterConfiguration

java.lang.Object
  extended by org.apache.commons.configuration.event.EventSource
      extended by org.apache.commons.configuration.AbstractConfiguration
          extended by org.apache.commons.configuration.CompositeConfiguration
              extended by com.parabon.ec.util.ParameterConfiguration
All Implemented Interfaces:
java.lang.Cloneable, org.apache.commons.configuration.Configuration

public class ParameterConfiguration
extends org.apache.commons.configuration.CompositeConfiguration

ECJ-compatible parameter file database. Supports the ECJ parameter file format, along with Apache Commons Configuration features such as variable substitution. parent.n entries load additional parameter files $ not part of a variable substitution is replaced with the current directory.

Author:
curt

Field Summary
 
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
 
Constructor Summary
ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor, java.io.File libraryPath, java.io.File file)
          Constructs configuration from file.
ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor, java.io.File libraryPath, java.io.InputStream in)
          Constructs configuration from input stream.
ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor, java.io.File libraryPath, java.util.Map map)
          Constructs configuration from map.
ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor, java.io.File libraryPath, java.net.URL url)
          Constructs configuration from URL input stream.
 
Method Summary
 java.io.File getBasePath()
          Gets the base path used to resolve relative pathnames.
 java.lang.String getEncoding()
          Gets the character set encoding for parameter files.
static java.lang.String interpolateCurdir(java.lang.String value)
          Replaces all $ in the string with the current directory path.
 void load(java.io.InputStream in)
          Loads parameters from an input stream.
protected  void loadConfig(org.apache.commons.configuration.PropertiesConfiguration primaryConfig, java.io.InputStream in)
          Loads parameters from an input stream.
protected  java.lang.Object resolveContainerStore(java.lang.String key)
           
 void setBaseDirectory(java.io.File basePath)
          Sets base path for relative pathnames in parent properties.
 void setEncoding(java.lang.String encoding)
          Sets the character set encoding for parameter files.
 
Methods inherited from class org.apache.commons.configuration.CompositeConfiguration
addConfiguration, addPropertyDirect, clear, clearPropertyDirect, clone, containsKey, getConfiguration, getInMemoryConfiguration, getKeys, getKeys, getList, getNumberOfConfigurations, getProperty, getStringArray, isEmpty, removeConfiguration, setDelimiterParsingDisabled, setListDelimiter
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addErrorLogListener, addProperty, clearProperty, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getSubstitutor, interpolate, interpolate, interpolateHelper, isDelimiterParsingDisabled, isThrowExceptionOnMissing, setDefaultListDelimiter, setDelimiter, setLogger, setProperty, setThrowExceptionOnMissing, subset
 
Methods inherited from class org.apache.commons.configuration.event.EventSource
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterConfiguration

public ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor,
                              java.io.File libraryPath,
                              java.io.InputStream in)
                       throws java.io.IOException
Constructs configuration from input stream. Note that no base path is set so any relative file references in parent parameters will fail.

Parameters:
ancestor - Ancestor paramater database.
libraryPath - Directory to search for included parameter files.
in - Input stream parameter database is read from.
Throws:
java.io.IOException

ParameterConfiguration

public ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor,
                              java.io.File libraryPath,
                              java.io.File file)
                       throws java.io.IOException
Constructs configuration from file.

Throws:
java.io.IOException

ParameterConfiguration

public ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor,
                              java.io.File libraryPath,
                              java.net.URL url)
                       throws java.io.IOException
Constructs configuration from URL input stream.

Throws:
java.io.IOException

ParameterConfiguration

public ParameterConfiguration(org.apache.commons.configuration.AbstractConfiguration ancestor,
                              java.io.File libraryPath,
                              java.util.Map map)
                       throws java.io.IOException
Constructs configuration from map.

Throws:
java.io.IOException
Method Detail

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Loads parameters from an input stream.

Parameters:
in - Parameter input stream.
Throws:
java.io.IOException

loadConfig

protected void loadConfig(org.apache.commons.configuration.PropertiesConfiguration primaryConfig,
                          java.io.InputStream in)
                   throws java.io.IOException
Loads parameters from an input stream.

Parameters:
primaryConfig - Configuration that parameters are loaded into.
in - Parameter file input stream.
Throws:
java.io.IOException

interpolateCurdir

public static java.lang.String interpolateCurdir(java.lang.String value)
Replaces all $ in the string with the current directory path. Ignored un-interpolated property references such as ${foo}. Public only so it can be accessed from ParameterDatabase.

Parameters:
value - String value to be substituted.

setBaseDirectory

public void setBaseDirectory(java.io.File basePath)
Sets base path for relative pathnames in parent properties.

Parameters:
basePath - Base directory path

getBasePath

public java.io.File getBasePath()
Gets the base path used to resolve relative pathnames.

Returns:
Base directory path

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the character set encoding for parameter files.

Parameters:
encoding - Character set encoding

getEncoding

public java.lang.String getEncoding()
Gets the character set encoding for parameter files.

Returns:
Java character set.

resolveContainerStore

protected java.lang.Object resolveContainerStore(java.lang.String key)
Overrides:
resolveContainerStore in class org.apache.commons.configuration.AbstractConfiguration