net.objectlab.qalab.parser
Class BaseStatMerge

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

public abstract class BaseStatMerge
extends org.xml.sax.helpers.DefaultHandler
implements StatMerger

This class abstract some methods used by all Stat Mergers being for Checkstyle, pmd, findbugs or Simian. This class implements some SAX callbacks for parsing the input statistics.

 

Constructor Summary
BaseStatMerge()
           
 
Method Summary
protected  void addFileStatistics(int increment)
          add a increment of file violation and also add it to the total violation count.
protected  void addNewResults()
          Add new results to the compiled statistics.
protected  void addTotalStatistics(int increment)
           
 int getFileCount()
           
protected  int getFileStatistics()
           
 java.lang.String getMergerTimeStamp()
          This may have been changed to "now".
 java.lang.String getSrcDir()
           
protected  TaskLogger getTaskLogger()
           
 int getTotalStatistics()
           
protected  void incrementFileCount(int increment)
          Increment file count by increment.
 boolean isQuiet()
           
 void mergeStats(org.xml.sax.InputSource source, QALabExporter qalabExporter)
          called by the ant task or the maven plug in.
protected  org.xml.sax.InputSource preProcessSource(org.xml.sax.InputSource source)
           
protected  void resetFileStatistics()
          reset the fileStatistics to 0, typically when handling a new file.
 void setCurrentFile(java.lang.String theFile)
           
 void setMergerTimeStamp(java.lang.String timestamp, boolean timeStampAsDate)
          set the merger time stamp to use for all stats.
 void setQuiet(boolean noLog)
          if quiet is true, the merger should limit its log output.
 void setSrcDir(java.lang.String directory)
          this will be used to truncate machine specific path.
 void setTaskLogger(TaskLogger task)
          set the logger to use.
protected  void setTotalStatistics(int value)
          Directly set the total statistics.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.objectlab.qalab.parser.StatMerger
getType
 

Constructor Detail

BaseStatMerge

public BaseStatMerge()
Method Detail

setCurrentFile

public final void setCurrentFile(java.lang.String theFile)
Parameters:
theFile - the current file for which the stats are processed.

isQuiet

public final boolean isQuiet()
Returns:
true means that no debug info is logged.

setQuiet

public final void setQuiet(boolean noLog)
Description copied from interface: StatMerger
if quiet is true, the merger should limit its log output.

Specified by:
setQuiet in interface StatMerger
Parameters:
noLog - true if no log required.

setTaskLogger

public final void setTaskLogger(TaskLogger task)
set the logger to use.

Specified by:
setTaskLogger in interface StatMerger
Parameters:
task - the logger.

getTaskLogger

protected final TaskLogger getTaskLogger()
Returns:
logger to use if not quiet.

setSrcDir

public final void setSrcDir(java.lang.String directory)
this will be used to truncate machine specific path.

Specified by:
setSrcDir in interface StatMerger
Parameters:
directory - the source directory.

getSrcDir

public final java.lang.String getSrcDir()
Returns:
the source directory

addNewResults

protected final void addNewResults()
Add new results to the compiled statistics. This could will generate a new <result> element and may be a new <file> element.


getTotalStatistics

public int getTotalStatistics()
Specified by:
getTotalStatistics in interface StatMerger
Returns:
give the total number of violations.

addTotalStatistics

protected final void addTotalStatistics(int increment)
Parameters:
increment - add increment to total number of violations.

setTotalStatistics

protected final void setTotalStatistics(int value)
Directly set the total statistics.

Parameters:
value -

getFileCount

public final int getFileCount()
Specified by:
getFileCount in interface StatMerger
Returns:
number of file counted.

incrementFileCount

protected final void incrementFileCount(int increment)
Increment file count by increment.

Parameters:
increment - increase file count by this value.

getFileStatistics

protected final int getFileStatistics()
Returns:
number of violation for current file.

addFileStatistics

protected final void addFileStatistics(int increment)
add a increment of file violation and also add it to the total violation count.

Parameters:
increment - value to add to the number of fileStatistics.

resetFileStatistics

protected final void resetFileStatistics()
reset the fileStatistics to 0, typically when handling a new file.


mergeStats

public final void mergeStats(org.xml.sax.InputSource source,
                             QALabExporter qalabExporter)
called by the ant task or the maven plug in.

Specified by:
mergeStats in interface StatMerger
Parameters:
source - the Reader from the statistics file.
qalabExporter - the QALabExporter to use for saving the stats.

preProcessSource

protected org.xml.sax.InputSource preProcessSource(org.xml.sax.InputSource source)

setMergerTimeStamp

public final void setMergerTimeStamp(java.lang.String timestamp,
                                     boolean timeStampAsDate)
set the merger time stamp to use for all stats.

Specified by:
setMergerTimeStamp in interface StatMerger
Parameters:
timestamp - the timestamp "YYYY-MM-dd HH:mm:ss"
timeStampAsDate - The timeStampAsDateOnly to set.

getMergerTimeStamp

public final java.lang.String getMergerTimeStamp()
This may have been changed to "now".

Specified by:
getMergerTimeStamp in interface StatMerger
Returns:
timestamp the time stamp in format YYYY-MM-dd HH:mm:ss