org.apache.commons.configuration
Class EnvironmentConfiguration

java.lang.Object
  extended by org.apache.commons.configuration.event.EventSource
      extended by org.apache.commons.configuration.AbstractConfiguration
          extended by org.apache.commons.configuration.MapConfiguration
              extended by org.apache.commons.configuration.EnvironmentConfiguration
All Implemented Interfaces:
java.lang.Cloneable, Configuration

public class EnvironmentConfiguration
extends MapConfiguration

A Configuration implementation that reads the platform specific environment variables using the map returned by System.getenv().

This configuration implementation is read-only. It allows read access to the defined OS environment variables, but their values cannot be changed. Any attempts to add or remove a property will throw an UnsupportedOperationException

Usage of this class is easy: After an instance has been created the get methods provided by the Configuration interface can be used for querying environment variables, e.g.:

 Configuration envConfig = new EnvironmentConfiguration();
 System.out.println("JAVA_HOME=" + envConfig.getString("JAVA_HOME");
 

Since:
1.5
Version:
$Id: EnvironmentConfiguration.java 1210171 2011-12-04 18:32:07Z oheger $
Author:
Nicolas De Loof

Field Summary
 
Fields inherited from class org.apache.commons.configuration.MapConfiguration
map
 
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
EnvironmentConfiguration()
          Create a Configuration based on the environment variables.
 
Method Summary
protected  void addPropertyDirect(java.lang.String key, java.lang.Object value)
          Adds a property to this configuration.
 void clear()
          Removes all properties from this configuration.
 void clearProperty(java.lang.String key)
          Removes a property from this configuration.
 
Methods inherited from class org.apache.commons.configuration.MapConfiguration
clearPropertyDirect, clone, containsKey, getKeys, getMap, getProperty, isEmpty, isTrimmingDisabled, setTrimmingDisabled
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addErrorLogListener, addProperty, append, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, 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

EnvironmentConfiguration

public EnvironmentConfiguration()
Create a Configuration based on the environment variables.

See Also:
System.getenv()
Method Detail

addPropertyDirect

protected void addPropertyDirect(java.lang.String key,
                                 java.lang.Object value)
Adds a property to this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.

Overrides:
addPropertyDirect in class MapConfiguration
Parameters:
key - the key of the property to be added
value - the property value

clearProperty

public void clearProperty(java.lang.String key)
Removes a property from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.

Specified by:
clearProperty in interface Configuration
Overrides:
clearProperty in class AbstractConfiguration
Parameters:
key - the key of the property to be removed

clear

public void clear()
Removes all properties from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.

Specified by:
clear in interface Configuration
Overrides:
clear in class AbstractConfiguration


Copyright © 2001-2013. All Rights Reserved.