public class SAXFilterHandler extends SimpleElementHandler
SAXFilterHandler provides a base class for
filtering SAX handlers. A SAX filter handler behaves like other
output stream filters such as FilterOutputStream.
A filter acts as a container for a handler, which may be supplied
at construction time or set. The filter typically receives SAX
events and processes them in some way before passing them to the
contained handler. This particular filter implements the content
handler component of XMLFilterImpl.
The contained
handler may be changed with setHandler(DefaultHandler),
thus allowing reuse of filters. The implementation of all methods
in this class delegates the methods to the contained handler, so an
extending class need only implement the handler methods that it
would like to filter. The contained handler is protected and may
be accessed directly by subclasses; its methods may be accessed
through super.
Warning: The Sun JDK 1.4.2 implementation of DefaultHandler is defective in not declaring an IOException to be thrown by DefaultHandler.resolveEntity(String,String). See the method
documentation for resolveEntity(String,String) for a
description of this class's implemented workaround.
| Modifier and Type | Field and Description |
|---|---|
protected org.xml.sax.helpers.DefaultHandler |
mHandler
The contained default handler to which events are delegated by
default.
|
CDATA_ATTS_TYPE, EMPTY_ATTS, NO_OP_DEFAULT_HANDLER| Constructor and Description |
|---|
SAXFilterHandler()
Construct a filter handler that contains the no-op handler
SimpleElementHandler.NO_OP_DEFAULT_HANDLER. |
SAXFilterHandler(org.xml.sax.helpers.DefaultHandler handler)
Construct a filter handler with the specified contained
handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch,
int start,
int length)
Call delegated to
mHandler. |
void |
endDocument()
Call delegated to
mHandler. |
void |
endElement(String namespaceURI,
String localName,
String qName)
Call delegated to
mHandler. |
void |
endPrefixMapping(String prefix)
Call delegated to
mHandler. |
void |
error(SAXParseException exception)
Call delegated to
mHandler. |
void |
fatalError(SAXParseException exception)
Call delegated to
mHandler. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
Call delegated to
mHandler. |
void |
notationDecl(String name,
String publicId,
String systemId)
Call delegated to
mHandler. |
void |
processingInstruction(String target,
String data)
Call delegated to
mHandler. |
InputSource |
resolveEntity(String publicId,
String systemId)
Call delegated to
mHandler. |
void |
setDocumentLocator(Locator locator)
Call delegated to
mHandler. |
void |
setHandler(org.xml.sax.helpers.DefaultHandler handler)
Sets the contained handler to the specified value.
|
void |
skippedEntity(String name)
Call delegated to
mHandler. |
void |
startDocument()
Call delegated to
mHandler. |
void |
startElement(String namespaceURI,
String localName,
String qName,
Attributes atts)
Call delegated to
mHandler. |
void |
startPrefixMapping(String prefix,
String uri)
Call delegated to
mHandler. |
void |
unparsedEntityDecl(String name,
String publicId,
String systemId,
String notationName)
Call delegated to
mHandler. |
void |
warning(SAXParseException exception)
Call delegated to
mHandler. |
addSimpleAttribute, characters, characters, characters, characters, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, createAttributes, endSimpleElement, endSimpleElement, startEndSimpleElement, startEndSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElement, startSimpleElementprotected org.xml.sax.helpers.DefaultHandler mHandler
super invocations.public SAXFilterHandler(org.xml.sax.helpers.DefaultHandler handler)
handler - The handler to be contained by the constructed
filter.public SAXFilterHandler()
SimpleElementHandler.NO_OP_DEFAULT_HANDLER.public void setHandler(org.xml.sax.helpers.DefaultHandler handler)
public void startDocument()
throws SAXException
mHandler.startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerSAXException - if the contained hanlder throws a SAX
exception.public void endDocument()
throws SAXException
mHandler.endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerSAXException - if the contained hanlder throws a SAX
exception.public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException
mHandler.startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - 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.SAXException - if the contained hanlder throws a SAX
exception.public void endElement(String namespaceURI, String localName, String qName) throws SAXException
mHandler.endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandlernamespaceURI - 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.SAXException - if the contained hanlder throws a SAX
exception.public void characters(char[] ch,
int start,
int length)
throws SAXException
mHandler.characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - Character array containing characters to handle.start - Index of first character to handle.length - Number of characters to handle.SAXException - if the contained hanlder throws a SAX
exception.public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
mHandler.ignorableWhitespace in interface ContentHandlerignorableWhitespace in class org.xml.sax.helpers.DefaultHandlerch - Character array containing characters to handle.start - Index of first character to handle.length - Number of characters to handle.SAXException - if the contained hanlder throws a SAX
exception.public void processingInstruction(String target, String data) throws SAXException
mHandler.processingInstruction in interface ContentHandlerprocessingInstruction in class org.xml.sax.helpers.DefaultHandlertarget - The processing instruction target.data - The processing instruction data, or
null if none is supplied.SAXException - if the contained hanlder throws a SAX
exception.public void startPrefixMapping(String prefix, String uri) throws SAXException
mHandler.startPrefixMapping in interface ContentHandlerstartPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - The namespace prefix being declared.uri - The namespace URI mapped to the prefix.SAXException - if the contained hanlder throws a SAX
exception.public void endPrefixMapping(String prefix) throws SAXException
mHandler.endPrefixMapping in interface ContentHandlerendPrefixMapping in class org.xml.sax.helpers.DefaultHandlerprefix - The namespace prefix being declared.SAXException - if the contained hanlder throws a SAX
exception.public void skippedEntity(String name) throws SAXException
mHandler.skippedEntity in interface ContentHandlerskippedEntity in class org.xml.sax.helpers.DefaultHandlername - The name of the skipped entity.SAXException - if the contained hanlder throws a SAX
exception.public void setDocumentLocator(Locator locator)
mHandler.setDocumentLocator in interface ContentHandlersetDocumentLocator in class org.xml.sax.helpers.DefaultHandlerlocator - A locator for all SAX document events.SAXException - if the contained hanlder throws a SAX
exception.public InputSource resolveEntity(String publicId, String systemId) throws SAXException
mHandler.
Note that this method only throws SAX exceptions, whereas the SAX specification allows it to also throw an I/O exception. In this class's implementation, all I/O exceptions thrown by the delegate are converted to SAX exceptions before being re-thrown by this method. This extreme measure is taken because a bug in JDK 1.4.x failed to delcare an I/O exception on the resolve entity method. Although Sun's 1.5 JDK does declare the exception, this method converts it to allow the same source to compile in 1.4 and 1.5. For more information on this bug, see Sun's bug report:
resolveEntity in DefaultHandler does not throw IOException
resolveEntity in interface EntityResolverresolveEntity in class org.xml.sax.helpers.DefaultHandlerpublicId - The public identifier, or null if
none is available.systemId - The system identifier provided in the XML
document.SAXException - if the contained hanlder throws a SAX
exception.public void error(SAXParseException exception) throws SAXException
mHandler.error in interface ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerexception - The error information, encoded as an exception.SAXException - if the contained hanlder throws a SAX
exception.public void fatalError(SAXParseException exception) throws SAXException
mHandler.fatalError in interface ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerexception - The fatal error information, encoded as an
exception.SAXException - if the contained hanlder throws a SAX
exception.public void warning(SAXParseException exception) throws SAXException
mHandler.warning in interface ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerexception - The warning information, encoded as an exception.SAXException - if the contained hanlder throws a SAX
exception.public void notationDecl(String name, String publicId, String systemId) throws SAXException
mHandler.notationDecl in interface DTDHandlernotationDecl in class org.xml.sax.helpers.DefaultHandlername - The notation name.publicId - The notation public identifier, or
null if none is available.systemId - The notation system identifier.SAXException - if the contained hanlder throws a SAX
exception.public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
mHandler.unparsedEntityDecl in interface DTDHandlerunparsedEntityDecl in class org.xml.sax.helpers.DefaultHandlername - The entity name.publicId - The entity public identifier, or
null if none is available.systemId - The entity system identifier.notationName - The name of the associated notation.SAXException - if the contained hanlder throws a SAX
exception.Copyright © 2019 Alias-i, Inc.. All rights reserved.