org.schmant.report
Class AbstractPrintingReport

java.lang.Object
  extended by org.schmant.report.AbstractReport
      extended by org.schmant.report.AbstractPrintingReport
All Implemented Interfaces:
Report
Direct Known Subclasses:
FileReport, StdoutReport

public abstract class AbstractPrintingReport
extends AbstractReport

This is an abstract base class for Report implementations that print their output somewhere.

Since:
0.6
Author:
Karl Gustafsson

Constructor Summary
protected AbstractPrintingReport(String identifier, ReportLineFormatter llf)
          Constructor.
 
Method Summary
 void debug(Object msg)
          Log a message to debug level (Level.FINE).
 void error(Object msg)
          Log a message to error level (Level.SEVERE).
 void error(Object msg, Throwable t)
          Log a message and an exception to error level (Level.SEVERE).
 String getIdentifier()
          Get the identifier for this report.
 ReportLineFormatter getReportLineFormatter()
           
protected  String getSeverityText(Level l)
          Get a text string for the log level.
 PrintWriter getStackTraceWriter(Level l)
          Get a PrintWriter to write a stack trace to if the stack trace for some reason cannot be logged through any of the ordinary logger methods.
 void info(Object msg)
          Log a message to info level (Level.INFO).
 void log(Object o, Level l)
          Log a message to the supplied level.
 void log(Object o, Throwable t, Level l)
          Log a message and an exception to the supplied level.
protected abstract  void printLine(Level l, String line)
          Print the formatted line.
protected abstract  void printStacktrace(Level l, String s)
          Print a stacktrace.
 void trace(Object msg)
          Log a message to trace level (Level.FINER).
 void warn(Object msg)
          Log a message to warn level (Level.WARNING).
 void warn(Object msg, Throwable t)
          Log a message and an exception to warn level (Level.WARNING).
 
Methods inherited from class org.schmant.report.AbstractReport
close, getLevel, isDebugReported, isErrorReported, isInfoReported, isLevelReported, isOpen, isTraceReported, isWarnReported, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPrintingReport

protected AbstractPrintingReport(String identifier,
                                 ReportLineFormatter llf)
Constructor.

Parameters:
identifier - An unique identifier for this report instance. (It is not verified in any way that the identifier actually is unique.)
llf - The log line formatter.
Method Detail

getIdentifier

public String getIdentifier()
Description copied from interface: Report
Get the identifier for this report. It may be null.

Returns:
This report's identifier. May be null.

printLine

protected abstract void printLine(Level l,
                                  String line)
Print the formatted line.

Parameters:
l - The severity of the log message. It is already verified that log messages of this severity should be printed.
line - The formatted log line.

printStacktrace

protected abstract void printStacktrace(Level l,
                                        String s)
Print a stacktrace.

Parameters:
l - The severity of the log message. It is already verified that log messages of this severity should be printed.
s - The formatted stack trace, including newlines.

getSeverityText

protected String getSeverityText(Level l)
Get a text string for the log level.

Parameters:
l - The log level.
Returns:
A descriptive text for the log level, e.g. "INFO".

log

public void log(Object o,
                Level l)
Description copied from interface: Report
Log a message to the supplied level.

Parameters:
o - The message to log.
l - The level to log to.

trace

public void trace(Object msg)
Description copied from interface: Report
Log a message to trace level (Level.FINER).

Parameters:
msg - The message to log.

debug

public void debug(Object msg)
Description copied from interface: Report
Log a message to debug level (Level.FINE).

Parameters:
msg - The message to log.

info

public void info(Object msg)
Description copied from interface: Report
Log a message to info level (Level.INFO).

Parameters:
msg - The message to log.

warn

public void warn(Object msg)
Description copied from interface: Report
Log a message to warn level (Level.WARNING).

Parameters:
msg - The message to log.

warn

public void warn(Object msg,
                 Throwable t)
Description copied from interface: Report
Log a message and an exception to warn level (Level.WARNING).

Parameters:
msg - The message to log.
t - The exception to log.

error

public void error(Object msg)
Description copied from interface: Report
Log a message to error level (Level.SEVERE).

Parameters:
msg - The message to log.

error

public void error(Object msg,
                  Throwable t)
Description copied from interface: Report
Log a message and an exception to error level (Level.SEVERE).

Parameters:
msg - The message to log.
t - The exception to log.

log

public void log(Object o,
                Throwable t,
                Level l)
Description copied from interface: Report
Log a message and an exception to the supplied level.

Parameters:
o - The message to log. This may be null.
t - The exception to log. This may be null.
l - The level to log to.

getStackTraceWriter

public PrintWriter getStackTraceWriter(Level l)
Description copied from interface: Report
Get a PrintWriter to write a stack trace to if the stack trace for some reason cannot be logged through any of the ordinary logger methods.

The caller is responsible for closing the writer.

Parameters:
l - The level to write the stack trace to.
Returns:
A print writer to write a stack trace to.

getReportLineFormatter

public ReportLineFormatter getReportLineFormatter()