EnvironmentConfiguration (Apache Commons Configuration 2.15.1 API)
Description: declaration: package: org.apache.commons.configuration2, class: EnvironmentConfiguration

Package org.apache.commons.configuration2

# 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`

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, 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

  Constructors
  Constructor
  Description
  `EnvironmentConfiguration()`
  Create a Configuration based on the environment variables.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addPropertyDirect(String key, Object value)`
  Adds a property to this configuration.
  `protected void`
  `clearInternal()`
  Removes all properties from this configuration.
  `protected void`
  `clearPropertyDirect(String key)`
  Removes a property from this configuration.

  ### Methods inherited from class org.apache.commons.configuration2.MapConfiguration

  `clone, containsKeyInternal, containsValueInternal, getKeysInternal, getMap, getPropertyInternal, isEmptyInternal, isTrimmingDisabled, setTrimmingDisabled, sizeInternal, toString`

  ### Methods 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, unlock`

  ### Methods inherited from class org.apache.commons.configuration2.event.BaseEventSource

  `addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEvents`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration

  `entrySet, forEach, getEnum, getEnum`

- ## Constructor Details

  - ### EnvironmentConfiguration

    public EnvironmentConfiguration()
    Create a Configuration based on the environment variables.
    See Also:
      - `System.getenv()`

- ## Method Details

  - ### addPropertyDirect

    protected void addPropertyDirect(String key, 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

  - ### clearInternal

    protected void clearInternal()
    Removes all properties from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
    Overrides:
      `clearInternal` in class `AbstractConfiguration`

  - ### clearPropertyDirect

    protected void clearPropertyDirect(String key)
    Removes a property from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
    Overrides:
      `clearPropertyDirect` in class `MapConfiguration`
    Parameters:
      `key` - the key of the property to be removed