| java.lang.Object net.myvietnam.mvncore.configuration.ConfigurationXMLDocument
ConfigurationXMLDocument | public class ConfigurationXMLDocument (Code) | | A helper class that supports XML-like processing for configuration
objects.
This class provides a set of methods that all have something to do with
treating a Configuration object as a XML document. So a
configuration can be transformed into a Document (either
dom4j or w3c), saved as an XML file or passed to Digester.
Implementation note: This class is not thread safe.
author: Oliver Heger version: $Id: ConfigurationXMLDocument.java,v 1.1 2003/12/09 08:25:30 huumai Exp $ |
Method Summary | |
public Object | callDigester(String prefix) Creates and initializes an object specified in the configuration
using Digester.
This method first constructs a subset configuration with the keys
starting with the given prefix. | protected Digester | createDefaultDigester(String prefix) Creates the default Digester instance for the given prefix. | public static ConfigurationXMLReader | createXMLReader(Configuration config) Returns a XMLReader object for the specified configuration
object. | public ConfigurationXMLReader | createXMLReader() Returns a XMLReader object for the actual configuration
object. | public ConfigurationXMLReader | createXMLReader(String prefix) Returns a ConfigurationXMLReader object for the subset
configuration specified by the given prefix. | public Configuration | getConfiguration() Returns the Configuration object for this document. | protected Digester | getDefaultDigester(String prefix) Returns a default Digester instance. | public Document | getDocument(String prefix, String rootName) Transforms the wrapped configuration into a dom4j document. | public Document | getDocument(String prefix) Transforms the wrapped configuration into a dom4j document. | public Document | getDocument() Transforms the wrapped configuration into a dom4j document. | public org.w3c.dom.Document | getW3cDocument(String prefix, String rootName) Transforms the wrapped configuration into a w3c document. | public org.w3c.dom.Document | getW3cDocument(String prefix) Transforms the wrapped configuration into a w3c document. | public org.w3c.dom.Document | getW3cDocument() Transforms the wrapped configuration into a w3c document. | public void | setConfiguration(Configuration configuration) Sets the Configuration object this document operates on. | protected void | setupDefaultDigester(Digester digester) Initializes the default digester instance used for simple object
creation. | static org.w3c.dom.Document | toW3cDocument(Document doc) Converts a dom4j document into a w3c document. | public void | write(Writer out, String prefix, String root, boolean pretty) Writes a configuration (or parts of it) to the given writer. | public void | write(Writer out, String prefix, String root) Writes a configuration (or parts of it) to the given writer. | public void | write(Writer out, String prefix, boolean pretty) Writes a configuration (or parts of it) to the given writer. | public void | write(Writer out, String prefix) Writes a configuration (or parts of it) to the given writer. | public void | write(Writer out, boolean pretty) Writes the wrapped configuration to the given writer. | public void | write(Writer out) Writes the wrapped configuration to the given writer. |
ATTR_NAME | final protected static String ATTR_NAME(Code) | | Constant for the name attribute.
|
ATTR_VALUE | final protected static String ATTR_VALUE(Code) | | Constant for the value attribute.
|
ELEM_CLASS | final protected static String ELEM_CLASS(Code) | | Constant for the class element.
|
ELEM_PROPERTY | final protected static String ELEM_PROPERTY(Code) | | Constant for the property element.
|
ConfigurationXMLDocument | public ConfigurationXMLDocument(Configuration config)(Code) | | Creates a new instance of ConfigurationXMLDocument
and sets the configuration object to be processed.
Parameters: config - the configuration object |
callDigester | public Object callDigester(String prefix) throws IOException, SAXException(Code) | | Creates and initializes an object specified in the configuration
using Digester.
This method first constructs a subset configuration with the keys
starting with the given prefix. It then transforms this subset into a
XML document and let that be processed by Digester. The result of this
processing is returned.
The method is intended to be used for creating simple objects that
are specified somewhere in the configuration in a standard way. The
following fragment shows how a configuration file must look like to be
understood by the default Digester rule set used by this method:
...
<class name="mypackage.MyClass"/>
<args>
<property name="myFirstProperty" value="myFirstValue"/>
<property name="MySecondProperty" value="mySecondValue"/>
...
</args>
...
Parameters: prefix - the prefix of the keys that are passed to Digester; canbe null, then the whole configuration will be processed the result of the Digester processing throws: IOException - if an IOException occurs throws: SAXException - if a SAXException occurs |
createDefaultDigester | protected Digester createDefaultDigester(String prefix)(Code) | | Creates the default Digester instance for the given prefix. This method
is called by getDefaultDigester() .
Parameters: prefix - the prefix of the keys to be processed; can benull, then the whole configuration is meant the default Digester instance |
createXMLReader | public static ConfigurationXMLReader createXMLReader(Configuration config)(Code) | | Returns a XMLReader object for the specified configuration
object. This reader can then be used to perform XML-like processing on
the configuration.
Parameters: config - the configuration object a XMLReader for this configuration |
createXMLReader | public ConfigurationXMLReader createXMLReader()(Code) | | Returns a XMLReader object for the actual configuration
object.
a XMLReader for the actual configuration |
createXMLReader | public ConfigurationXMLReader createXMLReader(String prefix)(Code) | | Returns a ConfigurationXMLReader object for the subset
configuration specified by the given prefix. If no properties are found
under this prefix, a NoSuchElementException
exception will be thrown.
Parameters: prefix - the prefix of the configuration keys that belong to thesubset; can be null, then the whole configuration is affected a XMLReader for the specified subset configuration |
getConfiguration | public Configuration getConfiguration()(Code) | | Returns the Configuration object for this document.
the Configuration object |
getDefaultDigester | protected Digester getDefaultDigester(String prefix)(Code) | | Returns a default Digester instance. This instance is used for the
simple object creation feature.
Parameters: prefix - the prefix of the keys to be processed; can benull, then the whole configuration is meant the default Digester instance |
getDocument | public Document getDocument(String prefix, String rootName) throws DocumentException(Code) | | Transforms the wrapped configuration into a dom4j document.
Parameters: prefix - a prefix for the keys to process; can be null,then all keys in the configuration will be added to the document Parameters: rootName - the name of the root element in the document; can benull, then a default name will be used the document throws: DocumentException - if an error occurs |
getDocument | public Document getDocument(String prefix) throws DocumentException(Code) | | Transforms the wrapped configuration into a dom4j document. The root
element will be given a default name.
Parameters: prefix - a prefix for the keys to process; can be null,then all keys in the configuration will be added to the document the document throws: DocumentException - if an error occurs |
getDocument | public Document getDocument() throws DocumentException(Code) | | Transforms the wrapped configuration into a dom4j document. The root
element will be given a default name.
the document throws: DocumentException - if an error occurs |
getW3cDocument | public org.w3c.dom.Document getW3cDocument(String prefix, String rootName) throws DocumentException(Code) | | Transforms the wrapped configuration into a w3c document.
Parameters: prefix - a prefix for the keys to process; can be null,then all keys in the configuration will be added to the document Parameters: rootName - the name of the root element in the document; can benull, then a default name will be used the document throws: DocumentException - if an error occurs |
getW3cDocument | public org.w3c.dom.Document getW3cDocument(String prefix) throws DocumentException(Code) | | Transforms the wrapped configuration into a w3c document. The root
element will be given a default name.
Parameters: prefix - a prefix for the keys to process; can be null,then all keys in the configuration will be added to the document the document throws: DocumentException - if an error occurs |
getW3cDocument | public org.w3c.dom.Document getW3cDocument() throws DocumentException(Code) | | Transforms the wrapped configuration into a w3c document. The root
element will be given a default name.
the document throws: DocumentException - if an error occurs |
setConfiguration | public void setConfiguration(Configuration configuration)(Code) | | Sets the Configuration object this document operates on.
Parameters: configuration - the Configuration object |
setupDefaultDigester | protected void setupDefaultDigester(Digester digester)(Code) | | Initializes the default digester instance used for simple object
creation. Here all needed properties and rules can be set. This base
implementation sets default rules for object creation as explained in
the comment for the callDigester() methods.
Parameters: digester - the digester instance to be initialized |
toW3cDocument | static org.w3c.dom.Document toW3cDocument(Document doc) throws DocumentException(Code) | | Converts a dom4j document into a w3c document.
Parameters: doc - the dom4j document the w3c document throws: DocumentException - if an error occurs |
write | public void write(Writer out, String prefix, String root, boolean pretty) throws IOException, DocumentException(Code) | | Writes a configuration (or parts of it) to the given writer.
Parameters: out - the output writer Parameters: prefix - the prefix of the subset to write; if null, thewhole configuration is written Parameters: root - the name of the root element of the resulting document;null for a default name Parameters: pretty - flag for the pretty print mode throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
write | public void write(Writer out, String prefix, String root) throws IOException, DocumentException(Code) | | Writes a configuration (or parts of it) to the given writer.
This overloaded version always uses pretty print mode.
Parameters: out - the output writer Parameters: prefix - the prefix of the subset to write; if null, thewhole configuration is written Parameters: root - the name of the root element of the resulting document;null for a default name throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
write | public void write(Writer out, String prefix, boolean pretty) throws IOException, DocumentException(Code) | | Writes a configuration (or parts of it) to the given writer.
The resulting document's root element will be given a default name.
Parameters: out - the output writer Parameters: prefix - the prefix of the subset to write; if null, thewhole configuration is written Parameters: pretty - flag for the pretty print mode throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
write | public void write(Writer out, String prefix) throws IOException, DocumentException(Code) | | Writes a configuration (or parts of it) to the given writer.
The resulting document's root element will be given a default name.
This overloaded version always uses pretty print mode.
Parameters: out - the output writer Parameters: prefix - the prefix of the subset to write; if null, thewhole configuration is written throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
write | public void write(Writer out, boolean pretty) throws IOException, DocumentException(Code) | | Writes the wrapped configuration to the given writer.
The resulting document's root element will be given a default name.
Parameters: out - the output writer Parameters: pretty - flag for the pretty print mode throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
write | public void write(Writer out) throws IOException, DocumentException(Code) | | Writes the wrapped configuration to the given writer.
The resulting document's root element will be given a default name.
This overloaded version always uses pretty print mode.
Parameters: out - the output writer throws: IOException - if an IO error occurs throws: DocumentException - if there is an error during processing |
|
|