Name
DefaultHandler
Synopsis
This helper class implements the four commonly-used
SAX handler interfaces from the org.xml.sax
package and defines stub implementations for all of their methods. It
is usually easier to subclass DefaultHandler and
override the desired methods than it is to implement all of the
interfaces (and all of their methods) from scratch.
DefaultHandler implements
ContentHandler, ErrorHandler,
EntityResolver and DTDHandler,
so you can pass an instance of this class, (or of a subclass you
define) to the setContentHandler( ),
setErrorHandler( ), setEntityResolver(
), and setDTDHandler( ) methods of an
XMLReader. You can also pass an instance of a
DefaultHandler subclass directly to one of the
parse( ) methods of a
javax.xml.parsers.SAXParser. The
SAXParser will take care of calling the four
relevant methods of its internal XMLReader.
All but two of the methods of DefaultHandler have
empty bodies and do nothing. The exceptions are
resolveEntity( ) which simply returns
null to tell the parser to resolve the entity
itself, and fatalError( ) which throws the
SAXParseException object that is passed to it.
Figure 22-15. org.xml.sax.helpers.DefaultHandler
public class DefaultHandler implements org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler { // Public Constructors public DefaultHandler( ); // Methods Implementing ContentHandler ...