< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/ErrorHandlerProxy.java

Print this page




  23 
  24 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  25 import org.xml.sax.ErrorHandler;
  26 import org.xml.sax.SAXException;
  27 import org.xml.sax.SAXParseException;
  28 
  29 /**
  30  * Wraps {@link XMLErrorHandler} and make it look like a SAX {@link ErrorHandler}.
  31  *
  32  * <p>
  33  * The derived class should override the {@link #getErrorHandler()} method
  34  * so that it will return the correct {@link XMLErrorHandler} instance.
  35  * This method will be called whenever an error/warning is found.
  36  *
  37  * <p>
  38  * Experience shows that it is better to store the actual
  39  * {@link XMLErrorHandler} in one place and looks up that variable,
  40  * rather than copying it into every component that needs an error handler
  41  * and update all of them whenever it is changed, IMO.
  42  *
  43  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  44  *
  45  */
  46 public abstract class ErrorHandlerProxy implements ErrorHandler {
  47 
  48     public void error(SAXParseException e) throws SAXException {
  49         XMLErrorHandler eh = getErrorHandler();
  50         if (eh instanceof ErrorHandlerWrapper) {
  51             ((ErrorHandlerWrapper)eh).fErrorHandler.error(e);
  52         }
  53         else {
  54             eh.error("","",ErrorHandlerWrapper.createXMLParseException(e));
  55         }
  56         // if an XNIException is thrown, just let it go.
  57         // REVISIT: is this OK? or should we try to wrap it into SAXException?
  58     }
  59 
  60     public void fatalError(SAXParseException e) throws SAXException {
  61         XMLErrorHandler eh = getErrorHandler();
  62         if (eh instanceof ErrorHandlerWrapper) {
  63             ((ErrorHandlerWrapper)eh).fErrorHandler.fatalError(e);


  23 
  24 import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
  25 import org.xml.sax.ErrorHandler;
  26 import org.xml.sax.SAXException;
  27 import org.xml.sax.SAXParseException;
  28 
  29 /**
  30  * Wraps {@link XMLErrorHandler} and make it look like a SAX {@link ErrorHandler}.
  31  *
  32  * <p>
  33  * The derived class should override the {@link #getErrorHandler()} method
  34  * so that it will return the correct {@link XMLErrorHandler} instance.
  35  * This method will be called whenever an error/warning is found.
  36  *
  37  * <p>
  38  * Experience shows that it is better to store the actual
  39  * {@link XMLErrorHandler} in one place and looks up that variable,
  40  * rather than copying it into every component that needs an error handler
  41  * and update all of them whenever it is changed, IMO.
  42  *
  43  * @author Kohsuke Kawaguchi
  44  *
  45  */
  46 public abstract class ErrorHandlerProxy implements ErrorHandler {
  47 
  48     public void error(SAXParseException e) throws SAXException {
  49         XMLErrorHandler eh = getErrorHandler();
  50         if (eh instanceof ErrorHandlerWrapper) {
  51             ((ErrorHandlerWrapper)eh).fErrorHandler.error(e);
  52         }
  53         else {
  54             eh.error("","",ErrorHandlerWrapper.createXMLParseException(e));
  55         }
  56         // if an XNIException is thrown, just let it go.
  57         // REVISIT: is this OK? or should we try to wrap it into SAXException?
  58     }
  59 
  60     public void fatalError(SAXParseException e) throws SAXException {
  61         XMLErrorHandler eh = getErrorHandler();
  62         if (eh instanceof ErrorHandlerWrapper) {
  63             ((ErrorHandlerWrapper)eh).fErrorHandler.fatalError(e);
< prev index next >