KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > util > xml > SimpleSaxErrorHandler


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.util.xml;
18
19 import org.apache.commons.logging.Log;
20 import org.xml.sax.ErrorHandler JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22 import org.xml.sax.SAXParseException JavaDoc;
23
24 /**
25  * Simple <code>org.xml.sax.ErrorHandler</code> implementation:
26  * logs warnings using the given Commons Logging logger instance,
27  * and rethrows errors to discontinue the XML transformation.
28  *
29  * @author Juergen Hoeller
30  * @since 1.2
31  */

32 public class SimpleSaxErrorHandler implements ErrorHandler JavaDoc {
33
34     private final Log logger;
35
36
37     /**
38      * Create a new SimpleSaxErrorHandler for the given
39      * Commons Logging logger instance.
40      */

41     public SimpleSaxErrorHandler(Log logger) {
42         this.logger = logger;
43     }
44
45
46     public void warning(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
47         logger.warn("Ignored XML validation warning", ex);
48     }
49
50     public void error(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
51         throw ex;
52     }
53
54     public void fatalError(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
55         throw ex;
56     }
57
58 }
59
Popular Tags