org.apache.tools.ant.taskdefs.optional.junit

Class AggregateTransformer

public class AggregateTransformer extends Object

Transform a JUnit xml report. The default transformation generates an html report in either framed or non-framed style. The non-framed style is convenient to have a concise report via mail, the framed report is much more convenient if you want to browse into different packages or testcases since it is a Javadoc like report.
Nested Class Summary
static classAggregateTransformer.Format
defines acceptable formats.
Field Summary
protected static DocumentBuilderFactorydbfactory
XML Parser factory accessible to subclasses
protected Documentdocument
the xml document to process
protected Stringformat
the format to use for the report.
static StringFRAMES
name of the frames format.
static StringNOFRAMES
name of the no frames format.
protected FilestyleDir
the style directory.
protected Tasktask
Task
protected FiletoDir
the destination directory, this is the root from where html should be generated
Constructor Summary
AggregateTransformer(Task task)
constructor creating the transformer from the junitreport task.
Method Summary
protected voidcheckOptions()
check for invalid options
XSLTProcess.ParamcreateParam()
Create an instance of an XSL parameter for configuration by Ant.
protected static DocumentBuilderFactorygetDocumentBuilderFactory()
Get the Document Builder Factory
protected ResourcegetStylesheet()
access the stylesheet to be used as a resource.
protected StringgetStylesheetSystemId()
Get the systemid of the appropriate stylesheet based on its name and styledir.
voidsetExtension(String ext)
set the extension of the output files
voidsetFormat(AggregateTransformer.Format format)
sets the format.
voidsetStyledir(File styledir)
set the style directory.
voidsetTodir(File todir)
set the destination directory.
voidsetXmlDocument(Document doc)
sets the input document.
protected voidsetXmlfile(File xmlfile)
Set the xml file to be processed.
voidtransform()
transformation

Field Detail

dbfactory

protected static DocumentBuilderFactory dbfactory
XML Parser factory accessible to subclasses

document

protected Document document
the xml document to process

format

protected String format
the format to use for the report. Must be FRAMES or NOFRAMES

FRAMES

public static final String FRAMES
name of the frames format.

NOFRAMES

public static final String NOFRAMES
name of the no frames format.

styleDir

protected File styleDir
the style directory. XSLs should be read from here if necessary

task

protected Task task
Task

toDir

protected File toDir
the destination directory, this is the root from where html should be generated

Constructor Detail

AggregateTransformer

public AggregateTransformer(Task task)
constructor creating the transformer from the junitreport task.

Parameters: task task delegating to this class

Method Detail

checkOptions

protected void checkOptions()
check for invalid options

Throws: BuildException if something goes wrong.

createParam

public XSLTProcess.Param createParam()
Create an instance of an XSL parameter for configuration by Ant.

Returns: an instance of the Param class to be configured.

Since: Ant 1.7

getDocumentBuilderFactory

protected static DocumentBuilderFactory getDocumentBuilderFactory()
Get the Document Builder Factory

Returns: the DocumentBuilderFactory instance in use

getStylesheet

protected Resource getStylesheet()
access the stylesheet to be used as a resource.

Returns: stylesheet as a resource

getStylesheetSystemId

protected String getStylesheetSystemId()
Get the systemid of the appropriate stylesheet based on its name and styledir. If no styledir is defined it will load it as a java resource in the xsl child package, otherwise it will get it from the given directory.

Returns: system ID of the stylesheet.

Throws: IOException thrown if the requested stylesheet does not exist.

setExtension

public void setExtension(String ext)
set the extension of the output files

Parameters: ext extension.

setFormat

public void setFormat(AggregateTransformer.Format format)
sets the format.

Parameters: format Must be FRAMES or NOFRAMES

setStyledir

public void setStyledir(File styledir)
set the style directory. It is optional and will override the default xsl used.

Parameters: styledir the directory containing the xsl files if the user would like to override with its own style.

setTodir

public void setTodir(File todir)
set the destination directory.

Parameters: todir the destination directory

setXmlDocument

public void setXmlDocument(Document doc)
sets the input document.

Parameters: doc input dom tree

setXmlfile

protected void setXmlfile(File xmlfile)
Set the xml file to be processed. This is a helper if you want to set the file directly. Much more for testing purposes.

Parameters: xmlfile xml file to be processed

Throws: BuildException if the document cannot be parsed.

transform

public void transform()
transformation

Throws: BuildException exception if something goes wrong with the transformation.