Package org.apache.commons.digester
Class NodeCreateRule.NodeBuilder
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.apache.commons.digester.NodeCreateRule.NodeBuilder
-
- All Implemented Interfaces:
org.xml.sax.ContentHandler,org.xml.sax.DTDHandler,org.xml.sax.EntityResolver,org.xml.sax.ErrorHandler
- Enclosing class:
- NodeCreateRule
private class NodeCreateRule.NodeBuilder extends org.xml.sax.helpers.DefaultHandlerThe SAX content handler that does all the actual work of assembling the DOM node tree from the SAX events.
-
-
Field Summary
Fields Modifier and Type Field Description protected intdepthDepth of the current node, relative to the element where the content handler was put into action.protected org.w3c.dom.DocumentdocA DOM Document used to create the various Node instances.protected org.xml.sax.ContentHandleroldContentHandlerThe content handler used by Digester before it was set to this content handler.protected org.w3c.dom.NoderootThe DOM node that will be pushed on Digester's stack.protected org.w3c.dom.NodetopThe current top DOM mode.
-
Constructor Summary
Constructors Constructor Description NodeBuilder(org.w3c.dom.Document doc, org.w3c.dom.Node root)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)Appends aTextnode to the current node.voidendElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)Checks whether control needs to be returned to Digester.voidprocessingInstruction(java.lang.String target, java.lang.String data)Adds a newProcessingInstructionto the current node.voidstartElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts)Adds a new childElementto the current node.
-
-
-
Field Detail
-
oldContentHandler
protected org.xml.sax.ContentHandler oldContentHandler
The content handler used by Digester before it was set to this content handler.
-
depth
protected int depth
Depth of the current node, relative to the element where the content handler was put into action.
-
doc
protected org.w3c.dom.Document doc
A DOM Document used to create the various Node instances.
-
root
protected org.w3c.dom.Node root
The DOM node that will be pushed on Digester's stack.
-
top
protected org.w3c.dom.Node top
The current top DOM mode.
-
-
Constructor Detail
-
NodeBuilder
public NodeBuilder(org.w3c.dom.Document doc, org.w3c.dom.Node root) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXExceptionConstructor.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 nodesroot- the root node- Throws:
javax.xml.parsers.ParserConfigurationException- if the DocumentBuilderFactory could not be instantiatedorg.xml.sax.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) throws org.xml.sax.SAXExceptionAppends aTextnode to the current node.- Specified by:
charactersin interfaceorg.xml.sax.ContentHandler- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Parameters:
ch- the characters from the XML documentstart- the start position in the arraylength- the number of characters to read from the array- Throws:
org.xml.sax.SAXException- if the DOM implementation throws an exception
-
endElement
public void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXExceptionChecks whether control needs to be returned to Digester.- Specified by:
endElementin interfaceorg.xml.sax.ContentHandler- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- the namespace URIlocalName- the local nameqName- the qualified (prefixed) name- Throws:
org.xml.sax.SAXException- if the DOM implementation throws an exception
-
processingInstruction
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXExceptionAdds a newProcessingInstructionto the current node.- Specified by:
processingInstructionin interfaceorg.xml.sax.ContentHandler- Overrides:
processingInstructionin classorg.xml.sax.helpers.DefaultHandler- Parameters:
target- the processing instruction targetdata- the processing instruction data, or null if none was supplied- Throws:
org.xml.sax.SAXException- if the DOM implementation throws an exception
-
startElement
public void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes atts) throws org.xml.sax.SAXExceptionAdds a new childElementto the current node.- Specified by:
startElementin interfaceorg.xml.sax.ContentHandler- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Parameters:
namespaceURI- the namespace URIlocalName- the local nameqName- the qualified (prefixed) nameatts- the list of attributes- Throws:
org.xml.sax.SAXException- if the DOM implementation throws an exception
-
-