org.schmant.report
Class FileReportFactory

java.lang.Object
  extended by org.schmant.report.FileReportFactory
All Implemented Interfaces:
ReportFactory
Direct Known Subclasses:
OverwritingFileReportFactory

public class FileReportFactory
extends Object
implements ReportFactory

This is a ReportFactory that creates FileReport Report:s.

The file name for created reporters are schmantlog_[identifier].log. Thus it is important that all Report:s have unique identifiers.

Since:
0.6
Author:
Karl Gustafsson

Constructor Summary
FileReportFactory()
           
 
Method Summary
protected  String getLogFileName(String identifier)
          Get the name of the log file for the specified identifier.
protected  File getLoggingDirectory()
          Get the directory where the log files are stored.
protected  boolean isAppend()
          Should existing log files be appended? This implementation returns true (a safe default).
 Report newReport(String identifier)
          Create a new Report instance.
 void setReportLineFormatter(ReportLineFormatter llf)
          Set the ReportLineFormatter to use for Report objects created from this factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReportFactory

public FileReportFactory()
Method Detail

setReportLineFormatter

public void setReportLineFormatter(ReportLineFormatter llf)
Description copied from interface: ReportFactory
Set the ReportLineFormatter to use for Report objects created from this factory. This must be set before any Report:s are created.

All ReportFactory implementations are required to use a default ReportLineFormatter (probably the SimpleReportLineFormatter) if no other formatter is set.

Specified by:
setReportLineFormatter in interface ReportFactory
Parameters:
llf - The new log line formatter.

getLoggingDirectory

protected File getLoggingDirectory()
Get the directory where the log files are stored. This implementation stores log files in the current working directory. Override this method to change that behavior.

Returns:
The current working directory.

getLogFileName

protected String getLogFileName(String identifier)
Get the name of the log file for the specified identifier. This implementation returns schmantlog_[identifier].log. Override this method to change that behavior.

Parameters:
identifier - The Report identifier.
Returns:
The log file name.

isAppend

protected boolean isAppend()
Should existing log files be appended? This implementation returns true (a safe default). Override to change that behavior.

Returns:
true if existing log files should be appended to.

newReport

public Report newReport(String identifier)
Description copied from interface: ReportFactory
Create a new Report instance.

Specified by:
newReport in interface ReportFactory
Parameters:
identifier - A unique identifier for the instance (for identifying messages logged from different execution threads), or null for no identifier.
Returns:
A new Report instance.