edu.umd.cs.findbugs

Class SortedBugCollection

public class SortedBugCollection extends 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 classSortedBugCollection.BugInstanceComparator
static classSortedBugCollection.MultiversionBugInstanceComparator
Constructor Summary
SortedBugCollection()
Constructor.
SortedBugCollection(Comparator<BugInstance> comparator)
Constructor.
SortedBugCollection(ProjectStats projectStats)
Constructor.
SortedBugCollection(ProjectStats projectStats, Comparator<BugInstance> comparator)
Constructor.
Method Summary
booleanadd(BugInstance bugInstance)
Add a BugInstance to this BugCollection.
booleanadd(BugInstance bugInstance, boolean updateActiveTime)
voidaddAll(Collection<BugInstance> collection)
Add a Collection of BugInstances to this BugCollection object.
voidaddAll(Collection<BugInstance> collection, boolean updateActiveTime)
Add a Collection of BugInstances to this BugCollection object.
voidaddAppVersion(AppVersion appVersion)
voidaddError(String message)
Add an analysis error.
voidaddError(String message, Throwable exception)
voidaddError(AnalysisError error)
voidaddMissingClass(String className)
Iterator<AppVersion>appVersionIterator()
Iterator<ClassFeatureSet>classFeatureSetIterator()
voidclearAppVersions()
voidclearBugInstances()
voidclearClassFeatures()
static voidcloneAll(Collection<BugInstance> dest, Collection<BugInstance> source)
Clone all of the BugInstance objects in the source Collection and add them to the destination Collection.
voidcomputeBugHashes()
booleancontains(BugInstance bugInstance)
SortedBugCollectioncreateEmptyCollectionWithMetadata()
SortedBugCollectionduplicate()
Iterator<AnalysisError>errorIterator()
BugInstancefindBug(String instanceHash, String bugType, int lineNumber)
longgetAnalysisTimestamp()
AppVersiongetAppVersionFromSequenceNumber(long target)
ClassFeatureSetgetClassFeatureSet(String className)
Collection<BugInstance>getCollection()
AppVersiongetCurrentAppVersion()
Get the current AppVersion.
BugInstancegetMatching(BugInstance bugInstance)
ProjectStatsgetProjectStats()
StringgetReleaseName()
longgetSequenceNumber()
StringgetSummaryHTML()
longgetTimestamp()
booleangetWithMessages()
Iterator<BugInstance>iterator()
Iterator<String>missingClassIterator()
voidreadXML(String fileName, Project project)
Read XML data from given file into this object, populating given Project as a side effect.
voidreadXML(File file, Project project)
Read XML data from given file into this object, populating given Project as a side effect.
voidreadXML(InputStream in, Project project, File base)
Read XML data from given input stream into this object, populating the Project as a side effect.
voidreadXML(InputStream in, Project project)
booleanremove(BugInstance bugInstance)
voidsetAnalysisTimestamp(long timestamp)
voidsetAnalysisVersion(String version)
voidsetClassFeatureSet(ClassFeatureSet classFeatureSet)
voidsetReleaseName(String releaseName)
voidsetSequenceNumber(long sequence)
voidsetTimestamp(long timestamp)
voidsetWithMessages(boolean withMessages)
DocumenttoDocument(Project project)
Convert the BugCollection into a dom4j Document object.
voidwriteEpilogue(XMLOutput xmlOutput)
voidwritePrologue(XMLOutput xmlOutput, Project project)
voidwriteXML(String fileName, Project project)
Write this BugCollection to a file as XML.
voidwriteXML(File file, Project project)
Write this BugCollection to a file as XML.
voidwriteXML(OutputStream out, Project project)
Write the BugCollection to given output stream as XML.
voidwriteXML(XMLOutput xmlOutput, Project project)
Write the BugCollection to an XMLOutput object.

Constructor Detail

SortedBugCollection

public SortedBugCollection()
Constructor. Creates an empty object.

SortedBugCollection

public SortedBugCollection(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, Comparator<BugInstance> comparator)
Constructor. Creates an empty object given an existing ProjectStats.

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

Method Detail

add

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

Parameters: bugInstance the BugInstance

Returns: true if the BugInstance was added, or false if a matching BugInstance was already in the BugCollection

