1 16 package org.directwebremoting.util; 17 18 import org.xml.sax.ErrorHandler ; 19 import org.xml.sax.SAXParseException ; 20 21 25 public final class LogErrorHandler implements ErrorHandler 26 { 27 30 public void fatalError(SAXParseException ex) 31 { 32 log.fatal(getMessage(ex)); 33 } 34 35 38 public void error(SAXParseException ex) 39 { 40 log.error(getMessage(ex)); 41 } 42 43 46 public void warning(SAXParseException ex) 47 { 48 log.warn(getMessage(ex)); 49 } 50 51 55 private String getMessage(SAXParseException ex) 56 { 57 if (ex.getSystemId() != null) 58 { 59 return "SystemID=" + ex.getSystemId() + " Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); 60 } 61 62 if (ex.getPublicId() != null) 63 { 64 return "PublicID=" + ex.getPublicId() + " Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); 65 } 66 67 return "Line=" + ex.getLineNumber() + ' ' + ex.getMessage(); 68 } 69 70 73 private static final Logger log = Logger.getLogger(LogErrorHandler.class); 74 } 75 | Popular Tags |