com.jrefinery.report.targets.csv
Class CSVProcessor

java.lang.Object
  extended bycom.jrefinery.report.targets.csv.CSVProcessor

public class CSVProcessor
extends java.lang.Object

The CSVProcessor coordinates the writing process for the raw CSV output.

A CSVWriter is added to the private copy of the report to handle the output process.

Author:
Thomas Morgner

Field Summary
static java.lang.String CSV_DATAROWNAME
          A key for accessing the 'print data row names' flag in the ReportConfiguration.
static java.lang.String CSV_SEPARATOR
          A key for accessing the separator string in the ReportConfiguration.
 
Constructor Summary
CSVProcessor(JFreeReport report)
          Creates a new CSVProcessor.
CSVProcessor(JFreeReport report, java.lang.String separator)
          Creates a new CSVProcessor.
CSVProcessor(JFreeReport report, java.lang.String separator, boolean writeDataRowNames)
          Creates a new CSVProcessor.
 
Method Summary
protected  JFreeReport getReport()
          Gets the local copy of the report.
 java.io.Writer getWriter()
          Returns the writer used in this Processor.
 void processReport()
          Processes the report.
 void setWriter(java.io.Writer writer)
          Defines the writer which should be used to write the contents of the report.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CSV_SEPARATOR

public static final java.lang.String CSV_SEPARATOR
A key for accessing the separator string in the ReportConfiguration.

See Also:
Constant Field Values

CSV_DATAROWNAME

public static final java.lang.String CSV_DATAROWNAME
A key for accessing the 'print data row names' flag in the ReportConfiguration.

See Also:
Constant Field Values
Constructor Detail

CSVProcessor

public CSVProcessor(JFreeReport report)
             throws ReportProcessingException,
                    FunctionInitializeException
Creates a new CSVProcessor. The processor will use a comma (",") to separate the column values, unless defined otherwise in the report configuration. The processor creates a private copy of the clone, so that no change to the original report will influence the report processing. DataRow names are not written.

Parameters:
report - the report to be processed.
Throws:
ReportProcessingException - if the report initialisation failed.
FunctionInitializeException - if the writer initialisation failed.

CSVProcessor

public CSVProcessor(JFreeReport report,
                    java.lang.String separator)
             throws ReportProcessingException,
                    FunctionInitializeException
Creates a new CSVProcessor. The processor will use the specified separator, the report configuration is not queried for a separator. The processor creates a private copy of the clone, so that no change to the original report will influence the report processing. DataRowNames are not written.

Parameters:
report - the report to be processed.
separator - the separator string to mark column boundaries.
Throws:
ReportProcessingException - if the report initialisation failed.
FunctionInitializeException - if the writer initialisation failed.

CSVProcessor

public CSVProcessor(JFreeReport report,
                    java.lang.String separator,
                    boolean writeDataRowNames)
             throws ReportProcessingException,
                    FunctionInitializeException
Creates a new CSVProcessor. The processor will use the specified separator, the report configuration is not queried for a separator. The processor creates a private copy of the clone, so that no change to the original report will influence the report processing. The first row will contain the datarow names.

Parameters:
report - the report to be processed.
separator - the separator string to mark column boundaries.
writeDataRowNames - controls whether or not the data row names are output.
Throws:
ReportProcessingException - if the report initialisation failed.
FunctionInitializeException - if the writer initialization failed.
Method Detail

getReport

protected JFreeReport getReport()
Gets the local copy of the report. This report is initialized to handle the report writing, changes to the report can have funny results, so be carefull, when using the report object.

Returns:
the local copy of the report.

getWriter

public java.io.Writer getWriter()
Returns the writer used in this Processor.

Returns:
the writer

setWriter

public void setWriter(java.io.Writer writer)
Defines the writer which should be used to write the contents of the report.

Parameters:
writer - the writer.

processReport

public void processReport()
                   throws ReportProcessingException
Processes the report. The generated output is written using the defined writer, the report is repaginated before the final writing.

Throws:
ReportProcessingException - if the report processing failed.
java.lang.IllegalStateException - if there is no writer defined.