01: package org.enhydra.shark.xpdl;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.xml.sax.ErrorHandler;
07: import org.xml.sax.SAXException;
08: import org.xml.sax.SAXParseException;
09:
10: /**
11: * Class that serves as an ErrorHandler for DOM parser.
12: * @author Sasa Bojanic
13: */
14: public class ParsingErrors implements ErrorHandler {
15:
16: public static String ERROR = "[Error]";
17: public static String WARNING = "[Warning]";
18: public static String FATAL_ERROR = "[Fatal Error]";
19: public static String AT_LINE_NO_STRING = " at line number ";
20:
21: public ParsingErrors() {
22: super ();
23: }
24:
25: List errorMessages = new ArrayList();
26:
27: public void warning(SAXParseException ex) {
28: store(ex, WARNING);
29: }
30:
31: public void error(SAXParseException ex) {
32: store(ex, ERROR);
33: }
34:
35: public void fatalError(SAXParseException ex) throws SAXException {
36: store(ex, FATAL_ERROR);
37: }
38:
39: public List getErrorMessages() {
40: return errorMessages;
41: }
42:
43: public void clearErrors() {
44: errorMessages.clear();
45: }
46:
47: void store(SAXParseException ex, String type) {
48: // build error text
49: String errorString = type + AT_LINE_NO_STRING
50: + ex.getLineNumber() + ": " + ex.getMessage() + "\n";
51: errorMessages.add(errorString);
52: }
53: }
|