com.raritantechnologies.xml.sax.filter
Class DispatchFilter

java.lang.Object
  extended byorg.xml.sax.helpers.XMLFilterImpl
      extended bycom.raritantechnologies.xml.sax.filter.DispatchFilter
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler, org.xml.sax.XMLFilter, org.xml.sax.XMLReader

public class DispatchFilter
extends org.xml.sax.helpers.XMLFilterImpl

A SAXFilter that can dispatch XML elements to different ContentHandlers based on the decisions of ElementSelectors. Enables XML content streams to be separated into parallel streams for collection or specialized processing.

Since a dispatch decision can be made anywhere within the path(s) of an element (i.e. anywhere below the root tag level), we have to wait until we are back at the root level before sending the SAX events on to the ContentHandler. The filter then sends all of the events for the elements that have been selected to be dispatched.

This class works with ElementSelector objects that manage the decisions to dispatch element tags or not and ElementDispatcher objects which connect an ElementSelector with a SAX ContentHandler that receives the selected elements for further processing.

Author:
Ted Sullivan
See Also:

Developed by
Raritan Technologies .

Constructor Summary
DispatchFilter()
           
DispatchFilter(org.xml.sax.XMLReader reader)
           
 
Method Summary
 void addDispatcher(ElementDispatcher dispatcher)
           
 void characters(char[] ch, int start, int length)
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
           
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DispatchFilter

public DispatchFilter()

DispatchFilter

public DispatchFilter(org.xml.sax.XMLReader reader)
Method Detail

addDispatcher

public void addDispatcher(ElementDispatcher dispatcher)

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Throws:
org.xml.sax.SAXException