1 17 package org.apache.servicemix.components.validation; 18 19 import javax.jbi.messaging.MessagingException; 20 21 import org.xml.sax.ErrorHandler ; 22 import org.xml.sax.SAXParseException ; 23 import org.xml.sax.SAXException ; 24 25 30 public class CountingErrorHandler implements MessageAwareErrorHandler { 31 private int warningCount; 32 private int errorCount; 33 private int fatalErrorCount; 34 35 38 public boolean hasErrors() { 39 return getErrorCount() > 0 || getFatalErrorCount() > 0; 40 } 41 42 45 public int getWarningCount() { 46 return warningCount; 47 } 48 49 52 public int getErrorCount() { 53 return errorCount; 54 } 55 56 59 public int getFatalErrorCount() { 60 return fatalErrorCount; 61 } 62 63 66 public void warning(SAXParseException e) throws SAXException { 67 ++warningCount; 68 } 69 70 73 public void error(SAXParseException e) throws SAXException { 74 ++errorCount; 75 } 76 77 80 public void fatalError(SAXParseException e) throws SAXException { 81 ++fatalErrorCount; 82 } 83 84 87 public boolean capturesMessages() { 88 return false; 89 } 90 91 94 public Object getMessagesAs(Class format) throws MessagingException { 95 throw new MessagingException("Unsupported message format: " + format.getName()); 96 } 97 98 101 public boolean supportsMessageFormat(Class format) { 102 return false; 103 } 104 105 } 106 | Popular Tags |