public final class SaxWalkerOverDom
extends java.lang.Object
Document in a SAX style, notifying listeners with SAX
events.
Because the document has already been processed, only the following methods
in the ContentHandler will be called:
ContentHandler.startDocument()ContentHandler.startPrefixMapping(String, String)ContentHandler.startElement(String, String, String, Attributes)ContentHandler.characters(char[], int, int)ContentHandler.endElement(String, String, String)ContentHandler.endPrefixMapping(String)ContentHandler.endDocument()| Modifier and Type | Class and Description |
|---|---|
private static class |
SaxWalkerOverDom.Attr |
private static class |
SaxWalkerOverDom.DomAttrsAsSax |
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<org.xml.sax.ContentHandler> |
listeners |
| Constructor and Description |
|---|
SaxWalkerOverDom()
Constructs a new
SaxWalkerOverDom. |
SaxWalkerOverDom(org.xml.sax.ContentHandler contentHandler)
Constructs a new
SaxWalkerOverDom with the provided
ContentHandler to send SAX events. |
SaxWalkerOverDom(java.util.List<org.xml.sax.ContentHandler> contentHandlers)
Constructs a new
SaxWalkerOverDom, taking ownership of the
list of ContentHandlers to send events to. |
| Modifier and Type | Method and Description |
|---|---|
void |
addContentHandler(org.xml.sax.ContentHandler contentHandler)
Adds the provided
ContentHandler to the list of content handlers
to send events to. |
private static java.lang.String |
convertNullToEmptyString(java.lang.String input) |
boolean |
removeContentHandler(org.xml.sax.ContentHandler contentHandler)
Removes the first instance of the provided
ContentHandler from
the set of handlers to send events to. |
private java.util.List<java.lang.String> |
startPrefixMappings(org.w3c.dom.Node node) |
void |
walk(org.w3c.dom.Document document)
Walks the provided
Document, sending events to all of the
ContentHandlers as it traverses. |
private void |
walk(org.w3c.dom.Element element) |
private void |
walk(org.w3c.dom.Text text) |
public SaxWalkerOverDom()
SaxWalkerOverDom.public SaxWalkerOverDom(org.xml.sax.ContentHandler contentHandler)
SaxWalkerOverDom with the provided
ContentHandler to send SAX events.contentHandler - The content handler to send events to.public SaxWalkerOverDom(java.util.List<org.xml.sax.ContentHandler> contentHandlers)
SaxWalkerOverDom, taking ownership of the
list of ContentHandlers to send events to.contentHandlers - The list of content handlers to send events to.public void addContentHandler(org.xml.sax.ContentHandler contentHandler)
ContentHandler to the list of content handlers
to send events to. If this content handler was already added, it will be
sent events twice (or more often).contentHandler - The content handler to send events to.public boolean removeContentHandler(org.xml.sax.ContentHandler contentHandler)
ContentHandler from
the set of handlers to send events to. If the content handler was added
more than once, it will continue to receive events.contentHandler - The content handler to stop sending events to.true if it was found, false if not.public void walk(org.w3c.dom.Document document)
throws org.xml.sax.SAXException
Document, sending events to all of the
ContentHandlers as it traverses. If there are no content
handlers, this method is a no-op.document - The Document to traverse.org.xml.sax.SAXException - if an exception occurs when notifying the handlers.private void walk(org.w3c.dom.Element element)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate void walk(org.w3c.dom.Text text)
throws org.xml.sax.SAXException
org.xml.sax.SAXExceptionprivate static java.lang.String convertNullToEmptyString(java.lang.String input)
private java.util.List<java.lang.String> startPrefixMappings(org.w3c.dom.Node node)
throws org.w3c.dom.DOMException,
org.xml.sax.SAXException
org.w3c.dom.DOMExceptionorg.xml.sax.SAXException