1 package net.jaekl.cfb.analyze;
3 import java.io.PrintWriter;
4 import java.util.HashSet;
6 import net.jaekl.cfb.xml.BugInstance;
8 // Compute and store the delta (difference) between two analyses
11 HashSet<BugInstance> m_fixed; // bugs that have been fixed
12 HashSet<BugInstance> m_common; // bugs that are present in both versions
13 HashSet<BugInstance> m_new; // bugs introduced in the new version
15 public Delta(Analysis before, Analysis after)
17 m_fixed = new HashSet<BugInstance>();
18 m_common = new HashSet<BugInstance>();
19 m_new = new HashSet<BugInstance>();
21 computeDelta(before, after);
24 public BugInstance[] getFixed() { return m_fixed.toArray(new BugInstance[m_fixed.size()]); }
25 public int getNumFixed() { return m_fixed.size(); }
27 public BugInstance[] getCommon() { return m_common.toArray(new BugInstance[m_common.size()]); }
28 public int getNumCommon() { return m_common.size(); }
30 public BugInstance[] getNew() { return m_new.toArray(new BugInstance[m_new.size()]); }
31 public int getNumNew() { return m_new.size(); }
33 public void dump(PrintWriter pw) {
34 pw.println("=========================");
35 pw.println(" NEW BUGS (" + m_new.size() + ")");
36 pw.println("-------------------------");
37 for (BugInstance bug : m_new) {
41 pw.println("=========================");
42 pw.println(" FIXED BUGS (" + m_fixed.size() + ")");
43 pw.println("-------------------------");
44 for (BugInstance bug : m_fixed) {
48 pw.println("=========================");
49 pw.println(" OLD BUGS (" + m_common.size() + ")");
50 pw.println("-------------------------");
51 for (BugInstance bug : m_common) {
56 void computeDelta(Analysis before, Analysis after)
62 HashSet<BugInstance> beforeBugs = new HashSet<BugInstance>();
65 beforeBugs.addAll(before.getBugCollection().getBugs());
68 for (BugInstance bug : after.getBugCollection().getBugs()) {
69 if (beforeBugs.contains(bug)) {
81 for (BugInstance bug : before.getBugCollection().getBugs()) {
82 if (! m_common.contains(bug)) {