1 19 package edu.umd.cs.findbugs; 20 21 import java.io.IOException ; 22 import java.util.Iterator ; 23 24 import org.dom4j.DocumentException; 25 26 public class NewResults { 27 private SortedBugCollection origCollection; 28 private SortedBugCollection newCollection; 29 private Project project; 30 31 public NewResults(String origFilename, String newFilename) 32 throws IOException , DocumentException { 33 this(new SortedBugCollection(), new SortedBugCollection(), new Project()); 34 origCollection.readXML(origFilename, new Project()); 35 newCollection.readXML(newFilename, project); 36 } 37 38 public NewResults(SortedBugCollection origCollection, SortedBugCollection newCollection, 39 Project project) { 40 this.origCollection = origCollection; 41 this.newCollection = newCollection; 42 this.project = project; 43 } 44 45 public SortedBugCollection execute() { 46 SortedBugCollection result = new SortedBugCollection(); 47 48 for (Iterator <BugInstance> i= newCollection.iterator(); i.hasNext(); ) { 49 BugInstance bugInstance = i.next(); 50 51 if (!origCollection.contains(bugInstance)) { 52 result.add(bugInstance); 53 } 54 } 55 56 return result; 57 } 58 59 public static void main(String [] argv) throws Exception { 60 if (argv.length != 3) { 61 System.err.println("Usage: " + NewResults.class.getName() + 62 " <orig results> <new results> <output file>"); 63 System.exit(1); 64 } 65 66 String origFilename = argv[0]; 67 String newFilename = argv[1]; 68 String outputFilename = argv[2]; 69 70 NewResults op = new NewResults(origFilename, newFilename); 71 72 SortedBugCollection result = op.execute(); 73 74 result.writeXML(outputFilename, op.project); 75 } 76 } 77 78 | Popular Tags |