KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > xml > CmsXmlErrorHandler


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/xml/CmsXmlErrorHandler.java,v $
3  * Date : $Date: 2006/03/27 14:52:20 $
4  * Version: $Revision: 1.8 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.xml;
33
34 import org.opencms.main.CmsLog;
35
36 import org.apache.commons.logging.Log;
37
38 import org.xml.sax.ErrorHandler JavaDoc;
39 import org.xml.sax.SAXException JavaDoc;
40 import org.xml.sax.SAXParseException JavaDoc;
41
42 /**
43  * Error hander for writing errors found during XML validation to the OpenCms log.<p>
44  *
45  * Exceptions caused by warnings are suppressed (but written to the log if level is set to WARN).<p>
46  *
47  * @author Michael Emmerich
48  *
49  * @version $Revision: 1.8 $
50  *
51  * @since 6.0.0
52  */

53 public class CmsXmlErrorHandler implements ErrorHandler JavaDoc {
54
55     /** The log object for this class. */
56     private static final Log LOG = CmsLog.getLog(CmsXmlErrorHandler.class);
57
58     /**
59      * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
60      */

61     public void error(SAXParseException JavaDoc exception) throws SAXException JavaDoc {
62
63         LOG.error(Messages.get().getBundle().key(Messages.LOG_PARSING_XML_RESOURCE_ERROR_0), exception);
64         throw exception;
65     }
66
67     /**
68      * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
69      */

70     public void fatalError(SAXParseException JavaDoc exception) throws SAXException JavaDoc {
71
72         LOG.error(Messages.get().getBundle().key(Messages.LOG_PARSING_XML_RESOURCE_FATAL_ERROR_0), exception);
73         throw exception;
74     }
75
76     /**
77      * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
78      */

79     public void warning(SAXParseException JavaDoc exception) {
80
81         if (LOG.isWarnEnabled()) {
82             LOG.error(Messages.get().getBundle().key(Messages.LOG_PARSING_XML_RESOURCE_WARNING_0), exception);
83         }
84     }
85 }
86
Popular Tags