1 package net.jaekl.cfb.analyze;
3 import java.io.PrintWriter;
4 import java.util.HashSet;
6 import net.jaekl.cfb.store.Run;
7 import net.jaekl.cfb.xml.BugInstance;
9 // Compute and store the delta (difference) between two analyses
15 HashSet<BugInstance> m_fixed; // bugs that have been fixed
16 HashSet<BugInstance> m_common; // bugs that are present in both versions
17 HashSet<BugInstance> m_new; // bugs introduced in the new version
19 public Delta(Analysis before, Analysis after)
25 m_earlier = new Run(before);
27 m_later = new Run(after);
29 m_fixed = new HashSet<BugInstance>();
30 m_common = new HashSet<BugInstance>();
31 m_new = new HashSet<BugInstance>();
33 computeDelta(before, after);
36 public BugInstance[] getFixed() { return m_fixed.toArray(new BugInstance[m_fixed.size()]); }
37 public int getNumFixed() { return m_fixed.size(); }
39 public BugInstance[] getCommon() { return m_common.toArray(new BugInstance[m_common.size()]); }
40 public int getNumCommon() { return m_common.size(); }
42 public BugInstance[] getNew() { return m_new.toArray(new BugInstance[m_new.size()]); }
43 public int getNumNew() { return m_new.size(); }
45 public Run getEarlier() { return m_earlier; }
46 public Run getLater() { return m_later; }
48 public void dump(PrintWriter pw) {
49 pw.println("=========================");
50 pw.println(" NEW BUGS (" + m_new.size() + ")");
51 pw.println("-------------------------");
52 for (BugInstance bug : m_new) {
56 pw.println("=========================");
57 pw.println(" FIXED BUGS (" + m_fixed.size() + ")");
58 pw.println("-------------------------");
59 for (BugInstance bug : m_fixed) {
63 pw.println("=========================");
64 pw.println(" OLD BUGS (" + m_common.size() + ")");
65 pw.println("-------------------------");
66 for (BugInstance bug : m_common) {
71 void computeDelta(Analysis before, Analysis after)
77 HashSet<BugInstance> beforeBugs = new HashSet<BugInstance>();
80 beforeBugs.addAll(before.getBugCollection().getBugs());
83 for (BugInstance bug : after.getBugCollection().getBugs()) {
84 if (beforeBugs.contains(bug)) {
96 for (BugInstance bug : before.getBugCollection().getBugs()) {
97 if (! m_common.contains(bug)) {