|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.BaseConfiguration
org.apache.commons.configuration.AbstractFileConfiguration
org.apache.commons.configuration.PropertiesConfiguration
org.apache.commons.configuration.XMLPropertiesConfiguration
public class XMLPropertiesConfiguration
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>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.
Note:Configuration objects of this type can be read concurrently
by multiple threads. However if one of these threads modifies the object,
synchronization has to be performed manually.
Nested Class Summary | |
---|---|
private class |
XMLPropertiesConfiguration.XMLPropertiesHandler
SAX Handler to parse a XML properties file. |
Nested classes/interfaces inherited from class org.apache.commons.configuration.PropertiesConfiguration |
---|
PropertiesConfiguration.PropertiesReader, PropertiesConfiguration.PropertiesWriter |
Field Summary | |
---|---|
private static java.lang.String |
DEFAULT_ENCODING
The default encoding (UTF-8 as specified by http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html) |
Fields inherited from class org.apache.commons.configuration.PropertiesConfiguration |
---|
COMMENT_CHARS |
Fields inherited from class org.apache.commons.configuration.AbstractFileConfiguration |
---|
autoSave, basePath, EVENT_RELOAD, fileName, strategy |
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration |
---|
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, 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(java.io.File file)
Creates and loads the xml properties from the specified file. |
|
XMLPropertiesConfiguration(java.lang.String fileName)
Creates and loads the xml properties from the specified file. |
|
XMLPropertiesConfiguration(java.net.URL url)
Creates and loads the xml properties from the specified URL. |
Method Summary | |
---|---|
void |
load(java.io.Reader in)
Load the properties from the given reader. |
void |
save(java.io.Writer out)
Save the configuration to the specified stream. |
private void |
writeProperty(java.io.PrintWriter out,
java.lang.String key,
java.util.List values)
Write a list property. |
private void |
writeProperty(java.io.PrintWriter out,
java.lang.String key,
java.lang.Object value)
Write a property. |
Methods inherited from class org.apache.commons.configuration.PropertiesConfiguration |
---|
clone, createLayout, getEncoding, getHeader, getInclude, getIncludesAllowed, getLayout, isCommentLine, propertyLoaded, setBasePath, setHeader, setInclude, setIncludesAllowed, setLayout, unescapeJava |
Methods inherited from class org.apache.commons.configuration.AbstractFileConfiguration |
---|
addProperty, clearProperty, containsKey, enterNoReload, exitNoReload, fireEvent, getBasePath, 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, setProperty, setReloadingStrategy, setURL |
Methods inherited from class org.apache.commons.configuration.BaseConfiguration |
---|
addPropertyDirect, clear, clearPropertyDirect |
Methods inherited from class org.apache.commons.configuration.event.EventSource |
---|
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, createErrorEvent, createEvent, fireError, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.commons.configuration.Configuration |
---|
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, subset |
Field Detail |
---|
private static final java.lang.String DEFAULT_ENCODING
Constructor Detail |
---|
public XMLPropertiesConfiguration()
public XMLPropertiesConfiguration(java.lang.String fileName) throws ConfigurationException
fileName
- The name of the properties file to load.
ConfigurationException
- Error while loading the properties filepublic XMLPropertiesConfiguration(java.io.File file) throws ConfigurationException
file
- The properties file to load.
ConfigurationException
- Error while loading the properties filepublic XMLPropertiesConfiguration(java.net.URL url) throws ConfigurationException
url
- The location of the properties file to load.
ConfigurationException
- Error while loading the properties fileMethod Detail |
---|
public void load(java.io.Reader in) throws ConfigurationException
PropertiesConfiguration
clear()
method is not called, so
the properties contained in the loaded file will be added to the
actual set of properties.
load
in interface FileConfiguration
load
in class PropertiesConfiguration
in
- An InputStream.
ConfigurationException
- if an error occurspublic void save(java.io.Writer out) throws ConfigurationException
PropertiesConfiguration
save
in interface FileConfiguration
save
in class PropertiesConfiguration
out
- the output stream used to save the configuration
ConfigurationException
- if an error occursprivate void writeProperty(java.io.PrintWriter out, java.lang.String key, java.lang.Object value)
out
- the output streamkey
- the key of the propertyvalue
- the value of the propertyprivate void writeProperty(java.io.PrintWriter out, java.lang.String key, java.util.List values)
out
- the output streamkey
- the key of the propertyvalues
- a list with all property values
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |