Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.configuration
Interface Configuration

All Known Subinterfaces:
  FileConfiguration

All Known Implementing Classes:
  AbstractConfiguration, AbstractFileConfiguration, HierarchicalXMLConfiguration

public interface Configuration

Configuration interface.

Version:
  $Id: Configuration.java,v 1.10 2004/08/16 22:16:31 henning Exp $

Method Summary
`void` | `addProperty(String key, Object value)` Add a property to the configuration.
`void` | `clearProperty(String key)` Remove a property from the configuration.
`boolean` | `containsKey(String key)` Check if the configuration contains the specified key.
`BigDecimal` | `getBigDecimal(String key)` Get a `BigDecimal` associated with the given configuration key.
`BigDecimal` | `getBigDecimal(String key, BigDecimal defaultValue)` Get a `BigDecimal` associated with the given configuration key.
`BigInteger` | `getBigInteger(String key)` Get a `BigInteger` associated with the given configuration key.
`BigInteger` | `getBigInteger(String key, BigInteger defaultValue)` Get a `BigInteger` associated with the given configuration key.
`boolean` | `getBoolean(String key)` Get a boolean associated with the given configuration key.
`boolean` | `getBoolean(String key, boolean defaultValue)` Get a boolean associated with the given configuration key.
`Boolean` | `getBoolean(String key, Boolean defaultValue)` Get a `Boolean` associated with the given configuration key.
`byte` | `getByte(String key)` Get a byte associated with the given configuration key.
`byte` | `getByte(String key, byte defaultValue)` Get a byte associated with the given configuration key.
`Byte` | `getByte(String key, Byte defaultValue)` Get a `Byte` associated with the given configuration key.
`double` | `getDouble(String key)` Get a double associated with the given configuration key.
`double` | `getDouble(String key, double defaultValue)` Get a double associated with the given configuration key.
`Double` | `getDouble(String key, Double defaultValue)` Get a `Double` associated with the given configuration key.
`float` | `getFloat(String key)` Get a float associated with the given configuration key.
`float` | `getFloat(String key, float defaultValue)` Get a float associated with the given configuration key.
`Float` | `getFloat(String key, Float defaultValue)` Get a `Float` associated with the given configuration key.
`int` | `getInt(String key)` Get a int associated with the given configuration key.
`int` | `getInt(String key, int defaultValue)` Get a int associated with the given configuration key.
`Integer` | `getInteger(String key, Integer defaultValue)` Get an `Integer` associated with the given configuration key.
`Iterator` | `getKeys()` Get the list of the keys contained in the configuration.
`Iterator` | `getKeys(String prefix)` Get the list of the keys contained in the configuration that match the specified prefix.
`List` | `getList(String key)` Get a List of strings associated with the given configuration key.
`List` | `getList(String key, List defaultValue)` Get a List of strings associated with the given configuration key.
`long` | `getLong(String key)` Get a long associated with the given configuration key.
`long` | `getLong(String key, long defaultValue)` Get a long associated with the given configuration key.
`Long` | `getLong(String key, Long defaultValue)` Get a `Long` associated with the given configuration key.
`Properties` | `getProperties(String key)` Get a list of properties associated with the given configuration key.
`Object` | `getProperty(String key)` Gets a property from the configuration.
`short` | `getShort(String key)` Get a short associated with the given configuration key.
`short` | `getShort(String key, short defaultValue)` Get a short associated with the given configuration key.
`Short` | `getShort(String key, Short defaultValue)` Get a `Short` associated with the given configuration key.
`String` | `getString(String key)` Get a string associated with the given configuration key.
`String` | `getString(String key, String defaultValue)` Get a string associated with the given configuration key.
`String[]` | `getStringArray(String key)` Get an array of strings associated with the given configuration key.
`Vector` | `getVector(String key)` Deprecated. This method is for compatibility with applications that use the pre-1.0 versions of commons-configuration. It will be removed post 1.0
`Vector` | `getVector(String key, Vector defaultValue)` Deprecated. This method is for compatibility with applications that use the pre-1.0 versions of commons-configuration. It will be removed post 1.0
`boolean` | `isEmpty()` Check if the configuration is empty.
`void` | `setProperty(String key, Object value)` Set a property, this will replace any previously set values.
`Configuration` | `subset(String prefix)` Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix.

