Name
XMLFilter
Synopsis
An XMLFilter
extends
XMLReader
and behaves like an
XMLReader
except that instead of parsing a
document itself, it filters the SAX events provided by a
“parent”
XMLReader
object. Use the setParent(
)
method to link an XMLFilter
object to
the XMLReader
that it is to serve as a filter for.
An XMLFilter
serves as both a source of SAX
events, and also as a receipient of those events, so an
implementation must implement ContentHandler
and
related interfaces so that it can obtain events from the parent
object, filter them, and then pass the filtered events on to the
ContentHandler
object that was registered on the
filter. See the helper class
org.xml.sax.helpers.XMLFilterImpl
for a bare-bones
implementation of an XMLFilter
that implements the
XMLReader
interface and the
ContentHandler
and related handler interfaces.
XMLFilterImpl
does no filtering—it simply
passes passes all of its method invocations through. You can subclass
it and override only the methods that need filtering.
Figure 22-6. org.xml.sax.XMLFilter
public interface XMLFilter extends XMLReader { // Public Instance Methods XMLReader getParent( ); void setParent(XMLReader parent); }
Implementations
org.xml.sax.helpers.XMLFilterImpl
Returned By
javax.xml.transform.sax.SAXTransformerFactory.newXMLFilter(
)
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.