|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.tools.ant.taskdefs.optional.metamata.MMetricsStreamHandler
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.
Field Summary | |
protected static java.lang.String[] |
ATTRIBUTES
|
protected static java.lang.String |
CLASS
CLASS construct, it should be named something like 'MyClass' |
protected static java.lang.String |
FILE
FILE construct, it should look like something 'MyClass.java' or 'MyClass.class' |
protected static java.lang.String |
METHOD
METHOD construct, it should looke like something 'doSomething(...)' or 'doSomething()' |
protected javax.xml.transform.sax.TransformerHandler |
metricsHandler
metrics handler |
protected java.io.InputStream |
metricsOutput
reader for stdout |
protected static java.lang.String |
PACKAGE
package construct, it should be look like 'com.mycompany.something' |
protected java.util.Stack |
stack
the stack where are stored the metrics element so that they we can know if we have to close an element or not. |
protected Task |
task
the task |
protected java.io.OutputStream |
xmlOutputStream
this is where the XML output will go, should mostly be a file the caller is responsible for flushing and closing this stream |
Method Summary | |
protected org.xml.sax.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 java.lang.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(java.lang.String line)
Process a metrics line. |
void |
setProcessErrorStream(java.io.InputStream p1)
Ignore. |
void |
setProcessInputStream(java.io.OutputStream p1)
Ignore. |
void |
setProcessOutputStream(java.io.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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final java.lang.String CLASS
protected static final java.lang.String PACKAGE
protected static final java.lang.String FILE
protected static final java.lang.String METHOD
protected static final java.lang.String[] ATTRIBUTES
protected java.io.InputStream metricsOutput
protected java.io.OutputStream xmlOutputStream
protected javax.xml.transform.sax.TransformerHandler metricsHandler
protected Task task
protected java.util.Stack stack
Method Detail |
public void setProcessInputStream(java.io.OutputStream p1) throws java.io.IOException
setProcessInputStream
in interface ExecuteStreamHandler
org.apache.tools.ant.taskdefs.ExecuteStreamHandler
os
- output stream to write to the standard input stream of the
subprocesspublic void setProcessErrorStream(java.io.InputStream p1) throws java.io.IOException
setProcessErrorStream
in interface ExecuteStreamHandler
org.apache.tools.ant.taskdefs.ExecuteStreamHandler
is
- input stream to read from the error stream from the subprocesspublic void setProcessOutputStream(java.io.InputStream is) throws java.io.IOException
setProcessOutputStream
in interface ExecuteStreamHandler
org.apache.tools.ant.taskdefs.ExecuteStreamHandler
is
- input stream to read from the error stream from the subprocesspublic void start() throws java.io.IOException
ExecuteStreamHandler
start
in interface ExecuteStreamHandler
public void stop()
stop
in interface ExecuteStreamHandler
protected void parseOutput() throws java.io.IOException, org.xml.sax.SAXException
protected void processLine(java.lang.String line) throws org.xml.sax.SAXException
line
- the line to process, it is normally a line full of metrics.protected void startElement(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem) throws org.xml.sax.SAXException
elem
- the element to process.org.xml.sax.SAXException
- thrown if there is a problem when sending SAX events.protected java.lang.String getConstructType(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
elem
- the metrics element to guess for its type.protected org.xml.sax.Attributes createAttributes(org.apache.tools.ant.taskdefs.optional.metamata.MetricsElement elem)
elem
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |