1 package edu.umd.cs.findbugs; 2 3 import java.util.HashSet ; 4 import java.util.Set ; 5 6 10 public class ErrorCountingBugReporter extends DelegatingBugReporter { 11 private int bugCount; 12 private int missingClassCount; 13 private int errorCount; 14 private Set <String > missingClassSet = new HashSet <String >(); 15 16 public ErrorCountingBugReporter(BugReporter realBugReporter) { 17 super(realBugReporter); 18 this.bugCount = 0; 19 this.missingClassCount = 0; 20 this.errorCount = 0; 21 22 realBugReporter.addObserver(new BugReporterObserver() { 26 public void reportBug(BugInstance bugInstance) { 27 ++bugCount; 28 } 29 }); 30 } 31 32 public int getBugCount() { 33 return bugCount; 34 } 35 36 public int getMissingClassCount() { 37 return missingClassCount; 38 } 39 40 public int getErrorCount() { 41 return errorCount; 42 } 43 44 @Override 45 public void logError(String message) { 46 ++errorCount; 47 super.logError(message); 48 } 49 50 @Override 51 public void reportMissingClass(ClassNotFoundException ex) { 52 String missing = AbstractBugReporter.getMissingClassName(ex); 53 if (missingClassSet.add(missing)) 54 ++missingClassCount; 55 super.reportMissingClass(ex); 56 } 57 } 58 | Popular Tags |