1 package net.sf.invicta.util; 2 3 import net.sf.invicta.Logger; 4 5 import org.apache.commons.digester.Digester; 6 import org.xml.sax.SAXException ; 7 import org.xml.sax.SAXParseException ; 8 9 13 public class BetterDigester extends Digester { 14 private int errorsCounter = 0; 15 16 public int getNumberOfErrors() { 17 return this.errorsCounter; 18 } 19 20 public void clearWithErrors() { 21 clear(); 22 this.errorsCounter = 0; 23 } 24 private String getErrMsg(SAXParseException e) { 25 errorsCounter++; 26 return "Parse Error at line " 27 + e.getLineNumber() 28 + " column " 29 + e.getColumnNumber() 30 + ": " 31 + e.getMessage(); 32 } 33 34 public void warning(SAXParseException e) throws SAXException { 35 Logger.warn(getErrMsg(e)); 36 } 37 38 public void error(SAXParseException e) throws SAXException { 39 Logger.warn(getErrMsg(e)); 40 } 41 42 public void fatalError(SAXParseException e) throws SAXException { 43 Logger.error(getErrMsg(e)); 44 throw new SAXException (e); 45 } 46 }; | Popular Tags |