1 /***
2 * This program is licensed under Common Public License Version 0.5.
3 *
4 * For License Information and conditions of use, see "LICENSE" in packaged
5 */
6
7 package net.wangs.xmlutil;
8
9 import org.xml.sax.helpers.*;
10
11 import org.xml.sax.SAXException;
12 import org.xml.sax.SAXParseException;
13 import java.util.Vector;
14 /***
15 * @author <a href="mailto:yuqingwang_99@yahoo.com">Yuqing Wang</a>
16 */
17 public class SAXErrorHandlerImpl extends DefaultHandler {
18
19
20 Vector errors = new Vector();
21
22 public void warning(SAXParseException ex) {
23 store(ex, "[Warning]");
24 }
25
26 public void error(SAXParseException ex) {
27 store(ex, "[Error]");
28 }
29
30 public void fatalError(SAXParseException ex) throws SAXException {
31 store(ex, "[Fatal Error]");
32 }
33
34 public Vector getErrors() {
35 return errors;
36 }
37
38 public void clearErrors() {
39 errors.clear();
40 }
41
42 void store(SAXParseException ex, String type) {
43
44
45 String errorString= type+" at line number, "+ex.getLineNumber()
46 +": "+ex.getMessage()+"\n";
47
48 System.out.println(errorString);
49
50 errors.add(errorString);
51 }
52
53 }
54