org.apache.commons.digester

Class NodeCreateRule.NodeBuilder

private class NodeCreateRule.NodeBuilder extends DefaultHandler

The SAX content handler that does all the actual work of assembling the DOM node tree from the SAX events.
Field Summary
protected intdepth
Depth of the current node, relative to the element where the content handler was put into action.
protected Documentdoc
A DOM Document used to create the various Node instances.
protected ContentHandleroldContentHandler
The content handler used by Digester before it was set to this content handler.
protected Noderoot
The DOM node that will be pushed on Digester's stack.
protected Nodetop
The current top DOM mode.
Constructor Summary
NodeBuilder(Document doc, Node root)
Constructor.
Method Summary
voidcharacters(char[] ch, int start, int length)
Appends a {@link org.w3c.dom.Text Text} node to the current node.
voidendElement(String namespaceURI, String localName, String qName)
Checks whether control needs to be returned to Digester.
voidprocessingInstruction(String target, String data)
Adds a new {@link org.w3c.dom.ProcessingInstruction ProcessingInstruction} to the current node.
voidstartElement(String namespaceURI, String localName, String qName, Attributes atts)
Adds a new child {@link org.w3c.dom.Element Element} to the current node.

Field Detail

depth

protected int depth
Depth of the current node, relative to the element where the content handler was put into action.

doc

protected Document doc
A DOM Document used to create the various Node instances.

oldContentHandler

protected ContentHandler oldContentHandler
The content handler used by Digester before it was set to this content handler.

root

protected Node root
The DOM node that will be pushed on Digester's stack.

top

protected Node top
The current top DOM mode.

Constructor Detail

NodeBuilder

public NodeBuilder(Document doc, Node root)
Constructor.

Stores the content handler currently used by Digester so it can be reset when done, and initializes the DOM objects needed to build the node.

Parameters: doc the document to use to create nodes root the root node

Throws: ParserConfigurationException if the DocumentBuilderFactory could not be instantiated SAXException if the XMLReader could not be instantiated by Digester (should not happen)

Method Detail

characters

public void characters(char[] ch, int start, int length)
Appends a {@link org.w3c.dom.Text Text} node to the current node.

Parameters: ch the characters from the XML document start the start position in the array length the number of characters to read from the array

Throws: SAXException if the DOM implementation throws an exception

endElement

public void endElement(String namespaceURI, String localName, String qName)
Checks whether control needs to be returned to Digester.

Parameters: namespaceURI the namespace URI localName the local name qName the qualified (prefixed) name

Throws: SAXException if the DOM implementation throws an exception

processingInstruction

public void processingInstruction(String target, String data)
Adds a new {@link org.w3c.dom.ProcessingInstruction ProcessingInstruction} to the current node.

Parameters: target the processing instruction target data the processing instruction data, or null if none was supplied

Throws: SAXException if the DOM implementation throws an exception

startElement

public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
Adds a new child {@link org.w3c.dom.Element Element} to the current node.

Parameters: namespaceURI the namespace URI localName the local name qName the qualified (prefixed) name atts the list of attributes

Throws: SAXException if the DOM implementation throws an exception

Copyright 2001-2005 The Apache Software Foundation.