org.e2etrace.formatter
Class AbstractTraceFormatter

java.lang.Object
  extended by org.e2etrace.formatter.AbstractTraceFormatter
All Implemented Interfaces:
ITraceFormatter
Direct Known Subclasses:
CSVTraceFormatter, PlainTextTraceFormatter

public abstract class AbstractTraceFormatter
extends Object
implements ITraceFormatter

Base class for trace formatters.

This class provides the logic for traversing a tree of trace steps. For each step the call-back formatSingleStep is invoked and the result written to the output stream. Additionally, formatHeader and formatFooter are invoked to generate formatter header and footer information.

Author:
Gunther Popp

Constructor Summary
protected AbstractTraceFormatter()
          Default constructor.
 
Method Summary
 void format(ITraceSession session, Writer toWriter)
          Generate a formatted output for the supplied trace session.
protected abstract  String formatSingleStep(ITraceStep step, int level)
          CALL-BACK: Generate formatted output for a single trace step.
protected  String getNewLine()
          Returns the platform dependent newline character(s).
protected abstract  void writeFooter(ITraceSession session, Writer toWriter)
          CALL-BACK: Write the footer of the trace output.
protected abstract  void writeHeader(ITraceSession session, Writer toWriter)
          CALL-BACK: Write the header of the trace output.
protected  void writeSteps(ITraceStep step, Writer toWriter, int level)
          Writes output of a trace step using a given call level and forwards the call to all child steps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTraceFormatter

protected AbstractTraceFormatter()
Default constructor.

Method Detail

formatSingleStep

protected abstract String formatSingleStep(ITraceStep step,
                                           int level)
CALL-BACK: Generate formatted output for a single trace step.

Parameters:
step - trace step
level - current call level (starting with 0)
Returns:
formatted output

format

public void format(ITraceSession session,
                   Writer toWriter)
            throws IOException
Generate a formatted output for the supplied trace session.

Specified by:
format in interface ITraceFormatter
Parameters:
session - trace session
toWriter - Writer to send the output to
Throws:
IOException - A problem occured sending the output to toWriter

getNewLine

protected String getNewLine()
Returns the platform dependent newline character(s).

Returns:
newline character(s)

writeFooter

protected abstract void writeFooter(ITraceSession session,
                                    Writer toWriter)
                             throws IOException
CALL-BACK: Write the footer of the trace output.

Parameters:
session - trace session
toWriter - output writer
Throws:
IOException - A problem occured sending the output to toWriter

writeHeader

protected abstract void writeHeader(ITraceSession session,
                                    Writer toWriter)
                             throws IOException
CALL-BACK: Write the header of the trace output.

Parameters:
session - trace session
toWriter - output writer
Throws:
IOException - A problem occured sending the output to toWriter

writeSteps

protected void writeSteps(ITraceStep step,
                          Writer toWriter,
                          int level)
                   throws IOException
Writes output of a trace step using a given call level and forwards the call to all child steps.

Parameters:
step - current step
toWriter - toWriter Writer to send the output to
level - current call level (starting with 0)
Throws:
IOException - A problem occured sending the output to toWriter


Copyright © 2013 Gunther Popp. All Rights Reserved.