Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MyFacesErrorHandler |
|
| 1.2;1.2 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, | |
13 | * software distributed under the License is distributed on an | |
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
15 | * KIND, either express or implied. See the License for the | |
16 | * specific language governing permissions and limitations | |
17 | * under the License. | |
18 | */ | |
19 | package org.apache.myfaces.shared_impl.util.xml; | |
20 | ||
21 | import org.apache.commons.logging.Log; | |
22 | import org.xml.sax.ErrorHandler; | |
23 | import org.xml.sax.SAXParseException; | |
24 | ||
25 | /** | |
26 | * Convenient error handler for xml sax parsing. | |
27 | * @author Manfred Geiler (latest modification by $Author: matzew $) | |
28 | * @version $Revision: 557350 $ $Date: 2007-07-18 13:19:50 -0500 (Wed, 18 Jul 2007) $ | |
29 | */ | |
30 | public class MyFacesErrorHandler | |
31 | implements ErrorHandler | |
32 | { | |
33 | private Log _log; | |
34 | ||
35 | public MyFacesErrorHandler(Log log) | |
36 | 0 | { |
37 | 0 | _log = log; |
38 | 0 | } |
39 | ||
40 | public void warning(SAXParseException exception) | |
41 | { | |
42 | 0 | if (_log.isWarnEnabled()) _log.warn(getMessage(exception), exception); |
43 | 0 | } |
44 | ||
45 | public void error(SAXParseException exception) | |
46 | { | |
47 | 0 | _log.error(getMessage(exception), exception); |
48 | 0 | } |
49 | ||
50 | public void fatalError(SAXParseException exception) | |
51 | { | |
52 | 0 | _log.fatal(getMessage(exception), exception); |
53 | 0 | } |
54 | ||
55 | private String getMessage(SAXParseException exception) | |
56 | { | |
57 | 0 | StringBuffer buf = new StringBuffer(); |
58 | 0 | buf.append("SAXParseException at"); |
59 | 0 | buf.append(" URI="); |
60 | 0 | buf.append(exception.getSystemId()); |
61 | 0 | buf.append(" Line="); |
62 | 0 | buf.append(exception.getLineNumber()); |
63 | 0 | buf.append(" Column="); |
64 | 0 | buf.append(exception.getColumnNumber()); |
65 | 0 | return buf.toString(); |
66 | } | |
67 | ||
68 | } |