corpus-services  1.0
ExbErrorReportGenerator.java
Go to the documentation of this file.
1 
10 package de.uni_hamburg.corpora.validation;
11 
13 import org.xml.sax.SAXException;
14 import org.xml.sax.SAXParseException;
15 import org.xml.sax.ErrorHandler;
16 
23 public class ExbErrorReportGenerator implements ErrorHandler {
24 
25  // store latest file name for laughs
26  private String currentFileName;
27  private Report stats;
28  final String EXB_SCHEMA = "exb-validate-schema";
29 
33  public ExbErrorReportGenerator(String fileName) {
34  super();
35  stats = new Report();
36  currentFileName = fileName;
37  }
38 
39  public Report getErrors() {
40  return stats;
41  }
42 
46  private void storeException(SAXParseException saxpe) {
47  // yeah this hack relies on parsing the localised(?) messages...
48  String msg = saxpe.getMessage();
49  String embeddedExceptions = saxpe.toString();
50  System.out.println(embeddedExceptions);
51  stats.addException(EXB_SCHEMA, saxpe, "In " + currentFileName + ", " + embeddedExceptions);
52  }
53 
58  public void fatalError(SAXParseException saxpe) throws SAXException {
59  storeException(saxpe);
60  }
61 
66  public void error(SAXParseException saxpe) throws SAXException {
67  storeException(saxpe);
68  }
69 
74  public void warning(SAXParseException saxpe) throws SAXException {
75  storeException(saxpe);
76 
77  }
78 }
79 
void addException(Throwable e, String description)
Definition: Report.java:287