org.apache.commons.digester

Class NodeCreateRule.NodeBuilder

Enclosing Class:
NodeCreateRule

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 int
depth
Depth of the current node, relative to the element where the content handler was put into action.
protected Document
doc
A DOM Document used to create the various Node instances.
protected ContentHandler
oldContentHandler
The content handler used by Digester before it was set to this content handler.
protected Node
root
The DOM node that will be pushed on Digester's stack.
protected Node
top
The current top DOM mode.

Constructor Summary

NodeBuilder(Document doc, Node root)
Constructor.

Method Summary

void
characters(char[] ch, int start, int length)
Appends a Text node to the current node.
void
endElement(String namespaceURI, String localName, String qName)
Checks whether control needs to be returned to Digester.
void
processingInstruction(String target, String data)
Adds a new ProcessingInstruction to the current node.
void
startElement(String namespaceURI, String localName, String qName, Attributes atts)
Adds a new child Element to the current node.

Field Details

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 Details

NodeBuilder

public NodeBuilder(Document doc,
                   Node root)
            throws ParserConfigurationException,
                   SAXException
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

Method Details

characters

public void characters(char[] ch,
                       int start,
                       int length)
            throws SAXException
Appends a 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

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
            throws SAXException
Checks whether control needs to be returned to Digester.
Parameters:
namespaceURI - the namespace URI
localName - the local name
qName - the qualified (prefixed) name

processingInstruction

public void processingInstruction(String target,
                                  String data)
            throws SAXException
Adds a new ProcessingInstruction to the current node.
Parameters:
target - the processing instruction target
data - the processing instruction data, or null if none was supplied

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
            throws SAXException
Adds a new child Element to the current node.
Parameters:
namespaceURI - the namespace URI
localName - the local name
qName - the qualified (prefixed) name
atts - the list of attributes

Copyright 2001-2005 The Apache Software Foundation.