Method Detail

### subset

    public Configuration subset(String prefix)

  Return a decorator Configuration containing every key from the current Configuration that starts with the specified prefix. The prefix is removed from the keys in the subset. For example, if the configuration contains the following properties:

          prefix.number = 1
          prefix.string = Apache
          prefixed.foo = bar
          prefix = Jakarta

  the Configuration returned by `subset("prefix")` will contain the properties:

          number = 1
          string = Apache
          = Jakarta

  (The key for the value "Jakarta" is an empty string)

  Since the subset is a decorator and not a modified copy of the initial Configuration, any change made to the subset is available to the Configuration, and reciprocally.

  Parameters:
    `prefix` - The prefix used to select the properties.
  See Also:
    `SubsetConfiguration`

### isEmpty

    public boolean isEmpty()

  Check if the configuration is empty.

  Returns:
    `true` if the configuration contains no property, `false` otherwise.

### containsKey

    public boolean containsKey(String key)

  Check if the configuration contains the specified key.

  Parameters:
    `key` - the key whose presence in this configuration is to be tested
  Returns:
    `true` if the configuration contains a value for this key, `false` otherwise

### addProperty

    public void addProperty(String key,
                            Object value)

  Add a property to the configuration. If it already exists then the value stated here will be added to the configuration entry. For example, if the property:

      resource.loader = file

  is already present in the configuration and you call

      addProperty("resource.loader", "classpath")

  Then you will end up with a List like the following:

      ["file", "classpath"]

  Parameters:
    `key` - The key to add the property to.
    `value` - The value to add.

### setProperty

    public void setProperty(String key,
                            Object value)

  Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).

  Parameters:
    `key` - The key of the property to change
    `value` - The new value

### clearProperty

    public void clearProperty(String key)

  Remove a property from the configuration.

  Parameters:
    `key` - the key to remove along with corresponding value.

### getProperty

    public Object getProperty(String key)

  Gets a property from the configuration.

  Parameters:
    `key` - property to retrieve
  Returns:
    the value to which this configuration maps the specified key, or null if the configuration contains no mapping for this key.

### getKeys

    public Iterator getKeys(String prefix)

  Get the list of the keys contained in the configuration that match the specified prefix.

  Parameters:
    `prefix` - The prefix to test against.
  Returns:
    An Iterator of keys that match the prefix.

### getKeys

    public Iterator getKeys()

  Get the list of the keys contained in the configuration.

  Returns:
    An Iterator.

### getProperties

    public Properties getProperties(String key)

  Get a list of properties associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated properties if key is found.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a String/List.
    `IllegalArgumentException` - if one of the tokens is malformed (does not contain an equals sign).

### getBoolean

    public boolean getBoolean(String key)

  Get a boolean associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated boolean.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Boolean.

### getBoolean

    public boolean getBoolean(String key,
                              boolean defaultValue)

  Get a boolean associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated boolean.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Boolean.

### getBoolean

    public Boolean getBoolean(String key,
                              Boolean defaultValue)
                       throws NoClassDefFoundError

  Get a `Boolean` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated boolean if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Boolean.
    `NoClassDefFoundError`

### getByte

    public byte getByte(String key)

  Get a byte associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated byte.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Byte.

### getByte

    public byte getByte(String key,
                        byte defaultValue)

  Get a byte associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated byte.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Byte.

### getByte

    public Byte getByte(String key,
                        Byte defaultValue)

  Get a `Byte` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated byte if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Byte.

### getDouble

    public double getDouble(String key)

  Get a double associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated double.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Double.

