org.pentaho.reporting.engine.classic.core.modules.output.csv
Class CSVWriter

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
      extended by org.pentaho.reporting.engine.classic.core.function.AbstractFunction
          extended by org.pentaho.reporting.engine.classic.core.modules.output.csv.CSVWriter
All Implemented Interfaces:
Serializable, Cloneable, EventListener, ReportListener, Expression, Function, OutputFunction

public class CSVWriter
extends AbstractFunction
implements OutputFunction

The CSV Writer is the content creation function used to create the CSV content. This implementation does no layouting, the DataRow's raw data is written to the supplied writer.

Author:
Thomas Morgner.
See Also:
Serialized Form

Constructor Summary
CSVWriter()
          DefaulConstructor.
 
Method Summary
 void clearInlineSubreports(SubReportProcessType inlineExecution)
           
 Object clone()
          Clones the expression.
 boolean createRollbackInformation()
           
 OutputFunction deriveForPagebreak()
          This method simply clones the function.
 OutputFunction deriveForStorage()
          This method simply clones the function.
 int getDependencyLevel()
          The dependency level defines the level of execution for this function.
 InlineSubreportMarker[] getInlineSubreports()
           
 String getSeparator()
          Gets the separator which is used to separate columns in a row.
 Object getValue()
          Return a selfreference of this CSVWriter.
 Writer getWriter()
          Returns the writer used to output the generated data.
 void groupFinished(ReportEvent event)
          Writes the GroupFooter of the active group.
 void groupStarted(ReportEvent event)
          Writes the GroupHeader of the current group.
 boolean isEnableGroupFooter()
           
 boolean isEnableGroupHeader()
           
 boolean isEnableItemband()
           
 boolean isEnableReportFooter()
           
 boolean isEnableReportHeader()
           
 boolean isWriteDataRowNames()
          Returns whether to print dataRow column names as header.
 boolean isWriteStateColumns()
           
 void itemsAdvanced(ReportEvent event)
          Writes the current ItemBand.
 void itemsFinished(ReportEvent event)
          Receives notification that a group of item bands has been completed.
 void itemsStarted(ReportEvent event)
          Receives notification that a group of item bands is about to be processed.
 void reportFinished(ReportEvent event)
          Writes the ReportFooter.
 void reportStarted(ReportEvent event)
          Writes the ReportHeader and (if defined) the dataRow names.
 void restart(ReportState state)
           
 void setDependencyLevel(int deplevel)
          Overrides the depency level.
 void setEnableGroupFooter(boolean enableGroupFooter)
           
 void setEnableGroupHeader(boolean enableGroupHeader)
           
 void setEnableItemband(boolean enableItemband)
           
 void setEnableReportFooter(boolean enableReportFooter)
           
 void setEnableReportHeader(boolean enableReportHeader)
           
 void setSeparator(String separator)
          Defines the separator, which is used to separate columns in a row.
 void setWriteDataRowNames(boolean writeDataRowNames)
          Defines, whether to print column names in the first row.
 void setWriter(Writer w)
          Defines the writer which should be used to output the generated data.
 void setWriteStateColumns(boolean writeStateColumns)
           
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
reportDone, reportInitialized
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
getDataRow, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setName, setPreserve, setRuntime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.event.ReportListener
reportDone, reportInitialized
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
getDataRow, getInstance, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setName, setRuntime
 

Constructor Detail

CSVWriter

public CSVWriter()
DefaulConstructor. Creates a CSVWriter with a dependency level of -1 and a default CSVQuoter.

Method Detail

isWriteDataRowNames

public boolean isWriteDataRowNames()
Returns whether to print dataRow column names as header.

Returns:
true, if column names are printed, false otherwise.

setWriteDataRowNames

public void setWriteDataRowNames(boolean writeDataRowNames)
Defines, whether to print column names in the first row.

Parameters:
writeDataRowNames - true, if column names are printed, false otherwise

isWriteStateColumns

public boolean isWriteStateColumns()

setWriteStateColumns

public void setWriteStateColumns(boolean writeStateColumns)

isEnableGroupFooter

public boolean isEnableGroupFooter()

setEnableGroupFooter

public void setEnableGroupFooter(boolean enableGroupFooter)

isEnableGroupHeader

public boolean isEnableGroupHeader()

setEnableGroupHeader

public void setEnableGroupHeader(boolean enableGroupHeader)

isEnableItemband

public boolean isEnableItemband()

setEnableItemband

public void setEnableItemband(boolean enableItemband)

isEnableReportFooter

public boolean isEnableReportFooter()

setEnableReportFooter

public void setEnableReportFooter(boolean enableReportFooter)

isEnableReportHeader

public boolean isEnableReportHeader()

setEnableReportHeader

