01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: LoggingErrorRedirector.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.xml;
09:
10: import java.util.ArrayList;
11: import java.util.Collection;
12: import org.xml.sax.SAXParseException;
13:
14: public class LoggingErrorRedirector extends XmlErrorRedirector {
15: private ArrayList<SAXParseException> mWarnings = new ArrayList<SAXParseException>();
16: private ArrayList<SAXParseException> mErrors = new ArrayList<SAXParseException>();
17: private ArrayList<SAXParseException> mFatalErrors = new ArrayList<SAXParseException>();
18:
19: public LoggingErrorRedirector() {
20: }
21:
22: public synchronized void warning(SAXParseException e) {
23: if (null == mWarnings) {
24: mWarnings = new ArrayList<SAXParseException>();
25: }
26: mWarnings.add(e);
27: }
28:
29: public synchronized void error(SAXParseException e) {
30: if (null == mErrors) {
31: mErrors = new ArrayList<SAXParseException>();
32: }
33: mErrors.add(e);
34: }
35:
36: public synchronized void fatalError(SAXParseException e) {
37: if (null == mFatalErrors) {
38: mFatalErrors = new ArrayList<SAXParseException>();
39: }
40: mFatalErrors.add(e);
41: }
42:
43: public Collection<SAXParseException> getWarnings() {
44: return mWarnings;
45: }
46:
47: public Collection<SAXParseException> getErrors() {
48: return mErrors;
49: }
50:
51: public Collection<SAXParseException> getFatalErrors() {
52: return mFatalErrors;
53: }
54:
55: public boolean hasWarnings() {
56: if (mWarnings != null && !mWarnings.isEmpty()) {
57: return true;
58: }
59:
60: return false;
61: }
62:
63: public boolean hasErrors() {
64: if (mErrors != null && !mErrors.isEmpty()) {
65: return true;
66: }
67:
68: return false;
69: }
70:
71: public boolean hasFatalErrors() {
72: if (mFatalErrors != null && !mFatalErrors.isEmpty()) {
73: return true;
74: }
75:
76: return false;
77: }
78: }
|