Package edu.umd.cs.findbugs.gui2
Class BugSet
- java.lang.Object
-
- edu.umd.cs.findbugs.gui2.BugSet
-
- All Implemented Interfaces:
java.lang.Iterable<BugLeafNode>
public class BugSet extends java.lang.Object implements java.lang.Iterable<BugLeafNode>
BugSet is what we use instead of SortedBugCollections. BugSet is somewhat poorly named, in that its actually a HashList of bugs, not a Set of them. (It can't be a set because we need to be able to sort it, also, HashList is great for doing contains and indexOf, its just slow for removing which we never need to do) The power of BugSet is in query. You can query a BugSet with a BugAspects, a list of StringPairs like <priority,high>, <designation,unclassified> and you will get out a new BugSet containing all of the bugs that are both high priority and unclassified. Also, after the first time a query is made, the results will come back instantly on future calls because the old queries are cached. Note that this caching can also lead to issues, problems with the BugTreeModel and the JTree getting out of sync, if there comes a time when the model and tree are out of sync but come back into sync if the tree is rebuilt, say by sorting the column headers, it probably means that resetData needs to be called on the model after doing one of its operations.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) BugSet
cache
private java.util.HashMap<BugAspects.SortableValue,java.lang.Boolean>
doneContainsMap
private java.util.HashMap<BugAspects.SortableValue,BugSet>
doneMap
private static java.lang.String[]
EMPTY_STRING_ARRAY
private static BugSet
mainBugSet
private java.util.ArrayList<BugLeafNode>
mainList
private java.util.HashMap<Sortables,java.lang.String[]>
sortablesToStrings
-
Constructor Summary
Constructors Constructor Description BugSet(BugCollection bugCollection)
BugSet(BugSet copySet)
Copy constructor, also used to make sure things are recalculatedBugSet(java.util.ArrayList<BugLeafNode> filteredSet, boolean cacheSortables)
BugSet(java.util.Collection<? extends BugLeafNode> filteredSet)
Creates a filterable dataset from the set passed in.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
cacheSortables()
we cache all values of each sortable that appear in the BugSet as we create it using cacheSortables, this makes it possible to only show branches that actually have bugs in them, and makes it faster by caching the results.void
clearCache()
(package private) java.lang.String[]
computeDistinctValues(Sortables key)
boolean
contains(BugAspects.SortableValue keyValuePair)
Contains takes a key/value pair(package private) static int
countFilteredBugs()
used to update the status bar in mainframe with the number of bugs that are filtered outprivate BugSet
filteredBugsCached()
private BugSet
filteredBugsNoCache()
BugLeafNode
get(int index)
java.lang.String[]
getAll(Sortables s)
Gets all the string values out of the bugs in the setBugSet
getBugsMatchingFilter(Matcher m)
(package private) java.lang.String[]
getDistinctValues(Sortables key)
static BugSet
getMainBugSet()
mainBugSet should probably always be the same as the data field in the current BugTreeModel we haven't run into any issues where it isn't, but if the two aren't equal using ==, problems might occur.BugLeafNode
getUnfiltered(int index)
int
indexOf(BugLeafNode p)
int
indexOfUnfiltered(BugLeafNode p)
java.util.Iterator<BugLeafNode>
iterator()
BugSet
query(BugAspects a)
Gives you back the BugSet containing all bugs that match your query(package private) BugSet
query(BugAspects.SortableValue keyValuePair)
A String pair has a key and a value.(package private) static void
setAsRootAndCache(BugSet bs)
Sets the BugSet passed in to be the mainBugSet, this should always match up with the data set in the BugTreeModelint
size()
int
sizeUnfiltered()
(package private) void
sortList()
(package private) static boolean
suppress(BugLeafNode p)
-
-
-
Field Detail
-
mainList
private java.util.ArrayList<BugLeafNode> mainList
-
doneMap
private final java.util.HashMap<BugAspects.SortableValue,BugSet> doneMap
-
doneContainsMap
private final java.util.HashMap<BugAspects.SortableValue,java.lang.Boolean> doneContainsMap
-
sortablesToStrings
private java.util.HashMap<Sortables,java.lang.String[]> sortablesToStrings
-
mainBugSet
private static BugSet mainBugSet
-
EMPTY_STRING_ARRAY
private static final java.lang.String[] EMPTY_STRING_ARRAY
-
cache
BugSet cache
-
-
Constructor Detail
-
BugSet
BugSet(java.util.Collection<? extends BugLeafNode> filteredSet)
Creates a filterable dataset from the set passed in. The first time this is used is from outside to create the main data list After that BugSet will create new smaller filtered sets and store them using this method.- Parameters:
filteredSet
-
-
BugSet
BugSet(BugCollection bugCollection)
-
BugSet
BugSet(BugSet copySet)
Copy constructor, also used to make sure things are recalculated- Parameters:
copySet
-
-
BugSet
BugSet(java.util.ArrayList<BugLeafNode> filteredSet, boolean cacheSortables)
-
-
Method Detail
-
getMainBugSet
public static BugSet getMainBugSet()
mainBugSet should probably always be the same as the data field in the current BugTreeModel we haven't run into any issues where it isn't, but if the two aren't equal using ==, problems might occur. If these problems do occur, See BugTreeModel.resetData() and perhaps adding a setAsRootAndCache() to it would fix the issue. This is not done right now for fear it might be slow.
-
getAll
public java.lang.String[] getAll(Sortables s)
Gets all the string values out of the bugs in the set- Parameters:
s
- The Sortables you want all values for- Returns:
- all values of the sortable passed in that occur in this bugset, in order based on the sortable's compare method.
-
setAsRootAndCache
static void setAsRootAndCache(BugSet bs)
Sets the BugSet passed in to be the mainBugSet, this should always match up with the data set in the BugTreeModel- Parameters:
bs
-
-
suppress
static boolean suppress(BugLeafNode p)
-
cacheSortables
void cacheSortables()
we cache all values of each sortable that appear in the BugSet as we create it using cacheSortables, this makes it possible to only show branches that actually have bugs in them, and makes it faster by caching the results.
-
getDistinctValues
java.lang.String[] getDistinctValues(Sortables key)
-
computeDistinctValues
java.lang.String[] computeDistinctValues(Sortables key)
-
countFilteredBugs
static int countFilteredBugs()
used to update the status bar in mainframe with the number of bugs that are filtered out
-
query
BugSet query(BugAspects.SortableValue keyValuePair)
A String pair has a key and a value. The key is the general category ie: Type The value is the value ie: Malicious Code. Query looks through a BugLeafNode set with a keyValuePair to see which BugLeafNodes inside match the value under the category of key. passing in a key of Abbrev and a value of MS should return a new BugSet with all the Mutable Static bugs in the current set Note also: This query will only be performed once, and then stored and reused if the same query is used again.
-
sortList
void sortList()
-
contains
public boolean contains(BugAspects.SortableValue keyValuePair)
Contains takes a key/value pair- Parameters:
keyValuePair
-- Returns:
- true if a bug leaf from filterNoCache() matches the pair
-
query
public BugSet query(BugAspects a)
Gives you back the BugSet containing all bugs that match your query
-
sizeUnfiltered
public int sizeUnfiltered()
-
indexOfUnfiltered
public int indexOfUnfiltered(BugLeafNode p)
-
getUnfiltered
public BugLeafNode getUnfiltered(int index)
-
iterator
public java.util.Iterator<BugLeafNode> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<BugLeafNode>
-
filteredBugsNoCache
private BugSet filteredBugsNoCache()
-
clearCache
public void clearCache()
-
filteredBugsCached
private BugSet filteredBugsCached()
-
size
public int size()
-
indexOf
public int indexOf(BugLeafNode p)
-
get
public BugLeafNode get(int index)
-
-