public void setEnableReportHeader(boolean enableReportHeader)

getWriter

public Writer getWriter()
Returns the writer used to output the generated data.

Returns:
the writer

setWriter

public void setWriter(Writer w)
Defines the writer which should be used to output the generated data.

Parameters:
w - the writer

setSeparator

public void setSeparator(String separator)
Defines the separator, which is used to separate columns in a row.

Parameters:
separator - the separator string, never null.
Throws:
NullPointerException - if the separator is null.
IllegalArgumentException - if the separator is an empty string.

getSeparator

public String getSeparator()
Gets the separator which is used to separate columns in a row.

Returns:
the separator, never null.

reportStarted

public void reportStarted(ReportEvent event)
Writes the ReportHeader and (if defined) the dataRow names.

Specified by:
reportStarted in interface ReportListener
Overrides:
reportStarted in class AbstractFunction
Parameters:
event - the event.

reportFinished

public void reportFinished(ReportEvent event)
Writes the ReportFooter.

Specified by:
reportFinished in interface ReportListener
Overrides:
reportFinished in class AbstractFunction
Parameters:
event - the event.

groupStarted

public void groupStarted(ReportEvent event)
Writes the GroupHeader of the current group.

Specified by:
groupStarted in interface ReportListener
Overrides:
groupStarted in class AbstractFunction
Parameters:
event - the event.

groupFinished

public void groupFinished(ReportEvent event)
Writes the GroupFooter of the active group.

Specified by:
groupFinished in interface ReportListener
Overrides:
groupFinished in class AbstractFunction
Parameters:
event - the event.

itemsStarted

public void itemsStarted(ReportEvent event)
Receives notification that a group of item bands is about to be processed.

The next events will be itemsAdvanced events until the itemsFinished event is raised.

Specified by:
itemsStarted in interface ReportListener
Overrides:
itemsStarted in class AbstractFunction
Parameters:
event - The event.

itemsFinished

public void itemsFinished(ReportEvent event)
Receives notification that a group of item bands has been completed.

The itemBand is finished, the report starts to close open groups.

Specified by:
itemsFinished in interface ReportListener
Overrides:
itemsFinished in class AbstractFunction
Parameters:
event - The event.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Writes the current ItemBand.

Specified by:
itemsAdvanced in interface ReportListener
Overrides:
itemsAdvanced in class AbstractFunction
Parameters:
event - the event.

getValue

public Object getValue()
Return a selfreference of this CSVWriter. This selfreference is used to confiugre the output process.

Specified by:
getValue in interface Expression
Returns:
this CSVWriter.

getDependencyLevel

public int getDependencyLevel()
The dependency level defines the level of execution for this function. Higher dependency functions are executed before lower dependency functions. For ordinary functions and expressions, the range for dependencies is defined to start from 0 (lowest dependency possible) to 2^31 (upper limit of int).

PageLayouter functions override the default behaviour an place them self at depency level -1, an so before any user defined function.

Specified by:
getDependencyLevel in interface Expression
Overrides:
getDependencyLevel in class AbstractExpression
Returns:
the level.

setDependencyLevel

public void setDependencyLevel(int deplevel)
Overrides the depency level. Should be lower than any other function depency.

Specified by:
setDependencyLevel in interface Expression
Overrides:
setDependencyLevel in class AbstractExpression
Parameters:
deplevel - the new depency level.

deriveForStorage

public OutputFunction deriveForStorage()
This method simply clones the function. The CSVWriter does not maintain large internal states and therefore need not to be aware of any advanced optimizations.

Specified by:
deriveForStorage in interface OutputFunction
Returns:
the derived function.

deriveForPagebreak

public OutputFunction deriveForPagebreak()
This method simply clones the function. The CSVWriter does not maintain large internal states and therefore need not to be aware of any advanced optimizations.

Specified by:
deriveForPagebreak in interface OutputFunction
Returns:
the derived function.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the expression. The expression should be reinitialized after the cloning.

Expressions maintain no state, cloning is done at the beginning of the report processing to disconnect the expression from any other object space.

Specified by:
clone in interface Expression
Overrides:
clone in class AbstractExpression
Returns:
a clone of this expression.
Throws:
CloneNotSupportedException - this should never happen.

getInlineSubreports

public InlineSubreportMarker[] getInlineSubreports()
Specified by:
getInlineSubreports in interface OutputFunction

clearInlineSubreports

public void clearInlineSubreports(SubReportProcessType inlineExecution)
Specified by:
clearInlineSubreports in interface OutputFunction

restart

public void restart(ReportState state)
Specified by:
restart in interface OutputFunction

createRollbackInformation

public boolean createRollbackInformation()
Specified by:
createRollbackInformation in interface OutputFunction