org.apache.commons.configuration
Class XMLConfiguration.XMLBuilderVisitor

java.lang.Object
  extended by org.apache.commons.configuration.HierarchicalConfiguration.NodeVisitor
      extended by org.apache.commons.configuration.HierarchicalConfiguration.BuilderVisitor
          extended by org.apache.commons.configuration.XMLConfiguration.XMLBuilderVisitor
Enclosing class:
XMLConfiguration

static class XMLConfiguration.XMLBuilderVisitor
extends HierarchicalConfiguration.BuilderVisitor

A concrete BuilderVisitor that can construct XML documents.


Field Summary
private  org.w3c.dom.Document document
          Stores the document to be constructed.
private  char listDelimiter
          Stores the list delimiter.
 
Constructor Summary
XMLConfiguration.XMLBuilderVisitor(org.w3c.dom.Document doc, char listDelimiter)
          Creates a new instance of XMLBuilderVisitor
 
Method Summary
private  org.w3c.dom.Element getElement(HierarchicalConfiguration.Node node)
          Helper method for accessing the element of the specified node.
protected  java.lang.Object insert(HierarchicalConfiguration.Node newNode, HierarchicalConfiguration.Node parent, HierarchicalConfiguration.Node sibling1, HierarchicalConfiguration.Node sibling2)
          Inserts a new node.
 void processDocument(HierarchicalConfiguration.Node rootNode)
          Processes the node hierarchy and adds new nodes to the document.
private static void updateAttribute(HierarchicalConfiguration.Node node, org.w3c.dom.Element elem, java.lang.String name, char listDelimiter)
          Helper method for updating the value of the specified node's attribute with the given name.
(package private) static void updateAttribute(HierarchicalConfiguration.Node node, java.lang.String name, char listDelimiter)
          Updates the value of the specified attribute of the given node.
 
Methods inherited from class org.apache.commons.configuration.HierarchicalConfiguration.BuilderVisitor
visitBeforeChildren
 
Methods inherited from class org.apache.commons.configuration.HierarchicalConfiguration.NodeVisitor
terminate, visitAfterChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

document

private org.w3c.dom.Document document
Stores the document to be constructed.


listDelimiter

private char listDelimiter
Stores the list delimiter.

Constructor Detail

XMLConfiguration.XMLBuilderVisitor

public XMLConfiguration.XMLBuilderVisitor(org.w3c.dom.Document doc,
                                          char listDelimiter)
Creates a new instance of XMLBuilderVisitor

Parameters:
doc - the document to be created
listDelimiter - the delimiter for attribute properties with multiple values
Method Detail

processDocument

public void processDocument(HierarchicalConfiguration.Node rootNode)
Processes the node hierarchy and adds new nodes to the document.

Parameters:
rootNode - the root node

insert

protected java.lang.Object insert(HierarchicalConfiguration.Node newNode,
                                  HierarchicalConfiguration.Node parent,
                                  HierarchicalConfiguration.Node sibling1,
                                  HierarchicalConfiguration.Node sibling2)
Inserts a new node. This implementation ensures that the correct XML element is created and inserted between the given siblings.

Specified by:
insert in class HierarchicalConfiguration.BuilderVisitor
Parameters:
newNode - the node to insert
parent - the parent node
sibling1 - the first sibling
sibling2 - the second sibling
Returns:
the new node

updateAttribute

private static void updateAttribute(HierarchicalConfiguration.Node node,
                                    org.w3c.dom.Element elem,
                                    java.lang.String name,
                                    char listDelimiter)
Helper method for updating the value of the specified node's attribute with the given name.

Parameters:
node - the affected node
elem - the element that is associated with this node
name - the name of the affected attribute
listDelimiter - the delimiter for attributes with multiple values

updateAttribute

static void updateAttribute(HierarchicalConfiguration.Node node,
                            java.lang.String name,
                            char listDelimiter)
Updates the value of the specified attribute of the given node. Because there can be multiple child nodes representing this attribute the new value is determined by iterating over all those child nodes.

Parameters:
node - the affected node
name - the name of the attribute
listDelimiter - the delimiter for attributes with multiple values

getElement

private org.w3c.dom.Element getElement(HierarchicalConfiguration.Node node)
Helper method for accessing the element of the specified node.

Parameters:
node - the node
Returns:
the element of this node