public class XMLFilterImpl extends Objectimplements XMLFilter , EntityResolver , DTDHandler , ContentHandler , ErrorHandler
This module, both source code and documentation, is in the Public Domain, and comes with NO WARRANTY. See http://www.saxproject.org for further information.
This class is designed to sit between an XMLReader and the client application's event handlers. By default, it does nothing but pass requests up to the reader and events on to the handlers unmodified, but subclasses can override specific methods to modify the event stream or the configuration requests as they pass through.
XMLFilter,
XMLReader,
EntityResolver,
DTDHandler,
ContentHandler,
ErrorHandler
| Constructor and Description |
|---|
XMLFilterImpl()
Construct an empty XML filter, with no parent.
|
XMLFilterImpl(XMLReader
Construct an XML filter with the specified parent.
|
| Modifier and Type | Method and Description |
|---|---|
void |
characters(char[] ch, int start, int length)
Filter a character data event.
|
void |
endDocument()
Filter an end document event.
|
void |
endElement(String
Filter an end element event.
|
void |
endPrefixMapping(String
Filter an end Namespace prefix mapping event.
|
void |
error(SAXParseException
Filter an error event.
|
void |
fatalError(SAXParseException
Filter a fatal error event.
|
ContentHandler |
getContentHandler()
Get the content event handler.
|
DTDHandler |
getDTDHandler()
Get the current DTD event handler.
|
EntityResolver |
getEntityResolver()
Get the current entity resolver.
|
ErrorHandler |
getErrorHandler()
Get the current error event handler.
|
boolean |
getFeature(String
Look up the value of a feature.
|
XMLReader |
getParent()
Get the parent reader.
|
Object |
getProperty(String
Look up the value of a property.
|
void |
ignorableWhitespace(char[] ch, int start, int length)
Filter an ignorable whitespace event.
|
void |
notationDecl(String
Filter a notation declaration event.
|
void |
parse(InputSource
Parse a document.
|
void |
parse(String
Parse a document.
|
void |
processingInstruction(String
Filter a processing instruction event.
|
InputSource |
resolveEntity(String
Filter an external entity resolution.
|
void |
setContentHandler(ContentHandler
Set the content event handler.
|
void |
setDocumentLocator(Locator
Filter a new document locator event.
|
void |
setDTDHandler(DTDHandler
Set the DTD event handler.
|
void |
setEntityResolver(EntityResolver
Set the entity resolver.
|
void |
setErrorHandler(ErrorHandler
Set the error event handler.
|
void |
setFeature(String
Set the value of a feature.
|
void |
setParent(XMLReader
Set the parent reader.
|
void |
setProperty(String
Set the value of a property.
|
void |
skippedEntity(String
Filter a skipped entity event.
|
void |
startDocument()
Filter a start document event.
|
void |
startElement(String
Filter a start element event.
|
void |
startPrefixMapping(String
Filter a start Namespace prefix mapping event.
|
void |
unparsedEntityDecl(String
Filter an unparsed entity declaration event.
|
void |
warning(SAXParseException
Filter a warning event.
|
public XMLFilterImpl()
This filter will have no parent: you must assign a parent before you start a parse or do any configuration with setFeature or setProperty, unless you use this as a pure event consumer rather than as an XMLReader.
public XMLFilterImpl(XMLReaderparent)
setParent(org.xml.sax.XMLReader),
getParent()
public void setParent(XMLReaderparent)
This is the XMLReader from which this filter will obtain its events and to which it will pass its configuration requests. The parent may itself be another filter.
If there is no parent reader set, any attempt to parse or to set or get a feature or property will fail.
setParent in interface
XMLFilter
parent - The parent XML reader.
getParent()
public XMLReadergetParent()
getParent in interface
XMLFilter
setParent(org.xml.sax.XMLReader)
public void setFeature(Stringname, boolean value) throws SAXNotRecognizedException , SAXNotSupportedException
This will always fail if the parent is null.
setFeature in interface
XMLReader
name - The feature name.
value - The requested feature value.
SAXNotRecognizedException - If the feature value can't be assigned or retrieved from the parent.
SAXNotSupportedException - When the parent recognizes the feature name but cannot set the requested value.
XMLReader.getFeature(java.lang.String)
public boolean getFeature(Stringname) throws SAXNotRecognizedException , SAXNotSupportedException
This will always fail if the parent is null.
getFeature in interface
XMLReader
name - The feature name.
SAXNotRecognizedException - If the feature value can't be assigned or retrieved from the parent.
SAXNotSupportedException - When the parent recognizes the feature name but cannot determine its value at this time.
XMLReader.setFeature(java.lang.String, boolean)
public void setProperty(Stringname, Object value) throws SAXNotRecognizedException , SAXNotSupportedException
This will always fail if the parent is null.
setProperty in interface
XMLReader
name - The property name.
value - The requested property value.
SAXNotRecognizedException - If the property value can't be assigned or retrieved from the parent.
SAXNotSupportedException - When the parent recognizes the property name but cannot set the requested value.
public ObjectgetProperty(String name) throws SAXNotRecognizedException , SAXNotSupportedException
getProperty in interface
XMLReader
name - The property name.
SAXNotRecognizedException - If the property value can't be assigned or retrieved from the parent.
SAXNotSupportedException - When the parent recognizes the property name but cannot determine its value at this time.
XMLReader.setProperty(java.lang.String, java.lang.Object)
public void setEntityResolver(EntityResolverresolver)
setEntityResolver in interface
XMLReader
resolver - The new entity resolver.
XMLReader.getEntityResolver()
public EntityResolvergetEntityResolver()
getEntityResolver in interface
XMLReader
XMLReader.setEntityResolver(org.xml.sax.EntityResolver)
public void setDTDHandler(DTDHandlerhandler)
setDTDHandler in interface
XMLReader
handler - the new DTD handler
XMLReader.getDTDHandler()
public DTDHandlergetDTDHandler()
getDTDHandler in interface
XMLReader
XMLReader.setDTDHandler(org.xml.sax.DTDHandler)
public void setContentHandler(ContentHandlerhandler)
setContentHandler in interface
XMLReader
handler - the new content handler
XMLReader.getContentHandler()
public ContentHandlergetContentHandler()
getContentHandler in interface
XMLReader
XMLReader.setContentHandler(org.xml.sax.ContentHandler)
public void setErrorHandler(ErrorHandlerhandler)
setErrorHandler in interface
XMLReader
handler - the new error handler
XMLReader.getErrorHandler()
public ErrorHandlergetErrorHandler()
getErrorHandler in interface
XMLReader
XMLReader.setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(InputSourceinput) throws SAXException , IOException
parse in interface
XMLReader
input - The input source for the document entity.
SAXException - Any SAX exception, possibly wrapping another exception.
IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
InputSource,
XMLReader.parse(java.lang.String) ,
XMLReader.setEntityResolver(org.xml.sax.EntityResolver) ,
XMLReader.setDTDHandler(org.xml.sax.DTDHandler) ,
XMLReader.setContentHandler(org.xml.sax.ContentHandler) ,
XMLReader.setErrorHandler(org.xml.sax.ErrorHandler)
public void parse(StringsystemId) throws SAXException , IOException
parse in interface
XMLReader
systemId - The system identifier as a fully-qualified URI.
SAXException - Any SAX exception, possibly wrapping another exception.
IOException - An IO exception from the parser, possibly from a byte stream or character stream supplied by the application.
XMLReader.parse(org.xml.sax.InputSource)
public InputSourceresolveEntity(String publicId, String systemId) throws SAXException , IOException
resolveEntity in interface
EntityResolver
publicId - The entity's public identifier, or null.
systemId - The entity's system identifier.
SAXException - The client may throw an exception during processing.
IOException - The client may throw an I/O-related exception while obtaining the new InputSource.
InputSource
public void notationDecl(Stringname, String publicId, String systemId) throws SAXException
notationDecl in interface
DTDHandler
name - The notation name.
publicId - The notation's public identifier, or null.
systemId - The notation's system identifier, or null.
SAXException - The client may throw an exception during processing.
DTDHandler.unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String) ,
Attributes
public void unparsedEntityDecl(Stringname, String publicId, String systemId, String notationName) throws SAXException
unparsedEntityDecl in interface
DTDHandler
name - The entity name.
publicId - The entity's public identifier, or null.
systemId - The entity's system identifier, or null.
notationName - The name of the associated notation.
SAXException - The client may throw an exception during processing.
DTDHandler.notationDecl(java.lang.String, java.lang.String, java.lang.String) ,
Attributes
public void setDocumentLocator(Locatorlocator)
setDocumentLocator in interface
ContentHandler
locator - The document locator.
Locator
public void startDocument()
throws SAXException
startDocument in interface
ContentHandler
SAXException - The client may throw an exception during processing.
ContentHandler.endDocument()
public void endDocument()
throws SAXException
endDocument in interface
ContentHandler
SAXException - The client may throw an exception during processing.
ContentHandler.startDocument()
public void startPrefixMapping(Stringprefix, String uri) throws SAXException
startPrefixMapping in interface
ContentHandler
prefix - The Namespace prefix.
uri - The Namespace URI.
SAXException - The client may throw an exception during processing.
ContentHandler.endPrefixMapping(java.lang.String) ,
ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
public void endPrefixMapping(Stringprefix) throws SAXException
endPrefixMapping in interface
ContentHandler
prefix - The Namespace prefix.
SAXException - The client may throw an exception during processing.
ContentHandler.startPrefixMapping(java.lang.String, java.lang.String) ,
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
public void startElement(Stringuri, String localName, String qName, Attributes atts) throws SAXException
startElement in interface
ContentHandler
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
atts - The element's attributes.
SAXException - The client may throw an exception during processing.
ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String) ,
Attributes,
AttributesImpl
public void endElement(Stringuri, String localName, String qName) throws SAXException
endElement in interface
ContentHandler
uri - The element's Namespace URI, or the empty string.
localName - The element's local name, or the empty string.
qName - The element's qualified (prefixed) name, or the empty string.
SAXException - The client may throw an exception during processing.
public void characters(char[] ch,
int start,
int length)
throws SAXException
characters in interface
ContentHandler
ch - An array of characters.
start - The starting position in the array.
length - The number of characters to use from the array.
SAXException - The client may throw an exception during processing.
ContentHandler.ignorableWhitespace(char[], int, int) ,
Locator
public void ignorableWhitespace(char[] ch,
int start,
int length)
throws SAXException
ignorableWhitespace in interface
ContentHandler
ch - An array of characters.
start - The starting position in the array.
length - The number of characters to use from the array.
SAXException - The client may throw an exception during processing.
ContentHandler.characters(char[], int, int)
public void processingInstruction(Stringtarget, String data) throws SAXException
processingInstruction in interface
ContentHandler
target - The processing instruction target.
data - The text following the target.
SAXException - The client may throw an exception during processing.
public void skippedEntity(Stringname) throws SAXException
skippedEntity in interface
ContentHandler
name - The name of the skipped entity.
SAXException - The client may throw an exception during processing.
public void warning(SAXParseExceptione) throws SAXException
warning in interface
ErrorHandler
e - The warning as an exception.
SAXException - The client may throw an exception during processing.
SAXParseException
public void error(SAXParseExceptione) throws SAXException
error in interface
ErrorHandler
e - The error as an exception.
SAXException - The client may throw an exception during processing.
SAXParseException
public void fatalError(SAXParseExceptione) throws SAXException
fatalError in interface
ErrorHandler
e - The error as an exception.
SAXException - The client may throw an exception during processing.
SAXParseException