View Javadoc

1   package org.devaki.nextobjects.util;
2   /*
3    *  nextobjects Copyright (C) 2001-2005 Emmanuel Florent
4    *  This program is free software; you can redistribute it and/or modify
5    *  it under the terms of the GNU General Public License as published by the
6    *  Free Software Foundation; either version 2 of the License, or (at your
7    *  option) any later version.
8    *  This program is distributed in the hope that it will
9    *  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10   *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   *  PURPOSE. See the GNU General Public License for more details.
12   *  You should have received a copy of the GNU General Public License along
13   *  with this program; if not, write to the Free Software Foundation, Inc., 59
14   *  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15   */
16  import org.apache.commons.logging.Log;
17  import org.apache.commons.logging.LogFactory;
18  import org.xml.sax.ErrorHandler;
19  import org.xml.sax.SAXException;
20  import org.xml.sax.SAXParseException;
21  /***
22   *  Implementation of ErrorHandler interface
23   * @author     <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
24   * */
25  class NOErrorHandler implements ErrorHandler
26  {
27      /*** The logger */
28      private static Log logger =
29          LogFactory.getLog(NOErrorHandler.class.getName());
30      /***
31       * warning
32       * @param exception the exception
33       * @throws SAXException sax exception
34       */
35      public final void warning(final SAXParseException exception)
36          throws SAXException
37      {
38          logger.warn(
39              exception.getMessage() + " Line: " + exception.getLineNumber());
40          throw new SAXException("Warning encountered");
41      }
42      /***
43       * error
44       * @param exception the exception
45       * @throws SAXException sax exception
46       */
47      public final void error(final SAXParseException exception)
48          throws SAXException
49      {
50          logger.error(
51              exception.getMessage() + " Line: " + exception.getLineNumber());
52          throw new SAXException("Error encountered");
53      }
54      /***
55       * fatal Error
56       * @param exception the exception
57       * @throws SAXException sax exception
58       */
59      public final void fatalError(final SAXParseException exception)
60          throws SAXException
61      {
62          logger.error(
63              exception.getMessage() + " Line: " + exception.getLineNumber());
64          logger.error("I give up");
65          throw new SAXException("Fatal Error encountered");
66      }
67  }