1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.shared_orchestra.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
27
28
29
30 public class MyFacesErrorHandler
31 implements ErrorHandler
32 {
33 private Log _log;
34
35 public MyFacesErrorHandler(Log log)
36 {
37 _log = log;
38 }
39
40 public void warning(SAXParseException exception)
41 {
42 if (_log.isWarnEnabled()) _log.warn(getMessage(exception), exception);
43 }
44
45 public void error(SAXParseException exception)
46 {
47 _log.error(getMessage(exception), exception);
48 }
49
50 public void fatalError(SAXParseException exception)
51 {
52 _log.fatal(getMessage(exception), exception);
53 }
54
55 private String getMessage(SAXParseException exception)
56 {
57 StringBuffer buf = new StringBuffer();
58 buf.append("SAXParseException at");
59 buf.append(" URI=");
60 buf.append(exception.getSystemId());
61 buf.append(" Line=");
62 buf.append(exception.getLineNumber());
63 buf.append(" Column=");
64 buf.append(exception.getColumnNumber());
65 return buf.toString();
66 }
67
68 }