Package org.apache.commons.configuration
Class EnvironmentConfiguration
java.lang.Object
org.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.MapConfiguration
org.apache.commons.configuration.EnvironmentConfiguration
- All Implemented Interfaces:
Cloneable
,Configuration
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
ConstructorsConstructorDescriptionCreate a Configuration based on the environment variables. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPropertyDirect
(String key, Object value) Adds a property to this configuration.void
clear()
Removes all properties from this configuration.void
clearProperty
(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
-
Constructor Details
-
EnvironmentConfiguration
public EnvironmentConfiguration()Create a Configuration based on the environment variables.- See Also:
-
-
Method Details
-
addPropertyDirect
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 classMapConfiguration
- Parameters:
key
- the key of the property to be addedvalue
- the property value
-
clearProperty
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 interfaceConfiguration
- Overrides:
clearProperty
in classAbstractConfiguration
- Parameters:
key
- the key of the property to be removed
-
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 interfaceConfiguration
- Overrides:
clear
in classAbstractConfiguration
-