add

public boolean add(BugInstance bugInstance, boolean updateActiveTime)

addAll

public void addAll(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(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

addAppVersion

public void addAppVersion(AppVersion appVersion)

addError

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

Parameters: message the error message

addError

public void addError(String message, Throwable exception)

addError

public void addError(AnalysisError error)

addMissingClass

public void addMissingClass(String className)

appVersionIterator

public Iterator<AppVersion> appVersionIterator()

classFeatureSetIterator

public Iterator<ClassFeatureSet> classFeatureSetIterator()

clearAppVersions

public void clearAppVersions()

clearBugInstances

public void clearBugInstances()

clearClassFeatures

public void clearClassFeatures()

cloneAll

public 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.

Parameters: dest the destination Collection source the source Collection

computeBugHashes

public void computeBugHashes()

contains

public boolean contains(BugInstance bugInstance)

createEmptyCollectionWithMetadata

public SortedBugCollection createEmptyCollectionWithMetadata()

duplicate

public SortedBugCollection duplicate()

errorIterator

public Iterator<AnalysisError> errorIterator()

findBug

public BugInstance findBug(String instanceHash, String bugType, int lineNumber)

getAnalysisTimestamp

public long getAnalysisTimestamp()

getAppVersionFromSequenceNumber

public AppVersion getAppVersionFromSequenceNumber(long target)

getClassFeatureSet

public ClassFeatureSet getClassFeatureSet(String className)

getCollection

public Collection<BugInstance> getCollection()

getCurrentAppVersion

public AppVersion getCurrentAppVersion()
Get the current AppVersion.

getMatching

public BugInstance getMatching(BugInstance bugInstance)

getProjectStats

public ProjectStats getProjectStats()

getReleaseName

public String getReleaseName()

getSequenceNumber

public long getSequenceNumber()

getSummaryHTML

public String getSummaryHTML()

getTimestamp

public long getTimestamp()

getWithMessages

public boolean getWithMessages()

Returns: Returns the withMessages.

iterator

public Iterator<BugInstance> iterator()

missingClassIterator

public Iterator<String> missingClassIterator()

readXML

public void readXML(String fileName, Project project)
Read XML data from given file into this object, populating given Project as a side effect.

Parameters: fileName name of the file to read project the Project

readXML

public void readXML(File file, Project project)
Read XML data from given file into this object, populating given Project as a side effect.

Parameters: file the file project the Project

readXML

public void readXML(InputStream in, Project project, File base)
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 project the Project

readXML

public void readXML(InputStream in, Project project)

remove

public boolean remove(BugInstance bugInstance)

setAnalysisTimestamp

public void setAnalysisTimestamp(long timestamp)

setAnalysisVersion

public void setAnalysisVersion(String version)

Parameters: version

setClassFeatureSet

public void setClassFeatureSet(ClassFeatureSet classFeatureSet)

setReleaseName

public void setReleaseName(String releaseName)

setSequenceNumber

public void setSequenceNumber(long sequence)

setTimestamp

public void setTimestamp(long timestamp)

setWithMessages

public void setWithMessages(boolean withMessages)

Parameters: withMessages The withMessages to set.

toDocument

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

Parameters: project the Project from which the BugCollection was generated

Returns: the Document representing the BugCollection as a dom4j tree

writeEpilogue

public void writeEpilogue(XMLOutput xmlOutput)

writePrologue

public void writePrologue(XMLOutput xmlOutput, Project project)

writeXML

public void writeXML(String fileName, Project project)
Write this BugCollection to a file as XML.

Parameters: fileName the file to write to project the Project from which the BugCollection was generated

writeXML

public void writeXML(File file, Project project)
Write this BugCollection to a file as XML.

Parameters: file the file to write to project the Project from which the BugCollection was generated

writeXML

public void writeXML(OutputStream out, Project project)
Write the BugCollection to given output stream as XML. The output stream will be closed, even if an exception is thrown.

Parameters: out the OutputStream to write to project the Project from which the BugCollection was generated

writeXML

public void writeXML(XMLOutput xmlOutput, Project project)
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".

Parameters: xmlOutput the XMLOutput object project the Project from which the BugCollection was generated

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