Class XMLFilterImpl
- All Implemented Interfaces:
-
ContentHandler,DTDHandler,EntityResolver,ErrorHandler,XMLFilter,XMLReader
public class XMLFilterImpl extends Object implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler
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.
- Since:
- 1.4, SAX 2.0
- See Also:
Constructor Summary
| Constructor | Description |
|---|---|
XMLFilterImpl() |
Construct an empty XML filter, with no parent. |
XMLFilterImpl |
Construct an XML filter with the specified parent. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
void |
characters |
Filter a character data event. |
void |
endDocument() |
Filter an end document event. |
void |
endElement |
Filter an end element event. |
void |
endPrefixMapping |
Filter an end Namespace prefix mapping event. |
void |
error |
Filter an error event. |
void |
fatalError |
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 |
Look up the value of a feature. |
XMLReader |
getParent() |
Get the parent reader. |
Object |
getProperty |
Look up the value of a property. |
void |
ignorableWhitespace |
Filter an ignorable whitespace event. |
void |
notationDecl |
Filter a notation declaration event. |
void |
parse |
Parse a document. |
void |
parse |
Parse a document. |
void |
processingInstruction |
Filter a processing instruction event. |
InputSource |
resolveEntity |
Filter an external entity resolution. |
void |
setContentHandler |
Set the content event handler. |
void |
setDocumentLocator |
Filter a new document locator event. |
void |
setDTDHandler |
Set the DTD event handler. |
void |
setEntityResolver |
Set the entity resolver. |
void |
setErrorHandler |
Set the error event handler. |
void |
setFeature |
Set the value of a feature. |
void |
setParent |
Set the parent reader. |
void |
setProperty |
Set the value of a property. |
void |
skippedEntity |
Filter a skipped entity event. |
void |
startDocument() |
Filter a start document event. |
void |
startElement |
Filter a start element event. |
void |
startPrefixMapping |
Filter a start Namespace prefix mapping event. |
void |
unparsedEntityDecl |
Filter an unparsed entity declaration event. |
void |
warning |
Filter a warning event. |
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods declared in interface org.xml.sax.ContentHandler
declaration
Constructor Details
XMLFilterImpl
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.
XMLFilterImpl
public XMLFilterImpl(XMLReader parent)
- Parameters:
-
parent- the specified parent - See Also:
Method Details
setParent
public void setParent(XMLReader parent)
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.
getParent
public XMLReader getParent()
setFeature
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException
This will always fail if the parent is null.
- Specified by:
-
setFeaturein interfaceXMLReader - Parameters:
-
name- The feature name. -
value- The requested feature value. - Throws:
-
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. - See Also:
getFeature
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException
This will always fail if the parent is null.
- Specified by:
-
getFeaturein interfaceXMLReader - Parameters:
-
name- The feature name. - Returns:
- The current value of the feature.
- Throws:
-
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. - See Also:
setProperty
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException
This will always fail if the parent is null.
- Specified by:
-
setPropertyin interfaceXMLReader - Parameters:
-
name- The property name. -
value- The requested property value. - Throws:
-
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.
getProperty
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException
- Specified by:
-
getPropertyin interfaceXMLReader - Parameters:
-
name- The property name. - Returns:
- The current value of the property.
- Throws:
-
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. - See Also:
setEntityResolver
public void setEntityResolver(EntityResolver resolver)
- Specified by:
-
setEntityResolverin interfaceXMLReader - Parameters:
-
resolver- The new entity resolver. - See Also:
getEntityResolver
public EntityResolver getEntityResolver()
- Specified by:
-
getEntityResolverin interfaceXMLReader - Returns:
- The current entity resolver, or null if none was set.
- See Also:
setDTDHandler
public void setDTDHandler(DTDHandler handler)
- Specified by:
-
setDTDHandlerin interfaceXMLReader - Parameters:
-
handler- the new DTD handler - See Also:
getDTDHandler
public DTDHandler getDTDHandler()
- Specified by:
-
getDTDHandlerin interfaceXMLReader - Returns:
- The current DTD handler, or null if none was set.
- See Also:
setContentHandler
public void setContentHandler(ContentHandler handler)
- Specified by:
-
setContentHandlerin interfaceXMLReader - Parameters:
-
handler- the new content handler - See Also:
getContentHandler
public ContentHandler getContentHandler()
- Specified by:
-
getContentHandlerin interfaceXMLReader - Returns:
- The current content handler, or null if none was set.
- See Also:
setErrorHandler
public void setErrorHandler(ErrorHandler handler)
- Specified by:
-
setErrorHandlerin interfaceXMLReader - Parameters:
-
handler- the new error handler - See Also:
getErrorHandler
public ErrorHandler getErrorHandler()
- Specified by:
-
getErrorHandlerin interfaceXMLReader - Returns:
- The current error handler, or null if none was set.
- See Also:
parse
public void parse(InputSource input) throws SAXException, IOException
- Specified by:
-
parsein interfaceXMLReader - Parameters:
-
input- The input source for the document entity. - Throws:
-
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. - See Also:
parse
public void parse(String systemId) throws SAXException, IOException
- Specified by:
-
parsein interfaceXMLReader - Parameters:
-
systemId- The system identifier as a fully-qualified URI. - Throws:
-
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. - See Also:
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
- Specified by:
-
resolveEntityin interfaceEntityResolver - Parameters:
-
publicId- The entity's public identifier, or null. -
systemId- The entity's system identifier. - Returns:
- A new InputSource or null for the default.
- Throws:
-
SAXException- The client may throw an exception during processing. -
IOException- The client may throw an I/O-related exception while obtaining the new InputSource. - See Also:
notationDecl
public void notationDecl(String name, String publicId, String systemId) throws SAXException
- Specified by:
-
notationDeclin interfaceDTDHandler - Parameters:
-
name- The notation name. -
publicId- The notation's public identifier, or null. -
systemId- The notation's system identifier, or null. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
unparsedEntityDecl
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException
- Specified by:
-
unparsedEntityDeclin interfaceDTDHandler - Parameters:
-
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. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
setDocumentLocator
public void setDocumentLocator(Locator locator)
- Specified by:
-
setDocumentLocatorin interfaceContentHandler - Parameters:
-
locator- The document locator. - See Also:
startDocument
public void startDocument() throws SAXException
- Specified by:
-
startDocumentin interfaceContentHandler - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
endDocument
public void endDocument() throws SAXException
- Specified by:
-
endDocumentin interfaceContentHandler - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
startPrefixMapping
public void startPrefixMapping(String prefix, String uri) throws SAXException
- Specified by:
-
startPrefixMappingin interfaceContentHandler - Parameters:
-
prefix- The Namespace prefix. -
uri- The Namespace URI. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
endPrefixMapping
public void endPrefixMapping(String prefix) throws SAXException
- Specified by:
-
endPrefixMappingin interfaceContentHandler - Parameters:
-
prefix- The Namespace prefix. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
startElement
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException
- Specified by:
-
startElementin interfaceContentHandler - Parameters:
-
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. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
endElement
public void endElement(String uri, String localName, String qName) throws SAXException
- Specified by:
-
endElementin interfaceContentHandler - Parameters:
-
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. - Throws:
-
SAXException- The client may throw an exception during processing.
characters
public void characters(char[] ch, int start, int length) throws SAXException
- Specified by:
-
charactersin interfaceContentHandler - Parameters:
-
ch- An array of characters. -
start- The starting position in the array. -
length- The number of characters to use from the array. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
- Specified by:
-
ignorableWhitespacein interfaceContentHandler - Parameters:
-
ch- An array of characters. -
start- The starting position in the array. -
length- The number of characters to use from the array. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
processingInstruction
public void processingInstruction(String target, String data) throws SAXException
- Specified by:
-
processingInstructionin interfaceContentHandler - Parameters:
-
target- The processing instruction target. -
data- The text following the target. - Throws:
-
SAXException- The client may throw an exception during processing.
skippedEntity
public void skippedEntity(String name) throws SAXException
- Specified by:
-
skippedEntityin interfaceContentHandler - Parameters:
-
name- The name of the skipped entity. - Throws:
-
SAXException- The client may throw an exception during processing.
warning
public void warning(SAXParseException e) throws SAXException
- Specified by:
-
warningin interfaceErrorHandler - Parameters:
-
e- The warning as an exception. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
error
public void error(SAXParseException e) throws SAXException
- Specified by:
-
errorin interfaceErrorHandler - Parameters:
-
e- The error as an exception. - Throws:
-
SAXException- The client may throw an exception during processing. - See Also:
fatalError
public void fatalError(SAXParseException e) throws SAXException
- Specified by:
-
fatalErrorin interfaceErrorHandler - Parameters:
-
e- The error as an exception. - Throws:
-
SAXException- The client may throw an exception during processing.
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.xml/org/xml/sax/helpers/XMLFilterImpl.html