KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > ParsingErrors


1 /*
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11 package org.enhydra.jawe.xml;
12
13 import java.util.*;
14
15 import org.xml.sax.*;
16
17 /**
18  * Class that serves as an ErrorHandler for DOM parser.
19  */

20 public class ParsingErrors implements ErrorHandler {
21
22    public ParsingErrors () {
23       super();
24    }
25
26    Set errorMessages = new HashSet();
27
28    public void warning(SAXParseException ex) {
29       store(ex, "[Warning]");
30    }
31
32    public void error(SAXParseException ex) {
33       store(ex, "[Error]");
34    }
35
36    public void fatalError(SAXParseException ex) throws SAXException {
37       store(ex, "[Fatal Error]");
38    }
39
40    public Set getErrorMessages() {
41       return errorMessages;
42    }
43
44    public void clearErrors() {
45       errorMessages.clear();
46    }
47
48    void store(SAXParseException ex, String JavaDoc type) {
49       // build error text
50
String JavaDoc errorString= type+" at line number "+ex.getLineNumber()
51          +": "+ex.getMessage()+"\n";
52       errorMessages.add(errorString);
53    }
54 }
55
Popular Tags