org.apache.commons.configuration
Class XMLPropertiesConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.AbstractConfiguration
      extended byorg.apache.commons.configuration.BaseConfiguration
          extended byorg.apache.commons.configuration.AbstractFileConfiguration
              extended byorg.apache.commons.configuration.PropertiesConfiguration
                  extended byorg.apache.commons.configuration.XMLPropertiesConfiguration
All Implemented Interfaces:
Configuration, FileConfiguration

public class XMLPropertiesConfiguration
extends PropertiesConfiguration

This configuration implements the XML properties format introduced in Java 5.0, see http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html. An XML properties file looks like this:

 <?xml version="1.0"?>
 <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
   <comment>Description of the property list</comment>
   <entry key="key1">value1</entry>
   <entry key="key2">value2</entry>
   <entry key="key3">value3</entry>
 </properties>
 </pre>

 The Java 5.0 runtime is not required to use this class. The default encoding
 for this configuration format is UTF-8. Note that unlike
 PropertiesConfiguration, XMLPropertiesConfiguration
 does not support includes.

Since:
1.1
Version:
$Revision$, $Date: 2005-02-26 13:56:39 +0100 (Sat, 26 Feb 2005) $
Author:
Emmanuel Bourg

Nested Class Summary
 
Nested classes inherited from class org.apache.commons.configuration.PropertiesConfiguration
PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter
 
Field Summary
 
Fields inherited from class org.apache.commons.configuration.AbstractFileConfiguration
autoSave, basePath, fileName, strategy
 
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, START_TOKEN
 
Constructor Summary
XMLPropertiesConfiguration()
          Creates an empty XMLPropertyConfiguration object which can be used to synthesize a new Properties file by adding values and then saving().
XMLPropertiesConfiguration(File file)
          Creates and loads the xml properties from the specified file.
XMLPropertiesConfiguration(String fileName)
          Creates and loads the xml properties from the specified file.
XMLPropertiesConfiguration(URL url)
          Creates and loads the xml properties from the specified URL.
 
Method Summary
 void load(Reader in)
          Load the properties from the given reader.
 void save(Writer out)
          Save the configuration to the specified stream.
 
Methods inherited from class org.apache.commons.configuration.PropertiesConfiguration
getHeader, getInclude, getIncludesAllowed, setBasePath, setHeader, setInclude, setIncludesAllowed, unescapeJava
 
Methods inherited from class org.apache.commons.configuration.AbstractFileConfiguration
addPropertyDirect, clearProperty, containsKey, getBasePath, getEncoding, getFile, getFileName, getKeys, getPath, getProperty, getReloadingStrategy, getURL, isAutoSave, isEmpty, load, load, load, load, load, load, possiblySave, reload, save, save, save, save, save, save, setAutoSave, setEncoding, setFile, setFileName, setPath, setReloadingStrategy, setURL
 
Methods inherited from class org.apache.commons.configuration.BaseConfiguration
clear
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addProperty, 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, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolateHelper, isThrowExceptionOnMissing, resolveContainerStore, setDelimiter, setProperty, setThrowExceptionOnMissing, subset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.configuration.Configuration
addProperty, clear, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getList, getList, getLong, getLong, getLong, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, setProperty, subset
 

Constructor Detail

XMLPropertiesConfiguration

public XMLPropertiesConfiguration()
Creates an empty XMLPropertyConfiguration object which can be used to synthesize a new Properties file by adding values and then saving(). An object constructed by this C'tor can not be tickled into loading included files because it cannot supply a base for relative includes.


XMLPropertiesConfiguration

public XMLPropertiesConfiguration(String fileName)
                           throws ConfigurationException
Creates and loads the xml properties from the specified file. The specified file can contain "include" properties which then are loaded and merged into the properties.

Parameters:
fileName - The name of the properties file to load.
Throws:
ConfigurationException - Error while loading the properties file

XMLPropertiesConfiguration

public XMLPropertiesConfiguration(File file)
                           throws ConfigurationException
Creates and loads the xml properties from the specified file. The specified file can contain "include" properties which then are loaded and merged into the properties.

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

XMLPropertiesConfiguration

public XMLPropertiesConfiguration(URL url)
                           throws ConfigurationException
Creates and loads the xml properties from the specified URL. The specified file can contain "include" properties which then are loaded and merged into the properties.

Parameters:
url - The location of the properties file to load.
Throws:
ConfigurationException - Error while loading the properties file
Method Detail

load

public void load(Reader in)
          throws ConfigurationException
Description copied from class: PropertiesConfiguration
Load the properties from the given reader. Note that the clear() method is not called, so the properties contained in the loaded file will be added to the actual set of properties.

Specified by:
load in interface FileConfiguration
Overrides:
load in class PropertiesConfiguration
Parameters:
in - An InputStream.
Throws:
ConfigurationException

save

public void save(Writer out)
          throws ConfigurationException
Description copied from class: PropertiesConfiguration
Save the configuration to the specified stream.

Specified by:
save in interface FileConfiguration
Overrides:
save in class PropertiesConfiguration
Parameters:
out - the output stream used to save the configuration
Throws:
ConfigurationException


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