APIdia Launch Partner
Top Description Fields Constructors Methods
org.xml.sax.helpers

public Class XMLFilterImpl

extends Object
implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler
Class Inheritance
All Implemented Interfaces
org.xml.sax.ErrorHandler, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.XMLFilter, org.xml.sax.XMLReader
Known Direct Subclasses
com.sun.org.apache.xalan.internal.xsltc.trax.TrAXFilter
Imports
java.io.IOException, org.xml.sax.XMLReader, .XMLFilter, .InputSource, .Locator, .Attributes, .EntityResolver, .DTDHandler, .ContentHandler, .ErrorHandler, .SAXException, .SAXParseException, .SAXNotSupportedException, .SAXNotRecognizedException

Base class for deriving an XML filter.

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.

Author
David Megginson
Since
1.4, SAX 2.0
See Also
org.xml.sax.XMLFilter, org.xml.sax.XMLReader, org.xml.sax.EntityResolver, org.xml.sax.DTDHandler, org.xml.sax.ContentHandler, org.xml.sax.ErrorHandler

Field Summary

Modifier and TypeField and Description
private ContentHandler
private DTDHandler
private EntityResolver
private ErrorHandler
private Locator
private XMLReader

Constructor Summary

AccessConstructor and Description
public
XMLFilterImpl()

Construct an empty XML filter, with no parent.

public
XMLFilterImpl(XMLReader
the specified parent
parent
)

Construct an XML filter with the specified parent.

Method Summary

Modifier and TypeMethod and Description
public void
characters(char[]
An array of characters.
ch
,
int
The starting position in the array.
start
,
int
The number of characters to use from the array.
length
)

Implements org.xml.sax.ContentHandler.characters.

Filter a character data event.

public void
endDocument()

Implements org.xml.sax.ContentHandler.endDocument.

Filter an end document event.

public void
endElement(String
The element's Namespace URI, or the empty string.
uri
,
String
The element's local name, or the empty string.
localName
,
String
The element's qualified (prefixed) name, or the empty string.
qName
)

Implements org.xml.sax.ContentHandler.endElement.

Filter an end element event.

public void
endPrefixMapping(String
The Namespace prefix.
prefix
)

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Filter an end Namespace prefix mapping event.

public void
error(SAXParseException
The error as an exception.
e
)

Implements org.xml.sax.ErrorHandler.error.

Filter an error event.

public void
fatalError(SAXParseException
The error as an exception.
e
)

Implements org.xml.sax.ErrorHandler.fatalError.

Filter a fatal error event.

public ContentHandler

Returns:

The current content handler, or null if none was set.
getContentHandler
()

Implements org.xml.sax.XMLReader.getContentHandler.

Get the content event handler.

public DTDHandler

Returns:

The current DTD handler, or null if none was set.
getDTDHandler
()

Implements org.xml.sax.XMLReader.getDTDHandler.

Get the current DTD event handler.

public EntityResolver

Returns:

The current entity resolver, or null if none was set.
getEntityResolver
()

Implements org.xml.sax.XMLReader.getEntityResolver.

Get the current entity resolver.

public ErrorHandler

Returns:

The current error handler, or null if none was set.
getErrorHandler
()

Implements org.xml.sax.XMLReader.getErrorHandler.

Get the current error event handler.

public boolean

Returns:

The current value of the feature.
getFeature
(String
The feature name.
name
)

Implements org.xml.sax.XMLReader.getFeature.

Look up the value of a feature.

public XMLReader

Returns:

The parent XML reader, or null if none is set.
getParent
()

Implements org.xml.sax.XMLFilter.getParent.

Get the parent reader.

public Object

Returns:

The current value of the property.
getProperty
(String
The property name.
name
)

Implements org.xml.sax.XMLReader.getProperty.

Look up the value of a property.

public void
ignorableWhitespace(char[]
An array of characters.
ch
,
int
The starting position in the array.
start
,
int
The number of characters to use from the array.
length
)

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Filter an ignorable whitespace event.

public void
notationDecl(String
The notation name.
name
,
String
The notation's public identifier, or null.
publicId
,
String
The notation's system identifier, or null.
systemId
)

Implements org.xml.sax.DTDHandler.notationDecl.

Filter a notation declaration event.

public void
parse(InputSource
The input source for the document entity.
input
)

