1 19 20 package edu.umd.cs.findbugs; 21 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.Set ; 25 26 30 public abstract class QueryBugAnnotations { 31 private HashSet <String > keywordSet = new HashSet <String >(); 34 35 42 public void addKeyword(String keyword) { 43 keywordSet.add(keyword); 44 } 45 46 53 public void scan(String filename) throws Exception { 54 BugCollection bugCollection = new SortedBugCollection(); 55 bugCollection.readXML(filename, new Project()); 56 scan(bugCollection, filename); 57 } 58 59 67 public void scan(BugCollection bugCollection, String filename) throws Exception { 68 Iterator <BugInstance> i = bugCollection.iterator(); 69 while (i.hasNext()) { 70 BugInstance bugInstance = i.next(); 71 72 Set <String > contents = bugInstance.getTextAnnotationWords(); 73 for (String aKeywordSet : keywordSet) { 74 if (contents.contains(aKeywordSet)) { 75 match(bugInstance, filename); 76 break; 77 } 78 } 79 } 80 } 81 82 88 protected abstract void match(BugInstance bugInstance, String filename) throws Exception ; 89 } 90 91 | Popular Tags |