| org.apache.commons.configuration.AbstractConfiguration org.apache.commons.configuration.HierarchicalConfiguration org.apache.commons.configuration.AbstractHierarchicalFileConfiguration org.apache.commons.configuration.XMLConfiguration
All known Subclasses: org.apache.commons.configuration.HierarchicalXMLConfiguration, org.apache.commons.configuration.DefaultConfigurationBuilder,
XMLConfiguration | public class XMLConfiguration extends AbstractHierarchicalFileConfiguration (Code) | | A specialized hierarchical configuration class that is able to parse XML
documents.
The parsed document will be stored keeping its structure. The class also
tries to preserve as much information from the loaded XML document as
possible, including comments and processing instructions. These will be
contained in documents created by the save() methods, too.
Like other file based configuration classes this class maintains the name
and path to the loaded configuration file. These properties can be altered
using several setter methods, but they are not modified by save()
and load() methods. If XML documents contain relative paths to
other documents (e.g. to a DTD), these references are resolved based on the
path set for this configuration.
By inheriting from
AbstractConfiguration this class
provides some extended functionaly, e.g. interpolation of property values.
Like in
PropertiesConfiguration property values can
contain delimiter characters (the comma ',' per default) and are then splitted
into multiple values. This works for XML attributes and text content of
elements as well. The delimiter can be escaped by a backslash. As an example
consider the following XML fragment:
<config>
<array>10,20,30,40</array>
<scalar>3\,1415</scalar>
<cite text="To be or not to be\, this is the question!"/>
</config>
Here the content of the array element will be splitted at
the commas, so the array key will be assigned 4 values. In the
scalar property and the text attribute of the
cite element the comma is escaped, so that no splitting is
performed.
XMLConfiguration implements the
FileConfiguration
interface and thus provides full support for loading XML documents from
different sources like files, URLs, or streams. A full description of these
features can be found in the documentation of
AbstractFileConfiguration .
since: commons-configuration 1.0 author: Jörg Schaible author: Oliver Heger version: $Revision: 513498 $, $Date: 2007-03-01 22:15:07 +0100 (Do, 01 Mrz 2007) $ |
Inner Class :class XMLNode extends Node | |
Inner Class :static class XMLBuilderVisitor extends BuilderVisitor | |
XMLConfiguration | public XMLConfiguration()(Code) | | Creates a new instance of XMLConfiguration .
|
XMLConfiguration | public XMLConfiguration(HierarchicalConfiguration c)(Code) | | Creates a new instance of XMLConfiguration and copies the
content of the passed in configuration into this object. Note that only
the data of the passed in configuration will be copied. If, for instance,
the other configuration is a XMLConfiguration , too,
things like comments or processing instructions will be lost.
Parameters: c - the configuration to copy since: 1.4 |
XMLConfiguration | public XMLConfiguration(String fileName) throws ConfigurationException(Code) | | Creates a new instance of XMLConfiguration . The
configuration is loaded from the specified file
Parameters: fileName - the name of the file to load throws: ConfigurationException - if the file cannot be loaded |
XMLConfiguration | public XMLConfiguration(File file) throws ConfigurationException(Code) | | Creates a new instance of XMLConfiguration .
The configuration is loaded from the specified file.
Parameters: file - the file throws: ConfigurationException - if an error occurs while loading the file |
XMLConfiguration | public XMLConfiguration(URL url) throws ConfigurationException(Code) | | Creates a new instance of XMLConfiguration .
The configuration is loaded from the specified URL.
Parameters: url - the URL throws: ConfigurationException - if loading causes an error |
clear | public void clear()(Code) | | Removes all properties from this configuration. If this configuration
was loaded from a file, the associated DOM document is also cleared.
|
clone | public Object clone()(Code) | | Creates a copy of this object. The new configuration object will contain
the same properties as the original, but it will lose any connection to a
source document (if one exists). This is to avoid race conditions if both
the original and the copy are modified and then saved.
the copy |
createDelegate | protected FileConfigurationDelegate createDelegate()(Code) | | Creates the file configuration delegate for this object. This implementation
will return an instance of a class derived from FileConfigurationDelegate
that deals with some specialities of XMLConfiguration .
the delegate for this object |
createDocumentBuilder | protected DocumentBuilder createDocumentBuilder() throws ParserConfigurationException(Code) | | Creates the DocumentBuilder to be used for loading files.
This implementation checks whether a specific
DocumentBuilder has been set. If this is the case, this
one is used. Otherwise a default builder is created. Depending on the
value of the validating flag this builder will be a validating or a non
validating DocumentBuilder .
the DocumentBuilder for loading configurationfiles throws: ParserConfigurationException - if an error occurs since: 1.2 |
createNode | protected Node createNode(String name)(Code) | | Creates a new node object. This implementation returns an instance of the
XMLNode class.
Parameters: name - the node's name the new node |
createTransformer | protected Transformer createTransformer() throws TransformerException(Code) | | Creates and initializes the transformer used for save operations. This
base implementation initializes all of the default settings like
indention mode and the DOCTYPE. Derived classes may overload this method
if they have specific needs.
the transformer to use for a save operation throws: TransformerException - if an error occurs since: 1.3 |
getDocument | public Document getDocument()(Code) | | Returns the XML document this configuration was loaded from. The return
value is null if this configuration was not loaded from a XML
document.
the XML document this configuration was loaded from |
getDocumentBuilder | public DocumentBuilder getDocumentBuilder()(Code) | | Returns the DocumentBuilder object that is used for
loading documents. If no specific builder has been set, this method
returns null.
the DocumentBuilder for loading new documents since: 1.2 |
getPublicID | public String getPublicID()(Code) | | Returns the public ID of the DOCTYPE declaration from the loaded XML
document. This is null if no document has been loaded yet or if
the document does not contain a DOCTYPE declaration with a public ID.
the public ID since: 1.3 |
getRootElementName | public String getRootElementName()(Code) | | Returns the name of the root element. If this configuration was loaded
from a XML document, the name of this document's root element is
returned. Otherwise it is possible to set a name for the root element
that will be used when this configuration is stored.
the name of the root element |
getSystemID | public String getSystemID()(Code) | | Returns the system ID of the DOCTYPE declaration from the loaded XML
document. This is null if no document has been loaded yet or if
the document does not contain a DOCTYPE declaration with a system ID.
the system ID since: 1.3 |
initProperties | public void initProperties(Document document, boolean elemRefs)(Code) | | Initializes this configuration from an XML document.
Parameters: document - the document to be parsed Parameters: elemRefs - a flag whether references to the XML elements should be set |
isValidating | public boolean isValidating()(Code) | | Returns the value of the validating flag.
the validating flag since: 1.2 |
load | public void load(Reader in) throws ConfigurationException(Code) | | Load the configuration 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.
Parameters: in - An InputStream. throws: ConfigurationException - if an error occurs |
setDocumentBuilder | public void setDocumentBuilder(DocumentBuilder documentBuilder)(Code) | | Sets the DocumentBuilder object to be used for loading
documents. This method makes it possible to specify the exact document
builder. So an application can create a builder, configure it for its
special needs, and then pass it to this method.
Parameters: documentBuilder - the document builder to be used; if undefined, adefault builder will be used since: 1.2 |
setPublicID | public void setPublicID(String publicID)(Code) | | Sets the public ID of the DOCTYPE declaration. When this configuration is
saved, a DOCTYPE declaration will be constructed that contains this
public ID.
Parameters: publicID - the public ID since: 1.3 |
setRootElementName | public void setRootElementName(String name)(Code) | | Sets the name of the root element. This name is used when this
configuration object is stored in an XML file. Note that setting the name
of the root element works only if this configuration has been newly
created. If the configuration was loaded from an XML file, the name
cannot be changed and an UnsupportedOperationException
exception is thrown. Whether this configuration has been loaded from an
XML document or not can be found out using the getDocument()
method.
Parameters: name - the name of the root element |
setSystemID | public void setSystemID(String systemID)(Code) | | Sets the system ID of the DOCTYPE declaration. When this configuration is
saved, a DOCTYPE declaration will be constructed that contains this
system ID.
Parameters: systemID - the system ID since: 1.3 |
setValidating | public void setValidating(boolean validating)(Code) | | Sets the value of the validating flag. This flag determines whether
DTD validation should be performed when loading XML documents. This
flag is evaluated only if no custom DocumentBuilder was set.
Parameters: validating - the validating flag since: 1.2 |
Fields inherited from org.apache.commons.configuration.HierarchicalConfiguration | final public static int EVENT_ADD_NODES(Code)(Java Doc) final public static int EVENT_CLEAR_TREE(Code)(Java Doc)
|
Methods inherited from org.apache.commons.configuration.AbstractConfiguration | public void addErrorLogListener()(Code)(Java Doc) public void addProperty(String key, Object value)(Code)(Java Doc) abstract protected void addPropertyDirect(String key, Object value)(Code)(Java Doc) public void clear()(Code)(Java Doc) public void clearProperty(String key)(Code)(Java Doc) protected void clearPropertyDirect(String key)(Code)(Java Doc) abstract public boolean containsKey(String key)(Code)(Java Doc) protected ConfigurationInterpolator createInterpolator()(Code)(Java Doc) public BigDecimal getBigDecimal(String key)(Code)(Java Doc) public BigDecimal getBigDecimal(String key, BigDecimal defaultValue)(Code)(Java Doc) public BigInteger getBigInteger(String key)(Code)(Java Doc) public BigInteger getBigInteger(String key, BigInteger defaultValue)(Code)(Java Doc) public boolean getBoolean(String key)(Code)(Java Doc) public boolean getBoolean(String key, boolean defaultValue)(Code)(Java Doc) public Boolean getBoolean(String key, Boolean defaultValue)(Code)(Java Doc) public byte getByte(String key)(Code)(Java Doc) public byte getByte(String key, byte defaultValue)(Code)(Java Doc) public Byte getByte(String key, Byte defaultValue)(Code)(Java Doc) public static char getDefaultListDelimiter()(Code)(Java Doc) public static char getDelimiter()(Code)(Java Doc) public double getDouble(String key)(Code)(Java Doc) public double getDouble(String key, double defaultValue)(Code)(Java Doc) public Double getDouble(String key, Double defaultValue)(Code)(Java Doc) public float getFloat(String key)(Code)(Java Doc) public float getFloat(String key, float defaultValue)(Code)(Java Doc) public Float getFloat(String key, Float defaultValue)(Code)(Java Doc) public int getInt(String key)(Code)(Java Doc) public int getInt(String key, int defaultValue)(Code)(Java Doc) public Integer getInteger(String key, Integer defaultValue)(Code)(Java Doc) public ConfigurationInterpolator getInterpolator()(Code)(Java Doc) abstract public Iterator getKeys()(Code)(Java Doc) public Iterator getKeys(String prefix)(Code)(Java Doc) public List getList(String key)(Code)(Java Doc) public List getList(String key, List defaultValue)(Code)(Java Doc) public char getListDelimiter()(Code)(Java Doc) public Log getLogger()(Code)(Java Doc) public long getLong(String key)(Code)(Java Doc) public long getLong(String key, long defaultValue)(Code)(Java Doc) public Long getLong(String key, Long defaultValue)(Code)(Java Doc) public Properties getProperties(String key)(Code)(Java Doc) public Properties getProperties(String key, Properties defaults)(Code)(Java Doc) public short getShort(String key)(Code)(Java Doc) public short getShort(String key, short defaultValue)(Code)(Java Doc) public Short getShort(String key, Short defaultValue)(Code)(Java Doc) public String getString(String key)(Code)(Java Doc) public String getString(String key, String defaultValue)(Code)(Java Doc) public String[] getStringArray(String key)(Code)(Java Doc) public synchronized StrSubstitutor getSubstitutor()(Code)(Java Doc) protected String interpolate(String base)(Code)(Java Doc) protected Object interpolate(Object value)(Code)(Java Doc) protected String interpolateHelper(String base, List priorVariables)(Code)(Java Doc) public boolean isDelimiterParsingDisabled()(Code)(Java Doc) abstract public boolean isEmpty()(Code)(Java Doc) public boolean isThrowExceptionOnMissing()(Code)(Java Doc) protected Object resolveContainerStore(String key)(Code)(Java Doc) public static void setDefaultListDelimiter(char delimiter)(Code)(Java Doc) public static void setDelimiter(char delimiter)(Code)(Java Doc) public void setDelimiterParsingDisabled(boolean delimiterParsingDisabled)(Code)(Java Doc) public void setListDelimiter(char listDelimiter)(Code)(Java Doc) public void setLogger(Log log)(Code)(Java Doc) public void setProperty(String key, Object value)(Code)(Java Doc) public void setThrowExceptionOnMissing(boolean throwExceptionOnMissing)(Code)(Java Doc) public Configuration subset(String prefix)(Code)(Java Doc)
|
|
|