Package edu.umd.cs.findbugs
Class SortedBugCollection
java.lang.Object
edu.umd.cs.findbugs.SortedBugCollection
- All Implemented Interfaces:
BugCollection
,Iterable<BugInstance>
An implementation of
BugCollection
that keeps the BugInstances sorted
by class (using the native comparison ordering of BugInstance's compareTo()
method as a tie-breaker).- Author:
- David Hovemeyer
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Fields inherited from interface edu.umd.cs.findbugs.BugCollection
ANALYSIS_ERROR_ELEMENT_NAME, APP_CLASS_ELEMENT_NAME, CLASS_HASHES_ELEMENT_NAME, ERROR_ELEMENT_NAME, ERROR_EXCEPTION_ELEMENT_NAME, ERROR_MESSAGE_ELEMENT_NAME, ERROR_STACK_TRACE_ELEMENT_NAME, ERRORS_ELEMENT_NAME, HISTORY_ELEMENT_NAME, MISSING_CLASS_ELEMENT_NAME, PROJECT_ELEMENT_NAME, ROOT_ELEMENT_NAME, SRCMAP_ELEMENT_NAME, SUMMARY_HTML_ELEMENT_NAME
-
Constructor Summary
ConstructorDescriptionConstructor.SortedBugCollection
(Project project) SortedBugCollection
(ProjectStats projectStats) Constructor.SortedBugCollection
(ProjectStats projectStats, Project project) SortedBugCollection
(ProjectStats projectStats, Comparator<BugInstance> comparator) Constructor.SortedBugCollection
(ProjectStats projectStats, Comparator<BugInstance> comparator, Project project) SortedBugCollection
(Comparator<BugInstance> comparator) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(BugInstance bugInstance) Add a BugInstance to this BugCollection.boolean
add
(BugInstance bugInstance, boolean updateActiveTime) Add a BugInstance to this BugCollection.void
addAll
(Collection<BugInstance> collection) Add a Collection of BugInstances to this BugCollection object.void
addAll
(Collection<BugInstance> collection, boolean updateActiveTime) Add a Collection of BugInstances to this BugCollection object.void
addAppVersion
(AppVersion appVersion) Add an AppVersion representing a version of the analyzed application.void
addError
(AnalysisError error) Add an analysis error.void
Add an analysis error.void
void
addMissingClass
(String className) Add a missing class message.Get an Iterator over AppVersions defined in the collection.void
void
Clear all AppVersions representing previously-analyzed versions of the application.void
void
void
void
static void
cloneAll
(Collection<BugInstance> dest, Collection<BugInstance> source) Clone all of the BugInstance objects in the source Collection and add them to the destination Collection.void
boolean
contains
(BugInstance bugInstance) Create a new empty BugCollection with the same metadata as this one.long
Get the timestamp for when the analysis was performed.getAppVersionFromSequenceNumber
(long target) Gets the AppVersion corresponding to the given sequence number.getClassFeatureSet
(String className) Return the Collection storing the BugInstance objects.Get the current AppVersion.Collection<? extends AnalysisError>
getMatching
(BugInstance bugInstance) Get the project stats.Get the current release name.long
Get the sequence number of the BugCollection.long
long
Get the timestamp for the analyzed code (when it was compiled)long
boolean
Return whether textual messages will be added to any generated XMLboolean
boolean
boolean
Returns whether this bug collection contains results from multiple analysis runs, either of different version of the software or from different versions of FindBugs.iterator()
Return an Iterator over all the BugInstance objects in the BugCollection.lookupFromUniqueId
(String uniqueId) Deprecated.progessMonitoredInputStream
(File f, String msg) progressMonitoredInputStream
(InputStream in, int length, String msg) void
Read XML data from given file into this object, populating given Project as a side effect.void
readXML
(InputStream in) Read XML data from given input stream into this object, populating the Project as a side effect.void
readXML
(InputStream in, File base) Read XML data from given input stream into this object, populating the Project as a side effect.void
Read XML data from given reader into this object, populating the Project as a side effect.void
Read XML data from given file into this object, populating given Project as a side effect.void
boolean
remove
(BugInstance bugInstance) void
setAnalysisTimestamp
(long timestamp) Set the timestamp for when the analysis was performed.void
setAnalysisVersion
(String version) Set the version of FindBugs used to perform the analysisvoid
setApplySuppressions
(boolean applySuppressions) void
setClassFeatureSet
(ClassFeatureSet classFeatureSet) void
setMinimalXML
(boolean minimalXML) Set whether we should minimize XMLvoid
setReleaseName
(String releaseName) Set the current release name.void
setSequenceNumber
(long sequence) Set the sequence number of the BugCollection.void
setTimestamp
(long timestamp) Get the timestamp for the analyzed code (when it was compiled)void
setWithMessages
(boolean withMessages) Set whether textual messages should be added to any generated XMLorg.dom4j.Document
Convert the BugCollection into a dom4j Document object.toString()
void
trimAppVersions
(long numberToRetain) wrapGzip
(InputStream in, Object source) void
writeEpilogue
(XMLOutput xmlOutput) void
writePrologue
(XMLOutput xmlOutput) void
Write the BugCollection to an XMLOutput object.void
Write this BugCollection to a file as XML.void
writeXML
(OutputStream out) Write the BugCollection to given output stream as XML using a UTF8 encoding.void
Write the BugCollection to given output stream as XML.void
Write this BugCollection to a file as XML.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
SortedBugCollection
-
SortedBugCollection
- Throws:
IOException
org.dom4j.DocumentException
-
SortedBugCollection
public SortedBugCollection()Constructor. Creates an empty object. -
SortedBugCollection
Constructor. Creates an empty object. -
SortedBugCollection
Constructor. Creates an empty object given an existing ProjectStats.- Parameters:
projectStats
- the ProjectStats
-
SortedBugCollection
-
SortedBugCollection
Constructor. Creates an empty object given an existing ProjectStats.- Parameters:
projectStats
- the ProjectStatscomparator
- to use for sorting bug instances
-
SortedBugCollection
public SortedBugCollection(ProjectStats projectStats, Comparator<BugInstance> comparator, Project project)
-
-
Method Details
-
getTimeStartedLoading
public long getTimeStartedLoading() -
getTimeFinishedLoading
public long getTimeFinishedLoading() -
getDataSource
-
getProject
- Specified by:
getProject
in interfaceBugCollection
-
isApplySuppressions
public boolean isApplySuppressions()- Specified by:
isApplySuppressions
in interfaceBugCollection
-
setApplySuppressions
public void setApplySuppressions(boolean applySuppressions) - Specified by:
setApplySuppressions
in interfaceBugCollection
-
getAnalysisTimestamp
public long getAnalysisTimestamp()Description copied from interface:BugCollection
Get the timestamp for when the analysis was performed.- Specified by:
getAnalysisTimestamp
in interfaceBugCollection
-
setAnalysisTimestamp
public void setAnalysisTimestamp(long timestamp) Description copied from interface:BugCollection
Set the timestamp for when the analysis was performed.- Specified by:
setAnalysisTimestamp
in interfaceBugCollection
- Parameters:
timestamp
- the analysis timestamp.
-
addAll
Add a Collection of BugInstances to this BugCollection object. This just calls add(BugInstance) for each instance in the input collection.- Parameters:
collection
- the Collection of BugInstances to add
-
addAll
Add a Collection of BugInstances to this BugCollection object.- Parameters:
collection
- the Collection of BugInstances to addupdateActiveTime
- true if active time of added BugInstances should be updated to match collection: false if not
-
add
Add a BugInstance to this BugCollection. This just calls add(bugInstance, true).- Specified by:
add
in interfaceBugCollection
- Parameters:
bugInstance
- the BugInstance- Returns:
- true if the BugInstance was added, or false if a matching BugInstance was already in the BugCollection
-
addError
Add an analysis error.- Specified by:
addError
in interfaceBugCollection
- Parameters:
message
- the error message
-
getCurrentAppVersion
Get the current AppVersion.- Specified by:
getCurrentAppVersion
in interfaceBugCollection
-
readXML
Read XML data from given file into this object, populating given Project as a side effect.- Specified by:
readXML
in interfaceBugCollection
- Parameters:
fileName
- name of the file to read- Throws:
IOException
org.dom4j.DocumentException
-
readXML
Read XML data from given file into this object, populating given Project as a side effect.- Parameters:
file
- the file- Throws:
IOException
org.dom4j.DocumentException
-
readXML
- Throws:
IOException
org.dom4j.DocumentException
-
readXML
public void readXML(@WillClose InputStream in, File base) throws IOException, org.dom4j.DocumentException Read XML data from given input stream into this object, populating the Project as a side effect. An attempt will be made to close the input stream (even if an exception is thrown).- Parameters:
in
- the InputStream- Throws:
IOException
org.dom4j.DocumentException
-
readXML
Description copied from interface:BugCollection
Read XML data from given input stream into this object, populating the Project as a side effect. An attempt will be made to close the input stream (even if an exception is thrown).- Specified by:
readXML
in interfaceBugCollection
- Parameters:
in
- the InputStream- Throws:
IOException
org.dom4j.DocumentException
-
readXML
Description copied from interface:BugCollection
Read XML data from given reader into this object, populating the Project as a side effect. An attempt will be made to close the reader (even if an exception is thrown).- Specified by:
readXML
in interfaceBugCollection
- Parameters:
reader
- the Reader- Throws:
IOException
org.dom4j.DocumentException
-
writeXML
Description copied from interface:BugCollection
Write the BugCollection to given output stream as XML using a UTF8 encoding. The output stream will be closed, even if an exception is thrown.- Specified by:
writeXML
in interfaceBugCollection
- Parameters:
out
- the OutputStream to write to- Throws:
IOException
-
writeXML
Write this BugCollection to a file as XML.- Specified by:
writeXML
in interfaceBugCollection
- Parameters:
fileName
- the file to write to- Throws:
IOException
-
writeXML
Write this BugCollection to a file as XML.- Parameters:
file
- the file to write to- Throws:
IOException
-
toDocument
public org.dom4j.Document toDocument()Convert the BugCollection into a dom4j Document object.- Specified by:
toDocument
in interfaceBugCollection
- Returns:
- the Document representing the BugCollection as a dom4j tree
-
writeXML
Write the BugCollection to given output stream as XML. The output stream will be closed, even if an exception is thrown.- Specified by:
writeXML
in interfaceBugCollection
- Parameters:
out
- the OutputStream to write to- Throws:
IOException
-
writePrologue
- Specified by:
writePrologue
in interfaceBugCollection
- Throws:
IOException
-
computeBugHashes
public void computeBugHashes() -
writeXML
Write the BugCollection to an XMLOutput object. The finish() method of the XMLOutput object is guaranteed to be called.To write the SummaryHTML element, set property findbugs.report.SummaryHTML to "true".
- Specified by:
writeXML
in interfaceBugCollection
- Parameters:
xmlOutput
- the XMLOutput object- Throws:
IOException
-
writeEpilogue
- Specified by:
writeEpilogue
in interfaceBugCollection
- Throws:
IOException
-
cloneAll
Clone all of the BugInstance objects in the source Collection and add them to the destination Collection.- Parameters:
dest
- the destination Collectionsource
- the source Collection
-
add
Description copied from interface:BugCollection
Add a BugInstance to this BugCollection.- Specified by:
add
in interfaceBugCollection
- Parameters:
bugInstance
- the BugInstanceupdateActiveTime
- true if the warning's active time should be updated to include the collection's current time- Returns:
- true if the BugInstance was added, or false if a matching BugInstance was already in the BugCollection
-
remove
-
iterator
Description copied from interface:BugCollection
Return an Iterator over all the BugInstance objects in the BugCollection.- Specified by:
iterator
in interfaceBugCollection
- Specified by:
iterator
in interfaceIterable<BugInstance>
-
getCollection
Description copied from interface:BugCollection
Return the Collection storing the BugInstance objects.- Specified by:
getCollection
in interfaceBugCollection
-
addError
-
addError
Description copied from interface:BugCollection
Add an analysis error.- Specified by:
addError
in interfaceBugCollection
- Parameters:
error
- the AnalysisError object to add
-
clearErrors
public void clearErrors() -
addMissingClass
Description copied from interface:BugCollection
Add a missing class message.- Specified by:
addMissingClass
in interfaceBugCollection
- Parameters:
className
- the missing class message
-
getErrors
-
missingClassIterator
-
contains
-
getMatching
-
getSummaryHTML
- Throws:
IOException
-
getProjectStats
Description copied from interface:BugCollection
Get the project stats.- Specified by:
getProjectStats
in interfaceBugCollection
-
lookupFromUniqueId
Deprecated.Description copied from interface:BugCollection
Look up a BugInstance by its unique id.- Specified by:
lookupFromUniqueId
in interfaceBugCollection
- Parameters:
uniqueId
- the BugInstance's unique id.- Returns:
- the BugInstance with the given unique id, or null if there is no such BugInstance This is deprecated; uniqueIDs are not persistent.
-
isMultiversion
public boolean isMultiversion()Returns whether this bug collection contains results from multiple analysis runs, either of different version of the software or from different versions of FindBugs.- Specified by:
isMultiversion
in interfaceBugCollection
-
hasDeadBugs
public boolean hasDeadBugs()- Specified by:
hasDeadBugs
in interfaceBugCollection
-
getSequenceNumber
public long getSequenceNumber()Description copied from interface:BugCollection
Get the sequence number of the BugCollection. This value represents the number of times the user has analyzed a different version of the application and updated the historical bug collection using the UpdateBugCollection class.- Specified by:
getSequenceNumber
in interfaceBugCollection
- Returns:
- the sequence number
-
setSequenceNumber
public void setSequenceNumber(long sequence) Description copied from interface:BugCollection
Set the sequence number of the BugCollection.- Specified by:
setSequenceNumber
in interfaceBugCollection
- Parameters:
sequence
- the sequence number- See Also:
-
duplicate
-
createEmptyCollectionWithMetadata
Description copied from interface:BugCollection
Create a new empty BugCollection with the same metadata as this one.- Specified by:
createEmptyCollectionWithMetadata
in interfaceBugCollection
- Returns:
- a new empty BugCollection with the same metadata as this one
-
clearBugInstances
public void clearBugInstances() -
clearMissingClasses
public void clearMissingClasses()- Specified by:
clearMissingClasses
in interfaceBugCollection
-
getReleaseName
Description copied from interface:BugCollection
Get the current release name.- Specified by:
getReleaseName
in interfaceBugCollection
- Returns:
- current release name
-
setReleaseName
Description copied from interface:BugCollection
Set the current release name.- Specified by:
setReleaseName
in interfaceBugCollection
- Parameters:
releaseName
- the current release name
-
appVersionIterator
Description copied from interface:BugCollection
Get an Iterator over AppVersions defined in the collection.- Specified by:
appVersionIterator
in interfaceBugCollection
-
addAppVersion
Description copied from interface:BugCollection
Add an AppVersion representing a version of the analyzed application.- Specified by:
addAppVersion
in interfaceBugCollection
- Parameters:
appVersion
- the AppVersion
-
clearAppVersions
public void clearAppVersions()Description copied from interface:BugCollection
Clear all AppVersions representing previously-analyzed versions of the application.- Specified by:
clearAppVersions
in interfaceBugCollection
-
trimAppVersions
public void trimAppVersions(long numberToRetain) -
setTimestamp
public void setTimestamp(long timestamp) Description copied from interface:BugCollection
Get the timestamp for the analyzed code (when it was compiled)- Specified by:
setTimestamp
in interfaceBugCollection
- Parameters:
timestamp
- the timestamp.
-
getTimestamp
public long getTimestamp()Description copied from interface:BugCollection
Get the timestamp for the analyzed code (when it was compiled)- Specified by:
getTimestamp
in interfaceBugCollection
-
getClassFeatureSet
-
setClassFeatureSet
- Specified by:
setClassFeatureSet
in interfaceBugCollection
-
classFeatureSetIterator
-
clearClassFeatures
public void clearClassFeatures()- Specified by:
clearClassFeatures
in interfaceBugCollection
-
setWithMessages
public void setWithMessages(boolean withMessages) Description copied from interface:BugCollection
Set whether textual messages should be added to any generated XML- Specified by:
setWithMessages
in interfaceBugCollection
-
getWithMessages
public boolean getWithMessages()Description copied from interface:BugCollection
Return whether textual messages will be added to any generated XML- Specified by:
getWithMessages
in interfaceBugCollection
-
getAppVersionFromSequenceNumber
Description copied from interface:BugCollection
Gets the AppVersion corresponding to the given sequence number.- Specified by:
getAppVersionFromSequenceNumber
in interfaceBugCollection
-
findBug
- Specified by:
findBug
in interfaceBugCollection
-
setAnalysisVersion
Description copied from interface:BugCollection
Set the version of FindBugs used to perform the analysis- Specified by:
setAnalysisVersion
in interfaceBugCollection
- Parameters:
version
- the analysis version.
-
getAnalysisVersion
-
progessMonitoredInputStream
- Throws:
IOException
-
progessMonitoredInputStream
- Throws:
IOException
-
progressMonitoredInputStream
-
wrapGzip
-
setMinimalXML
public void setMinimalXML(boolean minimalXML) Description copied from interface:BugCollection
Set whether we should minimize XML- Specified by:
setMinimalXML
in interfaceBugCollection
-
bugsPopulated
public void bugsPopulated()- Specified by:
bugsPopulated
in interfaceBugCollection
-
toString
-