FindBugs™ 1.3.9

edu.umd.cs.findbugs
Class SortedBugCollection

java.lang.Object
  extended by edu.umd.cs.findbugs.SortedBugCollection
All Implemented Interfaces:
BugCollection, java.lang.Iterable<BugInstance>

public class SortedBugCollection
extends java.lang.Object
implements BugCollection

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:
BugInstance

Nested Class Summary
static class SortedBugCollection.BugInstanceComparator
           
static class SortedBugCollection.MultiversionBugInstanceComparator
           
 
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
SortedBugCollection()
          Constructor.
SortedBugCollection(java.util.Comparator<BugInstance> comparator)
          Constructor.
SortedBugCollection(java.io.File f)
           
SortedBugCollection(Project project)
           
SortedBugCollection(ProjectStats projectStats)
          Constructor.
SortedBugCollection(ProjectStats projectStats, java.util.Comparator<BugInstance> comparator)
          Constructor.
SortedBugCollection(ProjectStats projectStats, java.util.Comparator<BugInstance> comparator, Project project)
           
SortedBugCollection(ProjectStats projectStats, Project project)
           
 
Method Summary
 boolean add(BugInstance bugInstance)
          Add a BugInstance to this BugCollection.
 boolean add(BugInstance bugInstance, boolean updateActiveTime)
          Add a BugInstance to this BugCollection.
 void addAll(java.util.Collection<BugInstance> collection)
          Add a Collection of BugInstances to this BugCollection object.
 void addAll(java.util.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 addError(java.lang.String message)
          Add an analysis error.
 void addError(java.lang.String message, java.lang.Throwable exception)
           
 void addMissingClass(java.lang.String className)
          Add a missing class message.
 java.util.Iterator<AppVersion> appVersionIterator()
          Get an Iterator over AppVersions defined in the collection.
 java.util.Iterator<ClassFeatureSet> classFeatureSetIterator()
           
 void clearAppVersions()
          Clear all AppVersions representing previously-analyzed versions of the application.
 void clearBugInstances()
           
 void clearClassFeatures()
           
 void clearMissingClasses()
           
static void cloneAll(java.util.Collection<BugInstance> dest, java.util.Collection<BugInstance> source)
          Clone all of the BugInstance objects in the source Collection and add them to the destination Collection.
 void computeBugHashes()
           
 boolean contains(BugInstance bugInstance)
           
 SortedBugCollection createEmptyCollectionWithMetadata()
          Create a new empty BugCollection with the same metadata as this one.
 SortedBugCollection duplicate()
           
 java.util.Iterator<AnalysisError> errorIterator()
           
 BugInstance findBug(java.lang.String instanceHash, java.lang.String bugType, int lineNumber)
           
 long getAnalysisTimestamp()
          Get the timestamp for when the analysis was performed.
 java.lang.String getAnalysisVersion()
           
 AppVersion getAppVersionFromSequenceNumber(long target)
          Gets the AppVersion corresponding to the given sequence number.
 ClassFeatureSet getClassFeatureSet(java.lang.String className)
           
 Cloud getCloud()
          Get the instance of user annotation plugin
 java.util.Collection<BugInstance> getCollection()
          Return the Collection storing the BugInstance objects.
 AppVersion getCurrentAppVersion()
          Get the current AppVersion.
 java.lang.String getDataSource()
           
 BugInstance getMatching(BugInstance bugInstance)
           
 Project getProject()
           
 ProjectStats getProjectStats()
          Get the project stats.
 java.lang.String getReleaseName()
          Get the current release name.
 long getSequenceNumber()
          Get the sequence number of the BugCollection.
 java.lang.String getSummaryHTML()
           
 long getTimeFinishedLoading()
           
 long getTimestamp()
          Get the timestamp for the analyzed code (when it was compiled)
 long getTimeStartedLoading()
           
 boolean getWithMessages()
          Return whether textual messages will be added to any generated XML
 boolean isApplySuppressions()
           
 java.util.Iterator<BugInstance> iterator()
          Return an Iterator over all the BugInstance objects in the BugCollection.
 BugInstance lookupFromUniqueId(java.lang.String uniqueId)
          Deprecated. 
 java.util.Iterator<java.lang.String> missingClassIterator()
           
 java.io.InputStream progessMonitoredInputStream(java.io.File f, java.lang.String msg)
           
 java.io.InputStream progessMonitoredInputStream(java.net.URLConnection c, java.lang.String msg)
           
 java.io.InputStream progressMonitoredInputStream(java.io.InputStream in, int length, java.lang.String msg)
           
 void readXML(java.io.File file)
          Read XML data from given file into this object, populating given Project as a side effect.
 void readXML(java.io.InputStream in)
          Read XML data from given input stream into this object, populating the Project as a side effect.
 void readXML(java.io.InputStream in, java.io.File base)
          Read XML data from given input stream into this object, populating the Project as a side effect.
 void readXML(java.lang.String fileName)
          Read XML data from given file into this object, populating given Project as a side effect.
 void readXML(java.net.URL u)
           
 Cloud reinitializeCloud()
           
 boolean remove(BugInstance bugInstance)
           
 void setAnalysisTimestamp(long timestamp)
          Set the timestamp for when the analysis was performed.
 void setAnalysisVersion(java.lang.String version)
          Set the version of FindBugs used to perform the analysis
 void setApplySuppressions(boolean applySuppressions)
           
 void setClassFeatureSet(ClassFeatureSet classFeatureSet)
           
 void setMinimalXML(boolean minimalXML)
          Set whether we should minimize XML
 void setReleaseName(java.lang.String releaseName)
          Set the current release name.
 void setRequestDatabaseCloud(boolean useDatabaseCloud)
           
 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 XML
 org.dom4j.Document toDocument()
          Convert the BugCollection into a dom4j Document object.
 java.io.InputStream wrapGzip(java.io.InputStream in, java.lang.Object source)
           
 void writeEpilogue(XMLOutput xmlOutput)
           
 void writePrologue(XMLOutput xmlOutput)
           
 void writeXML(java.io.File file)
          Write this BugCollection to a file as XML.
 void writeXML(java.io.OutputStream out)
          Write the BugCollection to given output stream as XML.
 void writeXML(java.lang.String fileName)
          Write this BugCollection to a file as XML.
 void writeXML(XMLOutput xmlOutput)
          Write the BugCollection to an XMLOutput object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedBugCollection

public SortedBugCollection(Project project)

SortedBugCollection

public SortedBugCollection(java.io.File f)
                    throws java.io.IOException,
                           org.dom4j.DocumentException
Throws:
java.io.IOException
org.dom4j.DocumentException

SortedBugCollection

public SortedBugCollection()
Constructor. Creates an empty object.


SortedBugCollection

public SortedBugCollection(java.util.Comparator<BugInstance> comparator)
Constructor. Creates an empty object.


SortedBugCollection

public SortedBugCollection(ProjectStats projectStats)
Constructor. Creates an empty object given an existing ProjectStats.

Parameters:
projectStats - the ProjectStats

SortedBugCollection

public SortedBugCollection(ProjectStats projectStats,
                           Project project)

SortedBugCollection

public SortedBugCollection(ProjectStats projectStats,
                           java.util.Comparator<BugInstance> comparator)
Constructor. Creates an empty object given an existing ProjectStats.

Parameters:
projectStats - the ProjectStats
comparator - to use for sorting bug instances

SortedBugCollection

public SortedBugCollection(ProjectStats projectStats,
                           java.util.Comparator<BugInstance> comparator,
                           Project project)
Method Detail

getTimeStartedLoading

public long getTimeStartedLoading()
Returns:
Returns the timeStartedLoading.

getTimeFinishedLoading

public long getTimeFinishedLoading()
Returns:
Returns the timeFinishedLoading.

getDataSource

public java.lang.String getDataSource()

getProject

public Project getProject()
Specified by:
getProject in interface BugCollection

setRequestDatabaseCloud

public void setRequestDatabaseCloud(boolean useDatabaseCloud)
Specified by:
setRequestDatabaseCloud in interface BugCollection

getCloud

@CheckForNull
public Cloud getCloud()
Description copied from interface: BugCollection
Get the instance of user annotation plugin

Specified by:
getCloud in interface BugCollection
Returns:
user annotation plugin OR null, if there is no annotation plugin installed

isApplySuppressions

public boolean isApplySuppressions()
Specified by:
isApplySuppressions in interface BugCollection

setApplySuppressions

public void setApplySuppressions(boolean applySuppressions)
Specified by:
setApplySuppressions in interface BugCollection

getAnalysisTimestamp

public long getAnalysisTimestamp()
Description copied from interface: BugCollection
Get the timestamp for when the analysis was performed.

Specified by:
getAnalysisTimestamp in interface BugCollection

setAnalysisTimestamp

public void setAnalysisTimestamp(long timestamp)
Description copied from interface: BugCollection
Set the timestamp for when the analysis was performed.

Specified by:
setAnalysisTimestamp in interface BugCollection
Parameters:
timestamp - the analysis timestamp.

addAll

public void addAll(java.util.Collection<BugInstance> collection)
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

public void addAll(java.util.Collection<BugInstance> collection,
                   boolean updateActiveTime)
Add a Collection of BugInstances to this BugCollection object.

Parameters:
collection - the Collection of BugInstances to add
updateActiveTime - true if active time of added BugInstances should be updated to match collection: false if not

add

public boolean add(BugInstance bugInstance)
Add a BugInstance to this BugCollection. This just calls add(bugInstance, true).

Specified by:
add in interface BugCollection
Parameters:
bugInstance - the BugInstance
Returns:
true if the BugInstance was added, or false if a matching BugInstance was already in the BugCollection

addError

public void addError(java.lang.String message)
Add an analysis error.

Specified by:
addError in interface BugCollection
Parameters:
message - the error message

getCurrentAppVersion

public AppVersion getCurrentAppVersion()
Get the current AppVersion.

Specified by:
getCurrentAppVersion in interface BugCollection

readXML

public void readXML(java.lang.String fileName)
             throws java.io.IOException,
                    org.dom4j.DocumentException
Read XML data from given file into this object, populating given Project as a side effect.

Specified by:
readXML in interface BugCollection
Parameters:
fileName - name of the file to read
Throws:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(java.io.File file)
             throws java.io.IOException,
                    org.dom4j.DocumentException
Read XML data from given file into this object, populating given Project as a side effect.

Parameters:
file - the file
Throws:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(java.net.URL u)
             throws java.io.IOException,
                    org.dom4j.DocumentException
Throws:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(@WillClose
                    java.io.InputStream in,
                    java.io.File base)
             throws java.io.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:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(@WillClose
                    java.io.InputStream in)
             throws java.io.IOException,
                    org.dom4j.DocumentException
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 interface BugCollection
Parameters:
in - the InputStream
Throws:
java.io.IOException
org.dom4j.DocumentException

writeXML

public void writeXML(java.lang.String fileName)
              throws java.io.IOException
Write this BugCollection to a file as XML.

Specified by:
writeXML in interface BugCollection
Parameters:
fileName - the file to write to
Throws:
java.io.IOException

writeXML

public void writeXML(java.io.File file)
              throws java.io.IOException
Write this BugCollection to a file as XML.

Parameters:
file - the file to write to
Throws:
java.io.IOException

toDocument

public org.dom4j.Document toDocument()
Convert the BugCollection into a dom4j Document object.

Specified by:
toDocument in interface BugCollection
Returns:
the Document representing the BugCollection as a dom4j tree

writeXML

public void writeXML(@WillClose
                     java.io.OutputStream out)
              throws java.io.IOException
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 interface BugCollection
Parameters:
out - the OutputStream to write to
Throws:
java.io.IOException

writePrologue

public void writePrologue(XMLOutput xmlOutput)
                   throws java.io.IOException
Specified by:
writePrologue in interface BugCollection
Throws:
java.io.IOException

computeBugHashes

public void computeBugHashes()

writeXML

public void writeXML(@WillClose
                     XMLOutput xmlOutput)
              throws java.io.IOException
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 interface BugCollection
Parameters:
xmlOutput - the XMLOutput object
Throws:
java.io.IOException

writeEpilogue

public void writeEpilogue(XMLOutput xmlOutput)
                   throws java.io.IOException
Specified by:
writeEpilogue in interface BugCollection
Throws:
java.io.IOException

cloneAll

public static void cloneAll(java.util.Collection<BugInstance> dest,
                            java.util.Collection<BugInstance> source)
Clone all of the BugInstance objects in the source Collection and add them to the destination Collection.

Parameters:
dest - the destination Collection
source - the source Collection

add

public boolean add(BugInstance bugInstance,
                   boolean updateActiveTime)
Description copied from interface: BugCollection
Add a BugInstance to this BugCollection.

Specified by:
add in interface BugCollection
Parameters:
bugInstance - the BugInstance
updateActiveTime - 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

public boolean remove(BugInstance bugInstance)

iterator

public java.util.Iterator<BugInstance> iterator()
Description copied from interface: BugCollection
Return an Iterator over all the BugInstance objects in the BugCollection.

Specified by:
iterator in interface BugCollection
Specified by:
iterator in interface java.lang.Iterable<BugInstance>

getCollection

public java.util.Collection<BugInstance> getCollection()
Description copied from interface: BugCollection
Return the Collection storing the BugInstance objects.

Specified by:
getCollection in interface BugCollection

addError

public void addError(java.lang.String message,
                     java.lang.Throwable exception)

addError

public void addError(AnalysisError error)
Description copied from interface: BugCollection
Add an analysis error.

Specified by:
addError in interface BugCollection
Parameters:
error - the AnalysisError object to add

addMissingClass

public void addMissingClass(java.lang.String className)
Description copied from interface: BugCollection
Add a missing class message.

Specified by:
addMissingClass in interface BugCollection
Parameters:
className - the missing class message

errorIterator

public java.util.Iterator<AnalysisError> errorIterator()

missingClassIterator

public java.util.Iterator<java.lang.String> missingClassIterator()

contains

public boolean contains(BugInstance bugInstance)

getMatching

public BugInstance getMatching(BugInstance bugInstance)

getSummaryHTML

public java.lang.String getSummaryHTML()
                                throws java.io.IOException
Throws:
java.io.IOException

getProjectStats

public ProjectStats getProjectStats()
Description copied from interface: BugCollection
Get the project stats.

Specified by:
getProjectStats in interface BugCollection

lookupFromUniqueId

@Deprecated
public BugInstance lookupFromUniqueId(java.lang.String uniqueId)
Deprecated. 

Description copied from interface: BugCollection
Look up a BugInstance by its unique id.

Specified by:
lookupFromUniqueId in interface BugCollection
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.

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 interface BugCollection
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 interface BugCollection
Parameters:
sequence - the sequence number
See Also:
BugCollection.getSequenceNumber()

duplicate

public SortedBugCollection duplicate()

clearBugInstances

public void clearBugInstances()

clearMissingClasses

public void clearMissingClasses()
Specified by:
clearMissingClasses in interface BugCollection

getReleaseName

public java.lang.String getReleaseName()
Description copied from interface: BugCollection
Get the current release name.

Specified by:
getReleaseName in interface BugCollection
Returns:
current release name

setReleaseName

public void setReleaseName(java.lang.String releaseName)
Description copied from interface: BugCollection
Set the current release name.

Specified by:
setReleaseName in interface BugCollection
Parameters:
releaseName - the current release name

appVersionIterator

public java.util.Iterator<AppVersion> appVersionIterator()
Description copied from interface: BugCollection
Get an Iterator over AppVersions defined in the collection.

Specified by:
appVersionIterator in interface BugCollection

addAppVersion

public void addAppVersion(AppVersion appVersion)
Description copied from interface: BugCollection
Add an AppVersion representing a version of the analyzed application.

Specified by:
addAppVersion in interface BugCollection
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 interface BugCollection

createEmptyCollectionWithMetadata

public SortedBugCollection createEmptyCollectionWithMetadata()
Description copied from interface: BugCollection
Create a new empty BugCollection with the same metadata as this one.

Specified by:
createEmptyCollectionWithMetadata in interface BugCollection
Returns:
a new empty BugCollection with the same metadata as this one

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 interface BugCollection
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 interface BugCollection

getClassFeatureSet

public ClassFeatureSet getClassFeatureSet(java.lang.String className)

setClassFeatureSet

public void setClassFeatureSet(ClassFeatureSet classFeatureSet)
Specified by:
setClassFeatureSet in interface BugCollection

classFeatureSetIterator

public java.util.Iterator<ClassFeatureSet> classFeatureSetIterator()

clearClassFeatures

public void clearClassFeatures()
Specified by:
clearClassFeatures in interface BugCollection

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 interface BugCollection
Parameters:
withMessages - The withMessages to set.

getWithMessages

public boolean getWithMessages()
Description copied from interface: BugCollection
Return whether textual messages will be added to any generated XML

Specified by:
getWithMessages in interface BugCollection
Returns:
Returns the withMessages.

getAppVersionFromSequenceNumber

public AppVersion getAppVersionFromSequenceNumber(long target)
Description copied from interface: BugCollection
Gets the AppVersion corresponding to the given sequence number.

Specified by:
getAppVersionFromSequenceNumber in interface BugCollection

findBug

public BugInstance findBug(java.lang.String instanceHash,
                           java.lang.String bugType,
                           int lineNumber)
Specified by:
findBug in interface BugCollection

setAnalysisVersion

public void setAnalysisVersion(java.lang.String version)
Description copied from interface: BugCollection
Set the version of FindBugs used to perform the analysis

Specified by:
setAnalysisVersion in interface BugCollection
Parameters:
version -

getAnalysisVersion

public java.lang.String getAnalysisVersion()

progessMonitoredInputStream

public java.io.InputStream progessMonitoredInputStream(java.io.File f,
                                                       java.lang.String msg)
                                                throws java.io.IOException
Throws:
java.io.IOException

progessMonitoredInputStream

public java.io.InputStream progessMonitoredInputStream(java.net.URLConnection c,
                                                       java.lang.String msg)
                                                throws java.io.IOException
Throws:
java.io.IOException

progressMonitoredInputStream

public java.io.InputStream progressMonitoredInputStream(java.io.InputStream in,
                                                        int length,
                                                        java.lang.String msg)

wrapGzip

public java.io.InputStream wrapGzip(java.io.InputStream in,
                                    java.lang.Object source)

reinitializeCloud

public Cloud reinitializeCloud()
Specified by:
reinitializeCloud in interface BugCollection

setMinimalXML

public void setMinimalXML(boolean minimalXML)
Description copied from interface: BugCollection
Set whether we should minimize XML

Specified by:
setMinimalXML in interface BugCollection

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.