KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > xerces > SAXXMLErrorHandler


1 package com.thaiopensource.validate.xerces;
2
3 import org.apache.xerces.util.ErrorHandlerWrapper;
4 import org.apache.xerces.xni.parser.XMLParseException;
5 import org.apache.xerces.xni.XNIException;
6 import org.xml.sax.ErrorHandler JavaDoc;
7
8 class SAXXMLErrorHandler extends ErrorHandlerWrapper {
9   private boolean hadError = false;
10
11   SAXXMLErrorHandler(ErrorHandler JavaDoc errorHandler) {
12     super(errorHandler);
13   }
14
15   void reset() {
16     hadError = false;
17   }
18
19   public void error(String JavaDoc domain, String JavaDoc key,
20                     XMLParseException exception) throws XNIException {
21     hadError = true;
22     if (fErrorHandler == null)
23       return;
24     super.error(domain, key, exception);
25   }
26
27   public void warning(String JavaDoc domain, String JavaDoc key,
28                       XMLParseException exception) throws XNIException {
29     if (fErrorHandler == null)
30       return;
31     super.warning(domain, key, exception);
32   }
33
34   public void fatalError(String JavaDoc domain, String JavaDoc key,
35                          XMLParseException exception) throws XNIException {
36     hadError = true;
37     if (fErrorHandler == null)
38       return;
39     super.fatalError(domain, key, exception);
40   }
41
42   boolean getHadError() {
43     return hadError;
44   }
45 }
46
Popular Tags