1 19 20 package edu.umd.cs.findbugs.gui2; 21 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 25 37 public class BugAspects implements Iterable <BugAspects.StringPair> 38 { 39 private static final long serialVersionUID = -5503915081879996968L; 40 private int count=-1; 41 private ArrayList <BugAspects.StringPair> lst = new ArrayList <BugAspects.StringPair>(); 42 43 public StringPair last() { 44 return lst.get(lst.size() - 1); 45 } 46 public int size() { 47 return lst.size(); 48 } 49 public String toString() 50 { 51 if (lst.isEmpty()) 52 return edu.umd.cs.findbugs.L10N.getLocalString("tree.bugs", "Bugs") + " (" + count + ")"; 53 else 54 { 55 if (count==-1) 56 return last().value; 57 else 58 return last().key.formatValue(last().value) + " (" + count + ")"; 59 } 60 } 61 62 66 public void setCount(int count) 67 { 68 this.count=count; 69 } 70 71 public int getCount() 72 { 73 return count; 74 } 75 76 public BugAspects() 77 { 78 super(); 79 } 80 81 public BugAspects(BugAspects a) 82 { 83 lst = new ArrayList <StringPair>(a.lst); 84 count = a.count; 85 } 86 87 public void add(StringPair sp) { 88 lst.add(sp); 89 } 90 public BugAspects addToNew(StringPair sp) 91 { 92 BugAspects result = new BugAspects(this); 93 result.lst.add(sp); 94 return result; 95 } 96 public StackedFilterMatcher getStackedFilterMatcher(){ 97 FilterMatcher[] filters = new FilterMatcher[lst.size()]; 98 for (int i = 0; i < filters.length; i++) 99 filters[i] = new FilterMatcher(lst.get(i)); 100 StackedFilterMatcher sfm = new StackedFilterMatcher(filters); 101 return sfm; 102 } 103 104 public BugSet getMatchingBugs(BugSet theSet) 105 { 106 return theSet.getBugsMatchingFilter(this.getStackedFilterMatcher()); 107 } 108 static class StringPair 109 { 110 final public Sortables key; 111 final public String value; 112 113 public StringPair(Sortables key, String value) 114 { 115 this.key = key; 116 this.value = value; 117 } 118 119 public int hashCode() 120 { 121 return key.hashCode() + value.hashCode(); 122 } 123 124 public boolean equals(Object that) 125 { 126 if (!(that instanceof StringPair)) 127 return false; 128 StringPair thatStringPair = ((StringPair)that); 129 return this.key.equals(thatStringPair.key) && this.value.equals(thatStringPair.value); 130 } 131 132 public String toString() 133 { 134 return key +":"+ value; 135 } 136 } 137 138 public Iterator <StringPair> iterator() { 139 return lst.iterator(); 140 } 141 } 142 | Popular Tags |