com.raritech.xml.sax.filter
Class ProgrammableSAXFilter

java.lang.Object
  |
  +--org.xml.sax.helpers.XMLFilterImpl
        |
        +--com.raritech.xml.sax.filter.ProgrammableSAXFilter
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 ProgrammableSAXFilter
extends org.xml.sax.helpers.XMLFilterImpl

A SAX filter that can be programmed to add/modify/delete elements/attributes/ or character data in an XML SAX stream. The filter monitors current path, maintains state for eliminated tags. (i.e. keeps listening for endElement before continuing to pass SAX events through). This filter supports simple or forward-only deletion: based on tag structure. For more complex (backward or deferred) deletion, use the SAXDeleteFilter which can delete based on "deep" structure.


Constructor Summary
ProgrammableSAXFilter()
           
ProgrammableSAXFilter(org.xml.sax.XMLReader reader)
           
 
Method Summary
 void addElementModifier(ElementModifier elementModifier)
          Adds an ElementModifier - an object than can change attributes or character data within a tag.
 void addElementRemover(ElementComparator elementRemover)
          This filter supports simple deletion: based on tag.
 void addElementReplacer(ElementReplacer replacer)
           
 void addListener(org.xml.sax.ContentHandler listener)
           
 void characters(char[] ch, int start, int length)
           
 void endDocument()
           
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
           
 void endPrefixMapping(java.lang.String prefix)
           
 void ignorableWhitespace(char[] ch, int start, int length)
           
 void processingInstruction(java.lang.String target, java.lang.String data)
           
 void skippedEntity(java.lang.String name)
           
 void startDocument()
           
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
           
 void startPrefixMapping(java.lang.String prefix, java.lang.String uri)
           
 
Methods inherited from class org.xml.sax.helpers.XMLFilterImpl
error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, notationDecl, parse, parse, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgrammableSAXFilter

public ProgrammableSAXFilter()

ProgrammableSAXFilter

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

addElementRemover

public void addElementRemover(ElementComparator elementRemover)
This filter supports simple deletion: based on tag. This method allows tag detectors (ElementComparator) to be plugged in.
Parameters:
elementRemover - ElementComparator used to detect tags that should be removed from the XML stream.

addElementReplacer

public void addElementReplacer(ElementReplacer replacer)

addElementModifier

public void addElementModifier(ElementModifier elementModifier)
Adds an ElementModifier - an object than can change attributes or character data within a tag.
Parameters:
elementModifier - Modifier to be used to change the contents (including adding child tags)

addListener

public void addListener(org.xml.sax.ContentHandler listener)

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
Overrides:
startElement in class org.xml.sax.helpers.XMLFilterImpl

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Overrides:
endElement in class org.xml.sax.helpers.XMLFilterImpl

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Overrides:
characters in class org.xml.sax.helpers.XMLFilterImpl

startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Overrides:
startDocument in class org.xml.sax.helpers.XMLFilterImpl

endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Overrides:
endDocument in class org.xml.sax.helpers.XMLFilterImpl

startPrefixMapping

public void startPrefixMapping(java.lang.String prefix,
                               java.lang.String uri)
                        throws org.xml.sax.SAXException
Overrides:
startPrefixMapping in class org.xml.sax.helpers.XMLFilterImpl

endPrefixMapping

public void endPrefixMapping(java.lang.String prefix)
                      throws org.xml.sax.SAXException
Overrides:
endPrefixMapping in class org.xml.sax.helpers.XMLFilterImpl

ignorableWhitespace

public void ignorableWhitespace(char[] ch,
                                int start,
                                int length)
                         throws org.xml.sax.SAXException
Overrides:
ignorableWhitespace in class org.xml.sax.helpers.XMLFilterImpl

processingInstruction

public void processingInstruction(java.lang.String target,
                                  java.lang.String data)
                           throws org.xml.sax.SAXException
Overrides:
processingInstruction in class org.xml.sax.helpers.XMLFilterImpl

skippedEntity

public void skippedEntity(java.lang.String name)
                   throws org.xml.sax.SAXException
Overrides:
skippedEntity in class org.xml.sax.helpers.XMLFilterImpl