public class XMLPropertiesConfiguration extends BaseConfiguration implements FileBasedConfiguration, FileLocatorAware
<?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.Modifier and Type | Field and Description |
---|---|
static 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)
|
Constructor and Description |
---|
XMLPropertiesConfiguration()
Creates an empty XMLPropertyConfiguration object which can be
used to synthesize a new Properties file by adding values and
then saving().
|
XMLPropertiesConfiguration(Element element)
Creates and loads the xml properties from the specified DOM node.
|
Modifier and Type | Method and Description |
---|---|
String |
getHeader()
Returns the header comment of this configuration.
|
void |
initFileLocator(FileLocator locator)
Initializes this object with a
FileLocator . |
void |
load(Element element)
Parses a DOM element containing the properties.
|
void |
read(Reader in)
Reads the content of this object from the given reader.
|
void |
save(Document document,
Node parent)
Writes the configuration as child to the given DOM node
|
void |
setHeader(String header)
Sets the header comment of this configuration.
|
void |
write(Writer out)
Writes the content of this object to the given writer.
|
addPropertyDirect, clearInternal, clearPropertyDirect, clone, containsKeyInternal, getKeysInternal, getPropertyInternal, isEmptyInternal, sizeInternal
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, initLogger, installInterpolator, interpolate, interpolate, interpolatedConfiguration, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setPropertyInternal, setSynchronizer, setThrowExceptionOnMissing, size, subset, unlock
addEventListener, clearErrorListeners, clearEventListeners, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEvents
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addProperty, clear, clearProperty, getInterpolator, installInterpolator, setInterpolator, setProperty, subset
containsKey, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getDouble, getDouble, getDouble, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getKeys, getKeys, getList, getList, getList, getList, getLong, getLong, getLong, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, immutableSubset, isEmpty, size
getSynchronizer, lock, setSynchronizer, unlock
public static final String DEFAULT_ENCODING
public XMLPropertiesConfiguration()
public XMLPropertiesConfiguration(Element element) throws ConfigurationException
element
- The DOM elementConfigurationException
- Error while loading the properties filepublic String getHeader()
public void setHeader(String header)
header
- the header commentpublic void read(Reader in) throws ConfigurationException
FileBased
FileHandler
for reading data.read
in interface FileBased
in
- the readerConfigurationException
- if a non-I/O related problem occurs, e.g.
the data read does not have the expected formatpublic void load(Element element) throws ConfigurationException
element
- The DOM elementConfigurationException
- Error while interpreting the DOMpublic void write(Writer out) throws ConfigurationException
FileBased
FileHandler
for writing data.write
in interface FileBased
out
- the writerConfigurationException
- if a non-I/O related problem occurs, e.g.
the data read does not have the expected formatpublic void save(Document document, Node parent)
document
- The DOM document to add the configuration toparent
- The DOM parent nodepublic void initFileLocator(FileLocator locator)
FileLocator
. The locator is
accessed during load and save operations.initFileLocator
in interface FileLocatorAware
locator
- the associated FileLocator
Copyright © 2001–2020 The Apache Software Foundation. All rights reserved.