Class EnvironmentConfiguration
java.lang.Object
org.apache.commons.configuration2.event.BaseEventSource
org.apache.commons.configuration2.AbstractConfiguration
org.apache.commons.configuration2.MapConfiguration
org.apache.commons.configuration2.EnvironmentConfiguration
- All Implemented Interfaces:
Cloneable,Configuration,EventSource,ImmutableConfiguration,SynchronizerSupport
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, for example:
Configuration envConfig = new EnvironmentConfiguration();
System.out.println("JAVA_HOME=" + envConfig.getString("JAVA_HOME");
- Since:
- 1.5
-
Field Summary
Fields inherited from class org.apache.commons.configuration2.MapConfiguration
map -
Constructor Summary
ConstructorsConstructorDescriptionCreate a Configuration based on the environment variables. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPropertyDirect(String key, Object value) Adds a property to this configuration.protected voidRemoves all properties from this configuration.protected voidRemoves a property from this configuration.Methods inherited from class org.apache.commons.configuration2.MapConfiguration
clone, containsKeyInternal, containsValueInternal, getKeysInternal, getMap, getPropertyInternal, isEmptyInternal, isTrimmingDisabled, setTrimmingDisabled, sizeInternal, toStringMethods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, addPropertyInternal, append, beginRead, beginWrite, clear, clearProperty, cloneInterpolator, contains, containsKey, containsValue, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, getKeysInternal, getList, getList, getList, getList, getListDelimiterHandler, getLogger, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, interpolatedConfiguration, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setPropertyInternal, setSynchronizer, setThrowExceptionOnMissing, size, subset, unlockMethods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEventsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
getEnum, getEnum
-
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:
addPropertyDirectin classMapConfiguration- Parameters:
key- the key of the property to be addedvalue- the property value
-
clearInternal
Removes all properties from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.- Overrides:
clearInternalin classAbstractConfiguration
-
clearPropertyDirect
Removes a property from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.- Overrides:
clearPropertyDirectin classMapConfiguration- Parameters:
key- the key of the property to be removed
-