### getDouble

    public double getDouble(String key,
                            double defaultValue)

  Get a double associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated double.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Double.

### getDouble

    public Double getDouble(String key,
                            Double defaultValue)

  Get a `Double` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated double if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Double.

### getFloat

    public float getFloat(String key)

  Get a float associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated float.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Float.

### getFloat

    public float getFloat(String key,
                          float defaultValue)

  Get a float associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated float.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Float.

### getFloat

    public Float getFloat(String key,
                          Float defaultValue)

  Get a `Float` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated float if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Float.

### getInt

    public int getInt(String key)

  Get a int associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated int.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Integer.

### getInt

    public int getInt(String key,
                      int defaultValue)

  Get a int associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated int.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Integer.

### getInteger

    public Integer getInteger(String key,
                              Integer defaultValue)

  Get an `Integer` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated int if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Integer.

### getLong

    public long getLong(String key)

  Get a long associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated long.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Long.

### getLong

    public long getLong(String key,
                        long defaultValue)

  Get a long associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated long.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Long.

### getLong

    public Long getLong(String key,
                        Long defaultValue)

  Get a `Long` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated long if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Long.

### getShort

    public short getShort(String key)

  Get a short associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated short.
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.
    `ConversionException` - is thrown if the key maps to an object that is not a Short.

### getShort

    public short getShort(String key,
                          short defaultValue)

  Get a short associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated short.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Short.

### getShort

    public Short getShort(String key,
                          Short defaultValue)

  Get a `Short` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated short if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Short.
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.

### getBigDecimal

    public BigDecimal getBigDecimal(String key)

  Get a `BigDecimal` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated BigDecimal if key is found and has valid format
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.

### getBigDecimal

    public BigDecimal getBigDecimal(String key,
                                    BigDecimal defaultValue)

  Get a `BigDecimal` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated BigDecimal if key is found and has valid format, default value otherwise.

### getBigInteger

    public BigInteger getBigInteger(String key)

  Get a `BigInteger` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated BigInteger if key is found and has valid format
  Throws:
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.

### getBigInteger

    public BigInteger getBigInteger(String key,
                                    BigInteger defaultValue)

  Get a `BigInteger` associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated BigInteger if key is found and has valid format, default value otherwise.

### getString

    public String getString(String key)

  Get a string associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated string.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a String.
    `NoSuchElementException` - is thrown if the key doesn't map to an existing object.

### getString

    public String getString(String key,
                            String defaultValue)

  Get a string associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated string if key is found and has valid format, default value otherwise.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a String.

### getStringArray

    public String[] getStringArray(String key)

  Get an array of strings associated with the given configuration key. If the key doesn't map to an existing object an empty array is returned

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated string array if key is found.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a String/List of Strings.

### getList

    public List getList(String key)

  Get a List of strings associated with the given configuration key. If the key doesn't map to an existing object an empty List is returned.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated List.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a List.

### getList

    public List getList(String key,
                        List defaultValue)

  Get a List of strings associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated List.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a List.

### getVector

    public Vector getVector(String key)

  Deprecated. This method is for compatibility with applications that use the pre-1.0 versions of commons-configuration. It will be removed post 1.0

  Get a Vector of strings associated with the given configuration key. If the key doesn't map to an existing object an empty Vector is returned.

  Parameters:
    `key` - The configuration key.
  Returns:
    The associated Vector.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Vector.

### getVector

    public Vector getVector(String key,
                            Vector defaultValue)

  Deprecated. This method is for compatibility with applications that use the pre-1.0 versions of commons-configuration. It will be removed post 1.0

  Get a Vector of strings associated with the given configuration key.

  Parameters:
    `key` - The configuration key.
    `defaultValue` - The default value.
  Returns:
    The associated Vector.
  Throws:
    `ConversionException` - is thrown if the key maps to an object that is not a Vector.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.