FileDocCategorySizeDatePackage
ErrorHandlerProxy.javaAPI DocJava SE 6 API2893Tue Jun 10 00:22:50 BST 2008com.sun.org.apache.xerces.internal.util

ErrorHandlerProxy

public abstract class ErrorHandlerProxy extends Object implements ErrorHandler
Wraps {@link XMLErrorHandler} and make it look like a SAX {@link ErrorHandler}.

The derived class should override the {@link #getErrorHandler()} method so that it will return the correct {@link XMLErrorHandler} instance. This method will be called whenever an error/warning is found.

Experience shows that it is better to store the actual {@link XMLErrorHandler} in one place and looks up that variable, rather than copying it into every component that needs an error handler and update all of them whenever it is changed, IMO.

author
Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
version
$Id: ErrorHandlerProxy.java,v 1.2.6.1 2005/09/05 07:54:22 neerajbj Exp $

Fields Summary
Constructors Summary
Methods Summary
public voiderror(org.xml.sax.SAXParseException e)

        XMLErrorHandler eh = getErrorHandler();
        if (eh instanceof ErrorHandlerWrapper) {
            ((ErrorHandlerWrapper)eh).fErrorHandler.error(e);
        }
        else {
            eh.error("","",ErrorHandlerWrapper.createXMLParseException(e));
        }
        // if an XNIException is thrown, just let it go.
        // REVISIT: is this OK? or should we try to wrap it into SAXException?
    
public voidfatalError(org.xml.sax.SAXParseException e)

        XMLErrorHandler eh = getErrorHandler();
        if (eh instanceof ErrorHandlerWrapper) {
            ((ErrorHandlerWrapper)eh).fErrorHandler.fatalError(e);
        }
        else {
            eh.fatalError("","",ErrorHandlerWrapper.createXMLParseException(e));
        }
    
protected abstract com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandlergetErrorHandler()

public voidwarning(org.xml.sax.SAXParseException e)

        XMLErrorHandler eh = getErrorHandler();
        if (eh instanceof ErrorHandlerWrapper) {
            ((ErrorHandlerWrapper)eh).fErrorHandler.warning(e);
        }
        else {
            eh.warning("","",ErrorHandlerWrapper.createXMLParseException(e));
        }