01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: EasyBeansErrorHandler.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.util.xml;
25:
26: import org.xml.sax.ErrorHandler;
27: import org.xml.sax.SAXException;
28: import org.xml.sax.SAXParseException;
29:
30: /**
31: * Define an error handler which throw an exception as Digester not (only print
32: * stack trace). This handler is use for throwing/catching in a convenient way
33: * the xml parsing error of xml file.
34: * @author Florent Benoit
35: */
36: public class EasyBeansErrorHandler implements ErrorHandler {
37:
38: /**
39: * Receive notification of a warning.
40: * @param exception exception to throw
41: * @throws SAXException if an error is thrown
42: */
43: public void warning(final SAXParseException exception)
44: throws SAXException {
45:
46: }
47:
48: /**
49: * Receive notification of a recoverable error.
50: * @param exception exception to throw
51: * @throws SAXException if an error is thrown
52: */
53: public void error(final SAXParseException exception)
54: throws SAXException {
55: throw new SAXException("Parse Fatal Error at line "
56: + exception.getLineNumber() + " column "
57: + exception.getColumnNumber() + ": "
58: + exception.getMessage());
59: }
60:
61: /**
62: * Receive notification of a non-recoverable error.
63: * @param exception exception to throw
64: * @throws SAXException if an error is thrown
65: */
66: public void fatalError(final SAXParseException exception)
67: throws SAXException {
68: throw new SAXException("Parse Fatal Error at line "
69: + exception.getLineNumber() + " column "
70: + exception.getColumnNumber() + ": "
71: + exception.getMessage());
72: }
73:
74: }
|