javanet.staxutils
Class XMLStreamReaderToContentHandler

java.lang.Object
  extended byjavanet.staxutils.XMLStreamReaderToContentHandler
All Implemented Interfaces:
StAXReaderToContentHandler

public class XMLStreamReaderToContentHandler
extends java.lang.Object
implements StAXReaderToContentHandler

This is a simple utility class that adapts StAX events from an XMLStreamReader to SAX events on a ContentHandler, bridging between the two parser technologies.

Version:
1.0
Author:
Ryan.Shoemaker@Sun.COM

Constructor Summary
XMLStreamReaderToContentHandler(XMLStreamReader staxCore, XMLFilterImplEx filter)
          Construct a new StAX to SAX adapter that will convert a StAX event stream into a SAX event stream.
 
Method Summary
 void bridge()
          Perform the conversion from StAX events to SAX events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLStreamReaderToContentHandler

public XMLStreamReaderToContentHandler(XMLStreamReader staxCore,
                                       XMLFilterImplEx filter)
Construct a new StAX to SAX adapter that will convert a StAX event stream into a SAX event stream.

Parameters:
staxCore - StAX event source
filter - SAX event sink
Method Detail

bridge

public void bridge()
            throws XMLStreamException
Description copied from interface: StAXReaderToContentHandler
Perform the conversion from StAX events to SAX events.

The StAX parser must be pointing at the start element or the start document. The method reads the parser until it hits the corresponding end element, and turns the complete sub-tree into the equivalent of the SAX events.

The receiver of the SAX event will see this sub-tree as if it were a whole document.

When this method returns successfully, the parser is at the next token of the end element.

Specified by:
bridge in interface StAXReaderToContentHandler
Throws:
XMLStreamException - if any errors are encountered while parsing XML from the XMLStreamReader or firing events on the ContentHandler.