org.apache.tools.ant.taskdefs.optional.metamata

Class MMetricsStreamHandler

public class MMetricsStreamHandler extends Object implements ExecuteStreamHandler

A handy metrics handler. Most of this code was done only with the screenshots on the documentation since the evaluation version as of this writing does not allow to save metrics or to run it via command line.

This class can be used to transform a text file or to process the output stream directly.

Method Summary
protected AttributescreateAttributes(MetricsElement elem)
Create all attributes of a MetricsElement skipping those who have an empty string
protected StringgetConstructType(MetricsElement elem)
return the construct type of the element.
protected voidparseOutput()
read each line and process it
protected voidprocessLine(String line)
Process a metrics line.
voidsetProcessErrorStream(InputStream p1)
Ignore.
voidsetProcessInputStream(OutputStream p1)
Ignore.
voidsetProcessOutputStream(InputStream is)
Set the inputstream
voidstart()
protected voidstartElement(MetricsElement elem)
Start a new construct.
voidstop()
Pretty dangerous business here.

Method Detail

createAttributes

protected Attributes createAttributes(MetricsElement elem)
Create all attributes of a MetricsElement skipping those who have an empty string

getConstructType

protected String getConstructType(MetricsElement elem)
return the construct type of the element. We can hardly recognize the type of a metrics element, so we are kind of forced to do some black magic based on the name and indentation to recognize the type.

Parameters: elem the metrics element to guess for its type.

Returns: the type of the metrics element, either PACKAGE, FILE, CLASS or METHOD.

parseOutput

protected void parseOutput()
read each line and process it

processLine

protected void processLine(String line)
Process a metrics line. If the metrics is invalid and that this is not the header line, it is display as info.

Parameters: line the line to process, it is normally a line full of metrics.

setProcessErrorStream

public void setProcessErrorStream(InputStream p1)
Ignore.

setProcessInputStream

public void setProcessInputStream(OutputStream p1)
Ignore.

setProcessOutputStream

public void setProcessOutputStream(InputStream is)
Set the inputstream

start

public void start()

startElement

protected void startElement(MetricsElement elem)
Start a new construct. Elements are popped until we are on the same parent node, then the element type is guessed and pushed on the stack.

Parameters: elem the element to process.

Throws: SAXException thrown if there is a problem when sending SAX events.

stop

public void stop()
Pretty dangerous business here.
Copyright B) 2000-2007 Apache Software Foundation. All Rights Reserved.