net.objectlab.qalab.parser
Class BuildStatMoverHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by net.objectlab.qalab.parser.BuildStatMoverHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class BuildStatMoverHandler
extends org.xml.sax.helpers.DefaultHandler

A handler class which uses SAX method to parse the XML file from QALab and extract the files that have seen a change in statistics within the time window.

 

Constructor Summary
BuildStatMoverHandler(org.xml.sax.InputSource qaLabSource, java.lang.String types, java.io.Writer outputFile, boolean weekendAdjustment, TaskLogger log, boolean noDebug)
          Constructor used by ant Task/Maven.
 
Method Summary
 void calculateCutoffDateTime()
          Calculate the cutoff date, ie the earliest date for the stat to be taken into account. extra 48h if original cutoff date falls on a Saturday or Sunday.
 void endDocument()
          At the end of parsing the qalab.xml document, generate the up/down report.
 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.
 void getFileName(org.xml.sax.Attributes attrs)
          Gets the filename from the id attribute.
 int getHoursOffsetForLastRun()
           
 java.lang.String getOffsetHours()
           
 org.xml.sax.InputSource getQalabSource()
          Return the input source to the base stats.
 void process()
          Create an instance of the SAX Parser and process the qalab.xml file.
 void setDatecutoff(int offsetInHours)
          calculates the datecutoff by adding the number of offset hours.
 void setEndTimeWindow(java.util.Date endTime)
           
 void setHoursOffsetForLastRun(int hoursOffsetForLastRun)
           
 void setOffsetHours(java.lang.String offset)
           
 void setStartTimeWindow(java.util.Date startTime)
           
 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 org.xml.sax.helpers.DefaultHandler
characters, 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

BuildStatMoverHandler

public BuildStatMoverHandler(org.xml.sax.InputSource qaLabSource,
                             java.lang.String types,
                             java.io.Writer outputFile,
                             boolean weekendAdjustment,
                             TaskLogger log,
                             boolean noDebug)
Constructor used by ant Task/Maven.

Parameters:
qaLabSource - the original QALab file.
types - the types to extract.
outputFile - the output file.
weekendAdjustment - true if it should adjust for weekends.
log - the logger to use.
noDebug - if true, quiet output (no debug info).
Method Detail

process

public final void process()
                   throws javax.xml.parsers.ParserConfigurationException,
                          org.xml.sax.SAXException,
                          java.io.IOException
Create an instance of the SAX Parser and process the qalab.xml file.

Throws:
javax.xml.parsers.ParserConfigurationException - cannot create an instance of parser.
org.xml.sax.SAXException - any SAX issue.
java.io.IOException - any IO/access to file issue.

getFileName

public final void getFileName(org.xml.sax.Attributes attrs)
Gets the filename from the id attribute.

Parameters:
attrs - XML attributes.

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.

getQalabSource

public final org.xml.sax.InputSource getQalabSource()
Return the input source to the base stats.

Returns:
InputSource typically the source to qalab.xml

endDocument

public final void endDocument()
                       throws org.xml.sax.SAXException
At the end of parsing the qalab.xml document, generate the up/down report.

Specified by:
endDocument in interface org.xml.sax.ContentHandler
Overrides:
endDocument in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException - any SAX issue.

setDatecutoff

public final void setDatecutoff(int offsetInHours)
calculates the datecutoff by adding the number of offset hours.

Parameters:
offsetInHours - number of hours from now.

calculateCutoffDateTime

public final void calculateCutoffDateTime()
Calculate the cutoff date, ie the earliest date for the stat to be taken into account. extra 48h if original cutoff date falls on a Saturday or Sunday.


setEndTimeWindow

public final void setEndTimeWindow(java.util.Date endTime)
Parameters:
endTime - The endTimeWindow to set.

setStartTimeWindow

public final void setStartTimeWindow(java.util.Date startTime)
Parameters:
startTime - The startTimeWindow to set.

setOffsetHours

public final void setOffsetHours(java.lang.String offset)
Parameters:
offset - The offsetHours to set.

getOffsetHours

public final java.lang.String getOffsetHours()
Returns:
Returns the offsetHours.

getHoursOffsetForLastRun

public int getHoursOffsetForLastRun()

setHoursOffsetForLastRun

public void setHoursOffsetForLastRun(int hoursOffsetForLastRun)