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

Class MMetricsStreamHandler

Implemented Interfaces:
ExecuteStreamHandler

public class MMetricsStreamHandler
extends java.lang.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 Attributes
createAttributes(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
Create all attributes of a MetricsElement skipping those who have an empty string
protected String
getConstructType(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
return the construct type of the element.
protected void
parseOutput()
read each line and process it
protected void
processLine(String line)
Process a metrics line.
void
setProcessErrorStream(InputStream p1)
Ignore.
void
setProcessInputStream(OutputStream p1)
Ignore.
void
setProcessOutputStream(InputStream is)
Set the inputstream
void
start()
Start handling of the streams.
protected void
startElement(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
Start a new construct.
void
stop()
Pretty dangerous business here.

Method Details

createAttributes

protected Attributes createAttributes(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
Create all attributes of a MetricsElement skipping those who have an empty string

getConstructType

protected String getConstructType(org.apache.tools.ant.taskdefs.optional.metamata.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()
            throws IOException,
                   SAXException
read each line and process it

processLine

protected void processLine(String line)
            throws SAXException
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)
            throws IOException
Ignore.
Specified by:
setProcessErrorStream in interface ExecuteStreamHandler

setProcessInputStream

public void setProcessInputStream(OutputStream p1)
            throws IOException
Ignore.
Specified by:
setProcessInputStream in interface ExecuteStreamHandler

setProcessOutputStream

public void setProcessOutputStream(InputStream is)
            throws IOException
Set the inputstream
Specified by:
setProcessOutputStream in interface ExecuteStreamHandler

start

public void start()
            throws IOException
Start handling of the streams.
Specified by:
start in interface ExecuteStreamHandler

startElement

protected void startElement(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
            throws SAXException
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.

stop

public void stop()
Pretty dangerous business here.
Specified by:
stop in interface ExecuteStreamHandler

Copyright B) 2000-2008 Apache Software Foundation. All Rights Reserved.