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)
21 m_earlier = new Run(before);
22 m_later = new Run(after);
24 m_fixed = new HashSet<BugInstance>();
25 m_common = new HashSet<BugInstance>();
26 m_new = new HashSet<BugInstance>();
28 computeDelta(before, after);
31 public BugInstance[] getFixed() { return m_fixed.toArray(new BugInstance[m_fixed.size()]); }
32 public int getNumFixed() { return m_fixed.size(); }
34 public BugInstance[] getCommon() { return m_common.toArray(new BugInstance[m_common.size()]); }
35 public int getNumCommon() { return m_common.size(); }
37 public BugInstance[] getNew() { return m_new.toArray(new BugInstance[m_new.size()]); }
38 public int getNumNew() { return m_new.size(); }
40 public Run getEarlier() { return m_earlier; }
41 public Run getLater() { return m_later; }
43 public void dump(PrintWriter pw) {
44 pw.println("=========================");
45 pw.println(" NEW BUGS (" + m_new.size() + ")");
46 pw.println("-------------------------");
47 for (BugInstance bug : m_new) {
51 pw.println("=========================");
52 pw.println(" FIXED BUGS (" + m_fixed.size() + ")");
53 pw.println("-------------------------");
54 for (BugInstance bug : m_fixed) {
58 pw.println("=========================");
59 pw.println(" OLD BUGS (" + m_common.size() + ")");
60 pw.println("-------------------------");
61 for (BugInstance bug : m_common) {
66 void computeDelta(Analysis before, Analysis after)
72 HashSet<BugInstance> beforeBugs = new HashSet<BugInstance>();
75 beforeBugs.addAll(before.getBugCollection().getBugs());
78 for (BugInstance bug : after.getBugCollection().getBugs()) {
79 if (beforeBugs.contains(bug)) {
91 for (BugInstance bug : before.getBugCollection().getBugs()) {
92 if (! m_common.contains(bug)) {