org.apache.commons.configuration2

## Class BaseConfiguration

- java.lang.Object
- - org.apache.commons.configuration2.event.BaseEventSource
  - - org.apache.commons.configuration2.AbstractConfiguration
    - - org.apache.commons.configuration2.BaseConfiguration

- All Implemented Interfaces:
    Cloneable, Configuration, EventSource, ImmutableConfiguration, SynchronizerSupport
  Direct Known Subclasses:
    PropertiesConfiguration, XMLPropertiesConfiguration

      public class BaseConfiguration
      extends AbstractConfiguration
      implements Cloneable

  Basic configuration class. Stores the configuration data but does not provide any load or save functions. If you want to load your Configuration from a file use PropertiesConfiguration or XmlConfiguration. This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them.
  Version:
    $Id: BaseConfiguration.java 1643922 2014-12-08 21:04:49Z oheger $
  Author:
    Stefano Mazzocchi, Jon S. Stevens, Dave Bryson, Geir Magnusson Jr., Leon Messerschmidt, Kent Johnson, Daniel Rall, Ilkka Priha, Jason van Zyl, Martin Poeschl, Henning P. Schmiedehausen, Konstantin Shaposhnikov

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseConfiguration()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addPropertyDirect(String key, Object value)` Adds a key/value pair to the map.
    `protected void` | `clearInternal()` Clears the whole configuration.
    `protected void` | `clearPropertyDirect(String key)` Clear a property in the configuration.
    `Object` | `clone()` Creates a copy of this object.
    `protected boolean` | `containsKeyInternal(String key)` check if the configuration contains the key
    `protected Iterator<String>` | `getKeysInternal()` Get the list of the keys contained in the configuration repository.
    `protected Object` | `getPropertyInternal(String key)` Read property from underlying map.
    `protected boolean` | `isEmptyInternal()` Check if the configuration is empty
    `protected int` | `sizeInternal()` Actually calculates the size of this configuration.

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

    - #### BaseConfiguration

          public BaseConfiguration()

  - ### Method Detail

    - #### addPropertyDirect

          protected void addPropertyDirect(String key,
                               Object value)

      Adds a key/value pair to the map. This routine does no magic morphing. It ensures the keylist is maintained
      Specified by:
        `addPropertyDirect` in class `AbstractConfiguration`
      Parameters:
        `key` - key to use for mapping
        `value` - object to store

    - #### getPropertyInternal

          protected Object getPropertyInternal(String key)

      Read property from underlying map.
      Specified by:
        `getPropertyInternal` in class `AbstractConfiguration`
      Parameters:
        `key` - key to use for mapping
      Returns:
        object associated with the given configuration key.

    - #### isEmptyInternal

          protected boolean isEmptyInternal()

      Check if the configuration is empty
      Specified by:
        `isEmptyInternal` in class `AbstractConfiguration`
      Returns:
        `true` if Configuration is empty, `false` otherwise.

    - #### containsKeyInternal

          protected boolean containsKeyInternal(String key)

      check if the configuration contains the key
      Specified by:
        `containsKeyInternal` in class `AbstractConfiguration`
      Parameters:
        `key` - the configuration key
      Returns:
        `true` if Configuration contain given key, `false` otherwise.

    - #### clearPropertyDirect

          protected void clearPropertyDirect(String key)

      Clear a property in the configuration.
      Specified by:
        `clearPropertyDirect` in class `AbstractConfiguration`
      Parameters:
        `key` - the key to remove along with corresponding value.

    - #### clearInternal

          protected void clearInternal()

      Description copied from class: `AbstractConfiguration`
      Clears the whole configuration. This method is called by `clear()` after some preparations have been made. This base implementation uses the iterator provided by `getKeys()` to remove every single property. Subclasses should override this method if there is a more efficient way of clearing the configuration.
      Overrides:
        `clearInternal` in class `AbstractConfiguration`

    - #### sizeInternal

          protected int sizeInternal()

      Actually calculates the size of this configuration. This method is called by `size()` with a read lock held. The base implementation provided here calculates the size based on the iterator returned by `getKeys()`. Sub classes which can determine the size in a more efficient way should override this method. This implementation obtains the size directly from the map used as data store. So this is a rather efficient implementation.
      Overrides:
        `sizeInternal` in class `AbstractConfiguration`
      Returns:
        the size of this configuration (i.e. the number of keys)

    - #### getKeysInternal

          protected Iterator<String> getKeysInternal()

      Get the list of the keys contained in the configuration repository.
      Specified by:
        `getKeysInternal` in class `AbstractConfiguration`
      Returns:
        An Iterator.

    - #### clone

          public Object clone()

      Creates a copy of this object. This implementation will create a deep clone, i.e. the map that stores the properties is cloned, too. So changes performed at the copy won't affect the original and vice versa.
      Overrides:
        `clone` in class `BaseEventSource`
      Returns:
        the copy
      Since:
        1.3

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