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
Class XMLConfiguration

    java.lang.Object
      org.apache.commons.configuration.AbstractConfiguration
          org.apache.commons.configuration.BaseConfiguration
              org.apache.commons.configuration.AbstractFileConfiguration
                  org.apache.commons.configuration.XMLConfiguration

All Implemented Interfaces:
  Configuration, FileConfiguration

public class XMLConfiguration
extends AbstractFileConfiguration

Reads a XML configuration file. To retrieve the value of an attribute of an element, use `X.Y.Z[@attribute]`. The '@' symbol was chosen for consistency with XPath. Setting property values will NOT automatically persist changes to disk, unless `autoSave=true`.

Since:
  commons-configuration 1.0
Version:
  $Revision: 1.17 $, $Date: 2004/10/04 19:35:45 $
Author:
  J�rg Schaible, Kelvin Tan , Daniel Rall , Emmanuel Bourg

Nested Class Summary

Nested classes inherited from class org.apache.commons.configuration.AbstractConfiguration
`AbstractConfiguration.PropertiesTokenizer`

Field Summary

Fields inherited from class org.apache.commons.configuration.AbstractFileConfiguration
`basePath, fileName, url`

Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
`END_TOKEN, START_TOKEN`

Constructor Summary
`XMLConfiguration()` Creates an empty XML configuration.
`XMLConfiguration(File file)` Creates and loads the XML configuration from the specified file.
`XMLConfiguration(String resource)` Creates and loads the XML configuration from the specified resource.
`XMLConfiguration(URL url)` Creates and loads the XML configuration from the specified URL.

Method Summary
`void` | `addProperty(String name, Object value)` Calls super method, and also ensures the underlying is modified so changes are persisted when saved.
`void` | `clearProperty(String name)` Calls super method, and also ensures the underlying `Document`is modified so changes are persisted when saved.
`(package private) Object` | `getXmlProperty(String name)`
`void` | `load(Reader in)` Load the configuration from the specified reader.
`protected static String` | `parseAttributeName(String key)` Parse a property key and return the attribute name if it existst.
`protected static String[]` | `parseElementNames(String key)` Parse a property key and return an array of the element hierarchy it specifies.
`void` | `save(Writer writer)` Save the configuration to the specified writer.
`void` | `setAutoSave(boolean autoSave)` If true, changes are automatically persisted.
`String` | `toString()`

Methods inherited from class org.apache.commons.configuration.AbstractFileConfiguration
`getBasePath, getFile, getFileName, getURL, load, load, load, load, load, load, save, save, save, save, save, save, setBasePath, setFile, setFileName, setURL`

Methods inherited from class org.apache.commons.configuration.BaseConfiguration
`addPropertyDirect, containsKey, getKeys, getPropertyDirect, isEmpty`

Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
`getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getVector, getVector, interpolate, interpolateHelper, isThrowExceptionOnMissing, setDelimiter, setProperty, setThrowExceptionOnMissing, split, subset`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.apache.commons.configuration.Configuration
`containsKey, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getVector, getVector, isEmpty, setProperty, subset`

Constructor Detail

### XMLConfiguration

    public XMLConfiguration()

  Creates an empty XML configuration.

### XMLConfiguration

    public XMLConfiguration(String resource)
                     throws ConfigurationException

  Creates and loads the XML configuration from the specified resource.

Parameters:
  `resource` - The name of the resource to load.
Throws:
  `ConfigurationException` - Error while loading the XML file

### XMLConfiguration

    public XMLConfiguration(File file)
                     throws ConfigurationException

  Creates and loads the XML configuration from the specified file.

Parameters:
  `file` - The XML file to load.
Throws:
  `ConfigurationException` - Error while loading the XML file

### XMLConfiguration

    public XMLConfiguration(URL url)
                     throws ConfigurationException

  Creates and loads the XML configuration from the specified URL.

Parameters:
  `url` - The location of the XML file to load.
Throws:
  `ConfigurationException` - Error while loading the XML file

Method Detail

### load

    public void load(Reader in)
              throws ConfigurationException

  Load the configuration from the specified reader.

  Parameters:
    `in` - the reader
  Throws:
    `ConfigurationException`

### addProperty

    public void addProperty(String name,
                            Object value)

  Calls super method, and also ensures the underlying is modified so changes are persisted when saved.

  Specified by:
    `addProperty` in interface `Configuration`
  Overrides:
    `addProperty` in class `AbstractConfiguration`
  Parameters:
    `name` -
    `value` -

### getXmlProperty

    Object getXmlProperty(String name)

### clearProperty

    public void clearProperty(String name)

  Calls super method, and also ensures the underlying `Document`is modified so changes are persisted when saved.

  Specified by:
    `clearProperty` in interface `Configuration`
  Overrides:
    `clearProperty` in class `BaseConfiguration`
  Parameters:
    `name` - The name of the property to clear.

### setAutoSave

    public void setAutoSave(boolean autoSave)

  If true, changes are automatically persisted.

  Parameters:
    `autoSave` -

### save

    public void save(Writer writer)
              throws ConfigurationException

  Save the configuration to the specified writer.

  Parameters:
    `writer` - the writer
  Throws:
    `ConfigurationException`

### toString

    public String toString()

### parseElementNames

    protected static String[] parseElementNames(String key)

  Parse a property key and return an array of the element hierarchy it specifies. For example the key "x.y.z[@abc]" will result in [x, y, z].

  Parameters:
    `key` - the key to parse
  Returns:
    the elements in the key

### parseAttributeName

    protected static String parseAttributeName(String key)

  Parse a property key and return the attribute name if it existst.

  Parameters:
    `key` - the key to parse
  Returns:
    the attribute name, or null if the key doesn't contain one

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.