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, e.g.:

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

  Since:
    1.5
  Version:
    $Id: EnvironmentConfiguration.java 1624601 2014-09-12 18:04:36Z oheger $
  Author:
    Nicolas De Loof

- - ### Field Summary

    - ### Fields inherited from class org.apache.commons.configuration2.MapConfiguration

      `map`

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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, getKeysInternal, getMap, getPropertyInternal, isEmptyInternal, isTrimmingDisabled, setTrimmingDisabled, sizeInternal`

    - ### Methods inherited from class org.apache.commons.configuration2.AbstractConfiguration

      `addErrorLogListener, addProperty, addPropertyInternal, append, beginRead, beginWrite, clear, clearProperty, cloneInterpolator, containsKey, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, 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, 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(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

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

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

Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.