SimpleErrorHandler.java
01 /*
02  *  SimpleErrorHandle.java
03  *
04  *  Copyright (c) 1995-2010, The University of Sheffield. See the file
05  *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06  *
07  *  This file is part of GATE (see http://gate.ac.uk/), and is free
08  *  software, licenced under the GNU Library General Public License,
09  *  Version 2, June 1991 (in the distribution as file licence.html,
10  *  and also available at http://gate.ac.uk/gate/licence.html).
11  *
12  *  Cristian URSU,  8/May/2000
13  *
14  *  $Id: SimpleErrorHandler.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15  */
16 
17 package gate.xml;
18 
19 import org.xml.sax.*;
20 
21 import gate.util.GateSaxException;
22 import gate.util.Out;
23 
24 public class SimpleErrorHandler implements ErrorHandler {
25 
26   /** Debug flag */
27   private static final boolean DEBUG = false;
28 
29   /**
30     * SimpleErrorHandler constructor comment.
31     */
32   public SimpleErrorHandler() {
33     super();
34   }
35 
36   /**
37     * This error method is called by the SAX parser when it encounts a
38     * recoverable(can continue parsing) error.
39     */
40   public void error(SAXParseException exthrows SAXException {
41     String systemId = "not available";
42     String publicId = "not available";
43     if (ex.getSystemId() != nullsystemId = ex.getSystemId();
44     if (ex.getPublicId() != nullpublicId = ex.getPublicId();
45     Out.prln("\nSAX parser recoverable error. Error details: \n"+
46                                 " Message: " + ex.getMessage() "\n" +
47                                 " System ID: " + systemId +  "\n" +
48                                 " Public ID: " + publicId +  "\n" +
49                                 " Line: " + ex.getLineNumber() "\n" +
50                                 " Column: "+ ex.getColumnNumber() "\n");
51   }// error
52   /**
53     * This fatalError method is called by the SAX parser when it encounts a
54     * fatal(can't continue parsing) error.
55     */
56   public void fatalError(SAXParseException exthrows SAXException{
57     String systemId = "not available";
58     String publicId = "not available";
59     if (ex.getSystemId() != nullsystemId = ex.getSystemId();
60     if (ex.getPublicId() != nullpublicId = ex.getPublicId();
61     throw new GateSaxException("Fatal XML parse error. Error details: \n"+
62                                 " Message: " + ex.getMessage() "\n" +
63                                 " System ID: " + systemId +  "\n" +
64                                 " Public ID: " + publicId +  "\n" +
65                                 " Line: " + ex.getLineNumber() "\n" +
66                                 " Column: "+ ex.getColumnNumber());
67   }// fatalError
68   /**
69     * This warning is called by the SAX parser when there is the danger of a
70     * confusion.
71     */
72   public void warning(SAXParseException exthrows SAXException {
73     String systemId = "not available";
74     String publicId = "not available";
75     if (ex.getSystemId() != nullsystemId = ex.getSystemId();
76     if (ex.getPublicId() != nullpublicId = ex.getPublicId();
77     Out.prln("SAX parser warning. Warning details: \n"+
78                                 " Message: " + ex.getMessage() "\n" +
79                                 " System ID: " + systemId +  "\n" +
80                                 " Public ID: " + publicId +  "\n" +
81                                 " Line: " + ex.getLineNumber() "\n" +
82                                 " Column: "+ ex.getColumnNumber());
83   }// warning
84 }// end class SimpleErrorHandler