public final class SaxWalkerOverDom extends 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()
Constructor and Description |
---|
SaxWalkerOverDom()
Constructs a new
SaxWalkerOverDom . |
SaxWalkerOverDom(ContentHandler contentHandler)
Constructs a new
SaxWalkerOverDom with the provided
ContentHandler to send SAX events. |
SaxWalkerOverDom(List<ContentHandler> contentHandlers)
Constructs a new
SaxWalkerOverDom , taking ownership of the
list of ContentHandler s to send events to. |
Modifier and Type | Method and Description |
---|---|
void |
addContentHandler(ContentHandler contentHandler)
Adds the provided
ContentHandler to the list of content handlers
to send events to. |
boolean |
removeContentHandler(ContentHandler contentHandler)
Removes the first instance of the provided
ContentHandler from
the set of handlers to send events to. |
void |
walk(Document document)
Walks the provided
Document , sending events to all of the
ContentHandler s as it traverses. |
public SaxWalkerOverDom()
SaxWalkerOverDom
.public SaxWalkerOverDom(ContentHandler contentHandler)
SaxWalkerOverDom
with the provided
ContentHandler
to send SAX events.contentHandler
- The content handler to send events to.public SaxWalkerOverDom(List<ContentHandler> contentHandlers)
SaxWalkerOverDom
, taking ownership of the
list of ContentHandler
s to send events to.contentHandlers
- The list of content handlers to send events to.public void addContentHandler(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(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(Document document) throws SAXException
Document
, sending events to all of the
ContentHandler
s as it traverses. If there are no content
handlers, this method is a no-op.document
- The Document
to traverse.systemId
- The system ID of this Document
.SAXException
- if an exception occurs when notifying the handlers.Copyright © 2004–2017 The Apache Software Foundation. All rights reserved.