1 16 package org.apache.myfaces.util.xml; 17 18 import org.apache.commons.logging.Log; 19 import org.xml.sax.ErrorHandler ; 20 import org.xml.sax.SAXParseException ; 21 22 27 public class MyFacesErrorHandler 28 implements ErrorHandler 29 { 30 private Log _log; 31 32 public MyFacesErrorHandler(Log log) 33 { 34 _log = log; 35 } 36 37 public void warning(SAXParseException exception) 38 { 39 if (_log.isWarnEnabled()) _log.warn(getMessage(exception), exception); 40 } 41 42 public void error(SAXParseException exception) 43 { 44 _log.error(getMessage(exception), exception); 45 } 46 47 public void fatalError(SAXParseException exception) 48 { 49 _log.fatal(getMessage(exception), exception); 50 } 51 52 private String getMessage(SAXParseException exception) 53 { 54 StringBuffer buf = new StringBuffer (); 55 buf.append("SAXParseException at"); 56 buf.append(" URI="); 57 buf.append(exception.getSystemId()); 58 buf.append(" Line="); 59 buf.append(exception.getLineNumber()); 60 buf.append(" Column="); 61 buf.append(exception.getColumnNumber()); 62 return buf.toString(); 63 } 64 65 } 66 | Popular Tags |