com.aliasi.xml
Class RemoveElementsFilter

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.aliasi.xml.SimpleElementHandler
          extended by com.aliasi.xml.SAXFilterHandler
              extended by com.aliasi.xml.RemoveElementsFilter
All Implemented Interfaces:
ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class RemoveElementsFilter
extends SAXFilterHandler

A RemoveElementsFilter filters out specified elements from a stream of SAX events. The elements to remove are specified by qualified name with the method removeElement(String). The content of the elements is not removed.

Since:
LingPipe1.0
Version:
3.8
Author:
Bob Carpenter

Field Summary
 
Fields inherited from class com.aliasi.xml.SAXFilterHandler
mHandler
 
Fields inherited from class com.aliasi.xml.SimpleElementHandler
CDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER
 
Constructor Summary
RemoveElementsFilter()
          Construct a filter to remove elements.
RemoveElementsFilter(DefaultHandler handler)
          Construct a filter to remove elements and pass events to the specified handler.
 
Method Summary
 void endElement(String namespaceURI, String localName, String qName)
          Removes specified elements, passing others to the contained handler.
 void removeElement(String qName)
          Add the specified qualified element name to the set of elements to remove.
 void startElement(String namespaceURI, String localName, String qName, Attributes atts)
          Removes specified elements and passes others through to the contained handler.
 
Methods inherited from class com.aliasi.xml.SAXFilterHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, setHandler, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class com.aliasi.xml.SimpleElementHandler
addSimpleAttribute, characters, characters, characters, characters, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, endSimpleElement, endSimpleElement, startEndSimpleElement, startEndSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoveElementsFilter

public RemoveElementsFilter()
Construct a filter to remove elements. Elements to be removed should be defined using removeElement(String). The handler to receive events should be set with SAXFilterHandler.setHandler(DefaultHandler).


RemoveElementsFilter

public RemoveElementsFilter(DefaultHandler handler)
Construct a filter to remove elements and pass events to the specified handler. Elements to be removed should be defined using removeElement(String).

Method Detail

removeElement

public void removeElement(String qName)
Add the specified qualified element name to the set of elements to remove.

Parameters:
qName - Qualified name of element to remove.

startElement

public void startElement(String namespaceURI,
                         String localName,
                         String qName,
                         Attributes atts)
                  throws SAXException
Removes specified elements and passes others through to the contained handler.

Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class SAXFilterHandler
Parameters:
namespaceURI - The URI identifying the name space, or null if there isn't one.
localName - Local name of element.
qName - Qualified name of element, which is prefixed with the name space URI and a colon if it is non-null, and is equal to local name if there is no name space specified.
atts - Attributes for this element.
Throws:
SAXException - if the contained hanlder throws a SAX exception.

endElement

public void endElement(String namespaceURI,
                       String localName,
                       String qName)
                throws SAXException
Removes specified elements, passing others to the contained handler.

Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class SAXFilterHandler
Parameters:
namespaceURI - The URI identifying the name space, or null if there isn't one.
localName - Local name of element.
qName - Qualified name of element, which is prefixed with the name space URI and a colon if it is non-null, and is equal to local name if there is no name space specified.
Throws:
SAXException - if the contained hanlder throws a SAX exception.