org.apache.commons.configuration

Class XMLConfiguration.XMLBuilderVisitor

static class XMLConfiguration.XMLBuilderVisitor extends BuilderVisitor

A concrete BuilderVisitor that can construct XML documents.
Field Summary
Documentdocument
Stores the document to be constructed.
charlistDelimiter
Stores the list delimiter.
Constructor Summary
XMLBuilderVisitor(Document doc, char listDelimiter)
Creates a new instance of XMLBuilderVisitor
Method Summary
ElementgetElement(Node node)
Helper method for accessing the element of the specified node.
protected Objectinsert(Node newNode, Node parent, Node sibling1, Node sibling2)
Inserts a new node.
voidprocessDocument(Node rootNode)
Processes the node hierarchy and adds new nodes to the document.
static voidupdateAttribute(Node node, Element elem, String name, char listDelimiter)
Helper method for updating the value of the specified node's attribute with the given name.
static voidupdateAttribute(Node node, String name, char listDelimiter)
Updates the value of the specified attribute of the given node.

Field Detail

document

private Document document
Stores the document to be constructed.

listDelimiter

private char listDelimiter
Stores the list delimiter.

Constructor Detail

XMLBuilderVisitor

public XMLBuilderVisitor(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

getElement

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

Parameters: node the node

Returns: the element of this node

insert

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

Parameters: newNode the node to insert parent the parent node sibling1 the first sibling sibling2 the second sibling

Returns: the new node

processDocument

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

Parameters: rootNode the root node

updateAttribute

private static void updateAttribute(Node node, Element elem, 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 vor attributes with multiple values

updateAttribute

static void updateAttribute(Node node, 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 vor attributes with multiple values