Implements org.xml.sax.XMLReader.parse.

Parse a document.

public void
parse(String
The system identifier as a fully-qualified URI.
systemId
)

Implements org.xml.sax.XMLReader.parse.

Parse a document.

public void
processingInstruction(String
The processing instruction target.
target
,
String
The text following the target.
data
)

Implements org.xml.sax.ContentHandler.processingInstruction.

Filter a processing instruction event.

public InputSource

Returns:

A new InputSource or null for the default.
resolveEntity
(String
The entity's public identifier, or null.
publicId
,
String
The entity's system identifier.
systemId
)

Implements org.xml.sax.EntityResolver.resolveEntity.

Filter an external entity resolution.

public void
setContentHandler(ContentHandler
the new content handler
handler
)

Implements org.xml.sax.XMLReader.setContentHandler.

Set the content event handler.

public void
setDocumentLocator(Locator
The document locator.
locator
)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Filter a new document locator event.

public void
setDTDHandler(DTDHandler
the new DTD handler
handler
)

Implements org.xml.sax.XMLReader.setDTDHandler.

Set the DTD event handler.

public void
setEntityResolver(EntityResolver
The new entity resolver.
resolver
)

Implements org.xml.sax.XMLReader.setEntityResolver.

Set the entity resolver.

public void
setErrorHandler(ErrorHandler
the new error handler
handler
)

Implements org.xml.sax.XMLReader.setErrorHandler.

Set the error event handler.

public void
setFeature(String
The feature name.
name
,
boolean
The requested feature value.
value
)

Implements org.xml.sax.XMLReader.setFeature.

Set the value of a feature.

public void
setParent(XMLReader
The parent XML reader.
parent
)

Implements org.xml.sax.XMLFilter.setParent.

Set the parent reader.

public void
setProperty(String
The property name.
name
,
Object
The requested property value.
value
)

Implements org.xml.sax.XMLReader.setProperty.

Set the value of a property.

private void
setupParse()

Set up before a parse.

public void
skippedEntity(String
The name of the skipped entity.
name
)

Implements org.xml.sax.ContentHandler.skippedEntity.

Filter a skipped entity event.

public void
startDocument()

Implements org.xml.sax.ContentHandler.startDocument.

Filter a start document event.

public void
startElement(String
The element's Namespace URI, or the empty string.
uri
,
String
The element's local name, or the empty string.
localName
,
String
The element's qualified (prefixed) name, or the empty string.
qName
,
Attributes
The element's attributes.
atts
)

Implements org.xml.sax.ContentHandler.startElement.

Filter a start element event.

public void
startPrefixMapping(String
The Namespace prefix.
prefix
,
String
The Namespace URI.
uri
)

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Filter a start Namespace prefix mapping event.

public void
unparsedEntityDecl(String
The entity name.
name
,
String
The entity's public identifier, or null.
publicId
,
String
The entity's system identifier, or null.
systemId
,
String
The name of the associated notation.
notationName
)

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Filter an unparsed entity declaration event.

public void
warning(SAXParseException
The warning as an exception.
e
)

Implements org.xml.sax.ErrorHandler.warning.

Filter a warning event.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentHandlerback to summary
private ContentHandler contentHandler
dtdHandlerback to summary
private DTDHandler dtdHandler
entityResolverback to summary
private EntityResolver entityResolver
errorHandlerback to summary
private ErrorHandler errorHandler
locatorback to summary
private Locator locator
parentback to summary
private XMLReader parent

Constructor Detail

XMLFilterImplback to summary
public XMLFilterImpl()

Construct an empty XML filter, with no parent.

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.

See Also
org.xml.sax.XMLReader#setFeature, org.xml.sax.XMLReader#setProperty, setParent
XMLFilterImplback to summary
public XMLFilterImpl(XMLReader parent)

Construct an XML filter with the specified parent.

Parameters
parent:XMLReader

the specified parent

See Also
setParent, getParent

Method Detail

charactersback to summary
public void characters(char[] ch, int start, int length) throws SAXException

Implements org.xml.sax.ContentHandler.characters.

Filter a character data event.

Parameters
ch:char[]

An array of characters.

start:int

The starting position in the array.

length:int

The number of characters to use from the array.

Exceptions
SAXException:
The client may throw an exception during processing.
endDocumentback to summary
public void endDocument() throws SAXException

