com.jrefinery.report.targets.table
Class TableWriter

java.lang.Object
  |
  +--com.jrefinery.report.function.AbstractFunction
        |
        +--com.jrefinery.report.targets.table.TableWriter
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener

public class TableWriter
extends AbstractFunction

The TableWriter is the content creation function used to collect the cell data. After the layouting is done, the layouted bands are forwarded to the TableProducer. The virtual page has an unlimited size, only when a manual pagebreak is encountered, a new page is started.

This can be used to f.i. to create separate sheets in Excel-Workbooks, the detailed semantics depend on concrete implementation of the TableProducer.

This writer is not thread-safe.

Author:
Thomas Morgner

Field Summary
static java.lang.String BASE_RESOURCE_CLASS
          The base class for localised resources.
static java.lang.String SHEET_NAME_FUNCTION_PROPERTY
          The SheetName-function property, defines the name of an StringFunction that creates the sheet names.
 
Fields inherited from interface com.jrefinery.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
TableWriter()
          Creates a new TableWriter.
 
Method Summary
 ReportEvent getCurrentEvent()
          Returns the current event, which has been updated at the start of every ReportListener method.
 int getDependencyLevel()
          The dependency level defines the level of execution for this function.
 float getMaxWidth()
          Gets the maximum width available for a root band during the layouting process.
 TableProducer getProducer()
          Gets the TableProducer.
 java.util.ResourceBundle getResources()
          Retrieves the resources for this PreviewFrame.
 java.lang.Object getValue()
          Return the current expression value.
 void groupFinished(ReportEvent event)
          Prints the group footer for the current group.
 void groupStarted(ReportEvent event)
          Prints the group header for the current group.
 void itemsAdvanced(ReportEvent event)
          Prints the itemband.
 void itemsFinished(ReportEvent event)
          Handles the end of the item processing.
 void itemsStarted(ReportEvent event)
          Handles the start of the item processing.
 void pageFinished(ReportEvent event)
          Prints the page footer.
 void pageStarted(ReportEvent event)
          Prints the PageHeader and all repeating group headers.
protected  void print(Band b)
          Performs the band layout and prints the band.
 void reportFinished(ReportEvent event)
          Receives notification that the report has finished.
 void reportStarted(ReportEvent event)
          Receives notification that the report has started.
 void setCurrentEvent(ReportEvent currentEvent)
          Defines the current event, which must be updated at the start of every ReportListener method.
 void setDependencyLevel(int deplevel)
          Overrides the depency level.
 void setMaxWidth(float width)
          Defines the maximum width available for a root band during the layouting process.
 void setProducer(TableProducer producer)
          Sets the TableProducer, that should be used to create the TableCellData.
 void startPage()
          Starts a new page.
 
Methods inherited from class com.jrefinery.report.function.AbstractFunction
clone, getDataRow, getInstance, getName, getProperties, getProperty, getProperty, initialize, isActive, reportDone, reportInitialized, setDataRow, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHEET_NAME_FUNCTION_PROPERTY

public static final java.lang.String SHEET_NAME_FUNCTION_PROPERTY
The SheetName-function property, defines the name of an StringFunction that creates the sheet names.

See Also:
Constant Field Values

BASE_RESOURCE_CLASS

public static final java.lang.String BASE_RESOURCE_CLASS
The base class for localised resources.

See Also:
Constant Field Values
Constructor Detail

TableWriter

public TableWriter()
Creates a new TableWriter. The dependency level is set to -1 and the maxwidth is defined to be 1000.

Method Detail

getValue

public java.lang.Object getValue()
Return the current expression value.

The value depends (obviously) on the expression implementation.

Returns:
the value of the function.

getMaxWidth

public float getMaxWidth()
Gets the maximum width available for a root band during the layouting process.

Returns:
the maximum width for a root band.

setMaxWidth

public void setMaxWidth(float width)
Defines the maximum width available for a root band during the layouting process.

Parameters:
width - the maximum width for a root band.

startPage

public void startPage()
Starts a new page. Fires the PageStarted event.


print

protected void print(Band b)
Performs the band layout and prints the band.

Parameters:
b - the band.

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 userdefined function.

Specified by:
getDependencyLevel in interface Expression
Overrides:
getDependencyLevel in class AbstractFunction
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 AbstractFunction
Parameters:
deplevel - the new depency level.

reportStarted

public void reportStarted(ReportEvent event)
Receives notification that the report has started.

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

reportFinished

public void reportFinished(ReportEvent event)
Receives notification that the report has finished.

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

getResources

public java.util.ResourceBundle getResources()
Retrieves the resources for this PreviewFrame. If the resources are not initialized, they get loaded on the first call to this method.

Returns:
this frames ResourceBundle.

pageStarted

public void pageStarted(ReportEvent event)
Prints the PageHeader and all repeating group headers.

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

pageFinished

public void pageFinished(ReportEvent event)
Prints the page footer.

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

groupStarted

public void groupStarted(ReportEvent event)
Prints the group header for the current group.

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

groupFinished

public void groupFinished(ReportEvent event)
Prints the group footer for the current group.

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

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Prints the itemband.

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

itemsStarted

public void itemsStarted(ReportEvent event)
Handles the start of the item processing.

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)
Handles the end of the item processing.

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.

getCurrentEvent

public ReportEvent getCurrentEvent()
Returns the current event, which has been updated at the start of every ReportListener method.

Returns:
the current event.

setCurrentEvent

public void setCurrentEvent(ReportEvent currentEvent)
Defines the current event, which must be updated at the start of every ReportListener method.

Parameters:
currentEvent - the current event.

getProducer

public TableProducer getProducer()
Gets the TableProducer.

Returns:
the table producer that should be used to create the TableCellData.

setProducer

public void setProducer(TableProducer producer)
Sets the TableProducer, that should be used to create the TableCellData.

Parameters:
producer - the table producer that should be used to create the TableCellData.