net.objectlab.qalab.parser
Class CoberturaLineStatMerge

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by net.objectlab.qalab.parser.BaseStatMerge
          extended by net.objectlab.qalab.parser.CoberturaLineStatMerge
All Implemented Interfaces:
StatMerger, org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
CoberturaBranchStatMerge

public class CoberturaLineStatMerge
extends BaseStatMerge

This class is able to read the XML output from Cobertura (LINE INFORMATION) and integrate the violation results into our "qalab" xml format.

 

Constructor Summary
CoberturaLineStatMerge()
           
 
Method Summary
 void endElement(java.lang.String ignoreNamespaceURI, java.lang.String ignoreSimplename, java.lang.String qualifiedname)
          At the end of an element, check if it is a file one and add the results found.
protected  java.lang.String getSummaryTag()
           
 int getTotalStatistics()
          For Cobertura the total statistics is the average of coverage, ie sum of all percentages divided by the TOTAL number of files (ie we do not report ZERO % coverage but they should count).
 java.lang.String getType()
           
protected  org.xml.sax.InputSource preProcessSource(org.xml.sax.InputSource source)
          This is required to get rid of the SYSTEM DTD otherwise one cannot parse coverage.xml behind most firewalls or offline.
protected  void setFileName(org.xml.sax.Attributes att)
          set the file name from the attributes from Findbugs XML.
 void startElement(java.lang.String ignoreNamespaceURI, java.lang.String localname, java.lang.String qualifiedname, org.xml.sax.Attributes attrs)
          At the start of a new element, capture the filename and if the element is a result one, create a SingleStat to store for the given type.
 
Methods inherited from class net.objectlab.qalab.parser.BaseStatMerge
addFileStatistics, addNewResults, addTotalStatistics, getFileCount, getFileStatistics, getMergerTimeStamp, getSrcDir, getTaskLogger, incrementFileCount, isQuiet, mergeStats, resetFileStatistics, setCurrentFile, setMergerTimeStamp, setQuiet, setSrcDir, setTaskLogger, setTotalStatistics
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoberturaLineStatMerge

public CoberturaLineStatMerge()
Method Detail

getType

public java.lang.String getType()
Returns:
cobertura-line

getSummaryTag

protected final java.lang.String getSummaryTag()

startElement

public final void startElement(java.lang.String ignoreNamespaceURI,
                               java.lang.String localname,
                               java.lang.String qualifiedname,
                               org.xml.sax.Attributes attrs)
                        throws org.xml.sax.SAXException
At the start of a new element, capture the filename and if the element is a result one, create a SingleStat to store for the given type.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - any SAX issue
Parameters:
ignoreNamespaceURI - ignore (present for interface implementation).
localname - name of the current element.
qualifiedname - element name.
attrs - the XML attribute of the current element.

endElement

public final void endElement(java.lang.String ignoreNamespaceURI,
                             java.lang.String ignoreSimplename,
                             java.lang.String qualifiedname)
                      throws org.xml.sax.SAXException
At the end of an element, check if it is a file one and add the results found.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - any SAX issue
Parameters:
ignoreNamespaceURI - ignore (present for interface implementation).
ignoreSimplename - ignore (present for interface implementation).
qualifiedname - the name of the element.

setFileName

protected void setFileName(org.xml.sax.Attributes att)
set the file name from the attributes from Findbugs XML.

Parameters:
att - xml attributes

getTotalStatistics

public int getTotalStatistics()
For Cobertura the total statistics is the average of coverage, ie sum of all percentages divided by the TOTAL number of files (ie we do not report ZERO % coverage but they should count).

Specified by:
getTotalStatistics in interface StatMerger
Overrides:
getTotalStatistics in class BaseStatMerge
Returns:
give the total number of violations.

preProcessSource

protected org.xml.sax.InputSource preProcessSource(org.xml.sax.InputSource source)
This is required to get rid of the SYSTEM DTD otherwise one cannot parse coverage.xml behind most firewalls or offline.

Overrides:
preProcessSource in class BaseStatMerge