Implements org.xml.sax.ContentHandler.endDocument.

Filter an end document event.

Exceptions
SAXException:
The client may throw an exception during processing.
endElementback to summary
public void endElement(String uri, String localName, String qName) throws SAXException

Implements org.xml.sax.ContentHandler.endElement.

Filter an end element event.

Parameters
uri:String

The element's Namespace URI, or the empty string.

localName:String

The element's local name, or the empty string.

qName:String

The element's qualified (prefixed) name, or the empty string.

Exceptions
SAXException:
The client may throw an exception during processing.
endPrefixMappingback to summary
public void endPrefixMapping(String prefix) throws SAXException

Implements org.xml.sax.ContentHandler.endPrefixMapping.

Filter an end Namespace prefix mapping event.

Parameters
prefix:String

The Namespace prefix.

Exceptions
SAXException:
The client may throw an exception during processing.
errorback to summary
public void error(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.error.

Filter an error event.

Parameters
e:SAXParseException

The error as an exception.

Exceptions
SAXException:
The client may throw an exception during processing.
fatalErrorback to summary
public void fatalError(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.fatalError.

Filter a fatal error event.

Parameters
e:SAXParseException

The error as an exception.

Exceptions
SAXException:
The client may throw an exception during processing.
getContentHandlerback to summary
public ContentHandler getContentHandler()

Implements org.xml.sax.XMLReader.getContentHandler.

Get the content event handler.

Returns:ContentHandler

The current content handler, or null if none was set.

getDTDHandlerback to summary
public DTDHandler getDTDHandler()

Implements org.xml.sax.XMLReader.getDTDHandler.

Get the current DTD event handler.

Returns:DTDHandler

The current DTD handler, or null if none was set.

getEntityResolverback to summary
public EntityResolver getEntityResolver()

Implements org.xml.sax.XMLReader.getEntityResolver.

Get the current entity resolver.

Returns:EntityResolver

The current entity resolver, or null if none was set.

getErrorHandlerback to summary
public ErrorHandler getErrorHandler()

Implements org.xml.sax.XMLReader.getErrorHandler.

Get the current error event handler.

Returns:ErrorHandler

The current error handler, or null if none was set.

getFeatureback to summary
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException

Implements org.xml.sax.XMLReader.getFeature.

Look up the value of a feature.

This will always fail if the parent is null.

Parameters
name:String

The feature name.

Returns:boolean

The current value of the feature.

Exceptions
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.
getParentback to summary
public XMLReader getParent()

Implements org.xml.sax.XMLFilter.getParent.

Get the parent reader.

Returns:XMLReader

The parent XML reader, or null if none is set.

See Also
setParent
getPropertyback to summary
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException

Implements org.xml.sax.XMLReader.getProperty.

Look up the value of a property.

Parameters
name:String

The property name.

Returns:Object

The current value of the property.

Exceptions
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.
ignorableWhitespaceback to summary
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException

Implements org.xml.sax.ContentHandler.ignorableWhitespace.

Filter an ignorable whitespace event.

Parameters
ch:char[]

An array of characters.

start:int

The starting position in the array.

length:int

The number of characters to use from the array.

Exceptions
SAXException:
The client may throw an exception during processing.
notationDeclback to summary
public void notationDecl(String name, String publicId, String systemId) throws SAXException

Implements org.xml.sax.DTDHandler.notationDecl.

Filter a notation declaration event.

Parameters
name:String

The notation name.

publicId:String

The notation's public identifier, or null.

systemId:String

The notation's system identifier, or null.

Exceptions
SAXException:
The client may throw an exception during processing.
parseback to summary
public void parse(InputSource input) throws SAXException, IOException

Implements org.xml.sax.XMLReader.parse.

Parse a document.

Parameters
input:InputSource

The input source for the document entity.

Exceptions
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.
parseback to summary
public void parse(String systemId) throws SAXException, IOException

Implements org.xml.sax.XMLReader.parse.

Parse a document.

Parameters
systemId:String

The system identifier as a fully-qualified URI.

Exceptions
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.
processingInstructionback to summary
public void processingInstruction(String target, String data) throws SAXException

Implements org.xml.sax.ContentHandler.processingInstruction.

Filter a processing instruction event.

Parameters
target:String

The processing instruction target.

data:String

The text following the target.

Exceptions
SAXException:
The client may throw an exception during processing.
resolveEntityback to summary
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException

Implements org.xml.sax.EntityResolver.resolveEntity.

Filter an external entity resolution.

Parameters
publicId:String

The entity's public identifier, or null.

systemId:String

The entity's system identifier.

Returns:InputSource

A new InputSource or null for the default.

Exceptions
SAXException:
The client may throw an exception during processing.
IOException:
The client may throw an I/O-related exception while obtaining the new InputSource.
setContentHandlerback to summary
public void setContentHandler(ContentHandler handler)

Implements org.xml.sax.XMLReader.setContentHandler.

Set the content event handler.

Parameters
handler:ContentHandler

the new content handler

setDocumentLocatorback to summary
public void setDocumentLocator(Locator locator)

Implements org.xml.sax.ContentHandler.setDocumentLocator.

Filter a new document locator event.

Parameters
locator:Locator

The document locator.

setDTDHandlerback to summary
public void setDTDHandler(DTDHandler handler)

Implements org.xml.sax.XMLReader.setDTDHandler.

Set the DTD event handler.

Parameters
handler:DTDHandler

the new DTD handler

setEntityResolverback to summary
public void setEntityResolver(EntityResolver resolver)

Implements org.xml.sax.XMLReader.setEntityResolver.

Set the entity resolver.

Parameters
resolver:EntityResolver

The new entity resolver.

setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler handler)

Implements org.xml.sax.XMLReader.setErrorHandler.

Set the error event handler.

Parameters
handler:ErrorHandler

the new error handler

setFeatureback to summary
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException

Implements org.xml.sax.XMLReader.setFeature.

Set the value of a feature.

This will always fail if the parent is null.

Parameters
name:String

The feature name.

value:boolean

The requested feature value.

Exceptions
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.
setParentback to summary
public void setParent(XMLReader parent)

Implements org.xml.sax.XMLFilter.setParent.

Set the parent reader.

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.

Parameters
parent:XMLReader

The parent XML reader.

See Also
getParent
setPropertyback to summary
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException

Implements org.xml.sax.XMLReader.setProperty.

Set the value of a property.

This will always fail if the parent is null.

Parameters
name:String

The property name.

value:Object

The requested property value.

Exceptions
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.
setupParseback to summary
private void setupParse()

Set up before a parse.

Before every parse, check whether the parent is non-null, and re-register the filter for all of the events.

skippedEntityback to summary
public void skippedEntity(String name) throws SAXException

Implements org.xml.sax.ContentHandler.skippedEntity.

Filter a skipped entity event.

Parameters
name:String

The name of the skipped entity.

Exceptions
SAXException:
The client may throw an exception during processing.
startDocumentback to summary
public void startDocument() throws SAXException

Implements org.xml.sax.ContentHandler.startDocument.

Filter a start document event.

Exceptions
SAXException:
The client may throw an exception during processing.
startElementback to summary
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException

Implements org.xml.sax.ContentHandler.startElement.

Filter a start element event.

Parameters
uri:String

The element's Namespace URI, or the empty string.

localName:String

The element's local name, or the empty string.

qName:String

The element's qualified (prefixed) name, or the empty string.

atts:Attributes

The element's attributes.

Exceptions
SAXException:
The client may throw an exception during processing.
startPrefixMappingback to summary
public void startPrefixMapping(String prefix, String uri) throws SAXException

Implements org.xml.sax.ContentHandler.startPrefixMapping.

Filter a start Namespace prefix mapping event.

Parameters
prefix:String

The Namespace prefix.

uri:String

The Namespace URI.

Exceptions
SAXException:
The client may throw an exception during processing.
unparsedEntityDeclback to summary
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException

Implements org.xml.sax.DTDHandler.unparsedEntityDecl.

Filter an unparsed entity declaration event.

Parameters
name:String

The entity name.

publicId:String

The entity's public identifier, or null.

systemId:String

The entity's system identifier, or null.

notationName:String

The name of the associated notation.

Exceptions
SAXException:
The client may throw an exception during processing.
warningback to summary
public void warning(SAXParseException e) throws SAXException

Implements org.xml.sax.ErrorHandler.warning.

Filter a warning event.

Parameters
e:SAXParseException

The warning as an exception.

Exceptions
SAXException:
The client may throw an exception during processing.