edu.umd.cs.findbugs
Class BugCollection

java.lang.Object
  extended by edu.umd.cs.findbugs.BugCollection
Direct Known Subclasses:
SortedBugCollection

public abstract class BugCollection
extends java.lang.Object

Abstract base class for collections of BugInstance objects and error messages associated with analysis. Supports reading and writing XML files.

Author:
David Hovemeyer
See Also:
BugInstance

Field Summary
(package private) static java.lang.String ANALYSIS_ERROR_ELEMENT_NAME
           
(package private) static java.lang.String APP_CLASS_ELEMENT_NAME
           
(package private) static java.lang.String ERRORS_ELEMENT_NAME
           
(package private) static java.lang.String MISSING_CLASS_ELEMENT_NAME
           
(package private) static java.lang.String PROJECT_ELEMENT_NAME
           
(package private) static java.lang.String ROOT_ELEMENT_NAME
           
(package private) static java.lang.String SRCMAP_ELEMENT_NAME
           
(package private) static java.lang.String SUMMARY_HTML_ELEMENT_NAME
           
 
Constructor Summary
BugCollection()
           
 
Method Summary
abstract  boolean add(BugInstance bugInstance)
          Add a BugInstance to this BugCollection.
 void addAll(java.util.Collection<BugInstance> collection)
          Add a Collection of BugInstances to this BugCollection object.
abstract  void addError(java.lang.String message)
          Add an analysis error message.
abstract  void addMissingClass(java.lang.String message)
          Add a missing class message.
private  void checkInputStream(java.io.InputStream in)
           
private  void doReadXML(java.io.InputStream in, Project project)
           
abstract  java.util.Iterator<java.lang.String> errorIterator()
          Return an Iterator over error messages.
abstract  java.util.Collection<BugInstance> getCollection()
          Return the Collection storing the BugInstance objects.
abstract  java.lang.String getSummaryHTML()
          Get the summary HTML text.
abstract  java.util.Iterator<BugInstance> iterator()
          Return an Iterator over all the BugInstance objects in the BugCollection.
abstract  java.util.Iterator<java.lang.String> missingClassIterator()
          Return an Iterator over missing class messages.
 void readXML(java.io.File file, Project project)
          Read XML data from given file into this object, populating given Project as a side effect.
 void readXML(java.io.InputStream in, Project project)
          Read XML data from given input stream into this object, populating the Project as a side effect.
 void readXML(java.lang.String fileName, Project project)
          Read XML data from given file into this object, populating given Project as a side effect.
abstract  boolean remove(BugInstance bugInstance)
          Remove a BugInstance from this BugCollection.
abstract  void setSummaryHTML(java.lang.String html)
          Set the summary HTML text.
 org.dom4j.Document toDocument(Project project)
          Convert the BugCollection into a dom4j Document object.
 void writeXML(java.io.File file, Project project)
          Write this BugCollection to a file as XML.
 void writeXML(java.io.OutputStream out, Project project)
          Write the BugCollection to given output stream as XML.
 void writeXML(java.lang.String fileName, Project project)
          Write this BugCollection to a file as XML.
 void writeXML(XMLOutput xmlOutput, Project project)
          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
 

Field Detail

ROOT_ELEMENT_NAME

static final java.lang.String ROOT_ELEMENT_NAME
See Also:
Constant Field Values

SRCMAP_ELEMENT_NAME

static final java.lang.String SRCMAP_ELEMENT_NAME
See Also:
Constant Field Values

PROJECT_ELEMENT_NAME

static final java.lang.String PROJECT_ELEMENT_NAME
See Also:
Constant Field Values

ERRORS_ELEMENT_NAME

static final java.lang.String ERRORS_ELEMENT_NAME
See Also:
Constant Field Values

ANALYSIS_ERROR_ELEMENT_NAME

static final java.lang.String ANALYSIS_ERROR_ELEMENT_NAME
See Also:
Constant Field Values

MISSING_CLASS_ELEMENT_NAME

static final java.lang.String MISSING_CLASS_ELEMENT_NAME
See Also:
Constant Field Values

SUMMARY_HTML_ELEMENT_NAME

static final java.lang.String SUMMARY_HTML_ELEMENT_NAME
See Also:
Constant Field Values

APP_CLASS_ELEMENT_NAME

static final java.lang.String APP_CLASS_ELEMENT_NAME
See Also:
Constant Field Values
Constructor Detail

BugCollection

public BugCollection()
Method Detail

addAll

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

Parameters:
collection - the Collection of BugInstances to add

add

public abstract boolean add(BugInstance bugInstance)
Add a BugInstance to this BugCollection.

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

remove

public abstract boolean remove(BugInstance bugInstance)
Remove a BugInstance from this BugCollection.

Parameters:
bugInstance - the BugInstance
Returns:
true if the BugInstance was removed, or false if it (or an equivalent BugInstance) was not present originally

iterator

public abstract java.util.Iterator<BugInstance> iterator()
Return an Iterator over all the BugInstance objects in the BugCollection.


getCollection

public abstract java.util.Collection<BugInstance> getCollection()
Return the Collection storing the BugInstance objects.


addError

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

Parameters:
message - the error message

addMissingClass

public abstract void addMissingClass(java.lang.String message)
Add a missing class message.

Parameters:
message - the missing class message

errorIterator

public abstract java.util.Iterator<java.lang.String> errorIterator()
Return an Iterator over error messages.


missingClassIterator

public abstract java.util.Iterator<java.lang.String> missingClassIterator()
Return an Iterator over missing class messages.


setSummaryHTML

public abstract void setSummaryHTML(java.lang.String html)
Set the summary HTML text.


getSummaryHTML

public abstract java.lang.String getSummaryHTML()
Get the summary HTML text.


readXML

public void readXML(java.lang.String fileName,
                    Project project)
             throws java.io.IOException,
                    org.dom4j.DocumentException
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
Throws:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(java.io.File file,
                    Project project)
             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
project - the Project
Throws:
java.io.IOException
org.dom4j.DocumentException

readXML

public void readXML(java.io.InputStream in,
                    Project project)
             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
project - the Project
Throws:
java.io.IOException
org.dom4j.DocumentException

doReadXML

private void doReadXML(java.io.InputStream in,
                       Project project)
                throws java.io.IOException,
                       org.dom4j.DocumentException
Throws:
java.io.IOException
org.dom4j.DocumentException

writeXML

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

Parameters:
fileName - the file to write to
project - the Project from which the BugCollection was generated
Throws:
java.io.IOException

writeXML

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

Parameters:
file - the file to write to
project - the Project from which the BugCollection was generated
Throws:
java.io.IOException

toDocument

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

writeXML

public void writeXML(java.io.OutputStream out,
                     Project project)
              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.

Parameters:
out - the OutputStream to write to
project - the Project from which the BugCollection was generated
Throws:
java.io.IOException

writeXML

public void writeXML(XMLOutput xmlOutput,
                     Project project)
              throws java.io.IOException
Write the BugCollection to an XMLOutput object. The finish() method of the XMLOutput object is guaranteed to be called.

Parameters:
xmlOutput - the XMLOutput object
project - the Project from which the BugCollection was generated
Throws:
java.io.IOException

checkInputStream

private void checkInputStream(java.io.InputStream in)
                       throws java.io.IOException
Throws:
java.io.IOException