And here comes DefaultHandler to the rescue. This
class doesn't define any behavior of its own; however, it does
implement ContentHandler,
ErrorHandler, EntityResolver,
and DTDHandler, and provides empty implementations
of each method of each interface. So you can have a single class
(call it, for example, MyHandlerClass) that
extends DefaultHandler. This class only needs to
override methods it needs to perform action in. You might implement
startElement( ), characters( ),
endElement( ), and fatalError(
), for example. In any combination of implemented methods,
though, you'll save tons of lines of code for methods you
don't need to provide action for, and make your code a lot
clearer too. Then, the argument to setErrorHandler(
), setContentHandler( ), and
setDTDHandler( ) would be the same instance of
this MyHandlerClass. Theoretically, you could pass
the instance to setEntityResolver( ) as well,
although (for about the fourth time!) I discourage mixing the
resolveEntity( ) method in with these other
interface methods.