org.greybird.xmliter
Interface SaxEventSource

All Known Implementing Classes:
ThreadedSaxEventSource, XercesSaxEventSource

public interface SaxEventSource

An incremental generator of SAX events.

SAX events are generated by calling a SAX ContentHandler when the generateEvents() method of this interface is called. SAX events may be generated during XML parsing or from any other data source.

When generateEvents() is called, only a subset of events are generated, so that not all events need to be queued in memory. Implementations should take care to generate a reasonably small set of events, or provide user control over the number of events generated.


Field Summary
static java.lang.String NAMESPACES_FEATURE
          The SAX feature: http://xml.org/sax/features/namespaces This feature must be set for SAX parsers used to generate events, or namespace information will not be correctly reported.
 
Method Summary
 void close(boolean completeParsing)
          Closes the event source to free up resources and stops generating events.
 boolean generateEvents()
          Generates a subset of SAX events and returns true if more events are still available.
 void setContentHandler(org.xml.sax.ContentHandler contentHandler)
          Sets the content handler to receive SAX events.
 

Field Detail

NAMESPACES_FEATURE

public static final java.lang.String NAMESPACES_FEATURE
The SAX feature: http://xml.org/sax/features/namespaces This feature must be set for SAX parsers used to generate events, or namespace information will not be correctly reported.
Method Detail

setContentHandler

public void setContentHandler(org.xml.sax.ContentHandler contentHandler)
Sets the content handler to receive SAX events.

This method is called by SaxIterator before it calls generateEvents().

Not all handler methods need be called by a generator. The methods used are as follows and all other method calls are ignored.


generateEvents

public boolean generateEvents()
                       throws java.io.IOException,
                              XmlIteratorException
Generates a subset of SAX events and returns true if more events are still available.
Throws:
java.io.IOException - if an error occurs retrieving input data.
XmlIteratorException - if an error occurs processing input data.

close

public void close(boolean completeParsing)
           throws java.io.IOException,
                  XmlIteratorException
Closes the event source to free up resources and stops generating events.

Even when completeParsing is true, no events should be generated by this method or by subsequent calls to generateEvents().

Parameters:
completeParsing - is true if parsing and reading of the input source should be completed during close, or false to abort parsing and reading.
Throws:
java.io.IOException - if an error occurs retrieving input data.
XmlIteratorException - if an error occurs processing input data.

Copyright (c) 2003 Mark T. Hayes; All Rights Reserved