net.sf.mavenhist.extractor
Class AbstractValidatingXMLValueExtractor

java.lang.Object
  extended by net.sf.mavenhist.extractor.AbstractXMLValueExtractor
      extended by net.sf.mavenhist.extractor.AbstractValidatingXMLValueExtractor
All Implemented Interfaces:
INamedExtractor, IValueExtractor, IXMLValueExtractor
Direct Known Subclasses:
AbstractXPathValueExtractor, JNCSSFunctionsPerPackageExtractor

public abstract class AbstractValidatingXMLValueExtractor
extends AbstractXMLValueExtractor

Used to validate the xml file with a test xpath that has to return a value.


Constructor Summary
AbstractValidatingXMLValueExtractor()
           
 
Method Summary
 MultiMetric[] extract(Document document)
          Implementation that checks first the validity of the xml file with the xpath given from the method getValidityTestXPath.
protected abstract  MultiMetric[] extractValidatedDocument(Document document)
          Extracts muliple values from one result document.
protected abstract  String getValidityTestXPath()
          The given xml-file will be tested with this xpath to be sure that the result will be valid.
protected  boolean isDocumentValid(Document document, String xpath)
          Tests that the document is valid at all.
 
Methods inherited from class net.sf.mavenhist.extractor.AbstractXMLValueExtractor
extract
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.mavenhist.extractor.INamedExtractor
getName
 

Constructor Detail

AbstractValidatingXMLValueExtractor

public AbstractValidatingXMLValueExtractor()
Method Detail

extract

public final MultiMetric[] extract(Document document)
                            throws ExtractionException
Implementation that checks first the validity of the xml file with the xpath given from the method getValidityTestXPath. If the check was successful the method extractValidatedDocument is called. Extracts multiple values from one result document.

Parameters:
document - to parse for the values.
Returns:
Array of metrics with the differentiated locations and values.
Throws:
ExtractionException - the XML-Queries failed.

extractValidatedDocument

protected abstract MultiMetric[] extractValidatedDocument(Document document)
                                                   throws TransformerException
Extracts muliple values from one result document.

Parameters:
document - to parse for the values.
Returns:
Array of metrics with the differentiated locations and values.
Throws:
TransformerException - the XML-Queries failed.

isDocumentValid

protected boolean isDocumentValid(Document document,
                                  String xpath)
                           throws TransformerException
Tests that the document is valid at all. When the given xpath returns at minimum 1 node the XML is taken as valid.

Parameters:
document - to search inside.
xpath - to check the document with.
Returns:
validity of the document.
Throws:
TransformerException - selection with xpath was not successful.

getValidityTestXPath

protected abstract String getValidityTestXPath()
The given xml-file will be tested with this xpath to be sure that the result will be valid. It is necessairy that the xpath query has a result to mark the XML as okay.

Returns:
XPath to check validity of the given file.


Copyright © 2009. All Rights Reserved.