com.jrefinery.report.targets.table
Class TableProducer

java.lang.Object
  |
  +--com.jrefinery.report.targets.table.TableProducer
Direct Known Subclasses:
CSVTableProducer, ExcelProducer, HtmlProducer, RTFProducer

public abstract class TableProducer
extends java.lang.Object

The TableProducer is responsible for creating the produced Table. After the writer has finished the band layout process, the layouted bands are forwarded into the TableProducer. The TableProducer coordinates the cell creation process and collects the generated TableCellData. The raw CellData objects are later transformed into a TableGridLayout.

This class defines the global contract and provides some helper methods for the implementors.

Author:
Thomas Morgner

Field Summary
static java.lang.String AUTHOR
          Literal text for the 'author' property name.
protected static java.lang.String CREATOR
          A useful constant for specifying the creator constant.
static java.lang.String TITLE
          Literal text for the 'title' property name.
 
Constructor Summary
TableProducer(boolean strictLayout)
          Creates a new TableProducer.
 
Method Summary
protected  void addCell(TableCellData data)
          Adds a new TableCellData to the grid.
abstract  void beginPage(java.lang.String name)
          Handles the start of a new page.
 void clearCells()
          Clears the grid, removes all created cells.
abstract  void close()
          Closes the report and finishs the report writing.
abstract  void configure(java.util.Properties configuration)
          Configures the table producer by reading the configuration settings from the given map.
protected  TableCellBackground createTableCellStyle(java.util.List background)
          Merges all TableCellBackgrounds contained in the given list.
abstract  void endPage()
          Handles the end of a page.
 int getCellCount()
          Gets the number of created cells in the grid.
abstract  TableCellDataFactory getCellDataFactory()
          Gets the TableProducer implementation of this TableProducer.
 java.lang.String getProperty(java.lang.String property)
          Queries the property named with property.
 java.lang.String getProperty(java.lang.String property, java.lang.String defaultValue)
          Queries the property named with property.
protected  java.util.Iterator getPropertyNames()
          Returns an enumeration of the property names.
 boolean isDummy()
          Gets the dummy mode state, in dummy mode no output is done.
abstract  boolean isOpen()
          Returns true, if the TableProducer is open.
protected  TableGridLayout layoutGrid()
          Calculates the positions for the Excel cells.
abstract  void open()
          Starts the report writing.
 void processBand(java.awt.geom.Rectangle2D bounds, Band band)
          Processes the layouted band.
 void setDummy(boolean dummy)
          Defines the dummy mode.
 void setProperty(java.lang.String property, java.lang.String value)
          Defines a property for this output target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TITLE

public static final java.lang.String TITLE
Literal text for the 'title' property name.

See Also:
Constant Field Values

AUTHOR

public static final java.lang.String AUTHOR
Literal text for the 'author' property name.

See Also:
Constant Field Values

CREATOR

protected static final java.lang.String CREATOR
A useful constant for specifying the creator constant.

Constructor Detail

TableProducer

public TableProducer(boolean strictLayout)
Creates a new TableProducer.

Parameters:
strictLayout - the strict layout flag. Set to true, to enable the strict layout mode.
Method Detail

open

public abstract void open()
Starts the report writing. This method is called before any other report handling method is called.


close

public abstract void close()
Closes the report and finishs the report writing. Any used resource should be freed when this method returns. The current page is already closed.


endPage

public abstract void endPage()
Handles the end of a page.


beginPage

public abstract void beginPage(java.lang.String name)
Handles the start of a new page. The page name is given as parameter. The TableWriter starts a new page whenever a manual pagebreak is found in the report definition. The ReportProducer has been opened before.

Parameters:
name - the page name

getCellDataFactory

public abstract TableCellDataFactory getCellDataFactory()
Gets the TableProducer implementation of this TableProducer.

Returns:
the TableProducers TableCellDataFactory, which is used to create the TableCellData.

clearCells

public void clearCells()
Clears the grid, removes all created cells.


layoutGrid

protected TableGridLayout layoutGrid()
Calculates the positions for the Excel cells.

Returns:
The table grid layout.

getCellCount

public int getCellCount()
Gets the number of created cells in the grid.

Returns:
the number of stored cells in the grid.

addCell

protected void addCell(TableCellData data)
Adds a new TableCellData to the grid.

Parameters:
data - the new TableCellData.

isOpen

public abstract boolean isOpen()
Returns true, if the TableProducer is open. Only open producers are able to write TableCells or to create TableCellData from Elements.

Returns:
checks, whether the TableProducer is open.

processBand

public void processBand(java.awt.geom.Rectangle2D bounds,
                        Band band)
Processes the layouted band. The band is inserted on the specified bounds in the TableGrid.

Parameters:
bounds - the bounds that define where to print the given band on this logical page
band - the band that should be spooled/printed

createTableCellStyle

protected TableCellBackground createTableCellStyle(java.util.List background)
Merges all TableCellBackgrounds contained in the given list. The list must be sorted by preference, the first background in the list overlays all other backgrounds.

Parameters:
background - the collected backgrounds for a single table cell.
Returns:
the merged TableCellBackground.

isDummy

public boolean isDummy()
Gets the dummy mode state, in dummy mode no output is done.

Returns:
true, if the producer is working in dummy mode, no output is done.

setDummy

public void setDummy(boolean dummy)
Defines the dummy mode.

Parameters:
dummy - set to true, to activate the dummy mode, so that all output is skipped.

setProperty

public void setProperty(java.lang.String property,
                        java.lang.String value)
Defines a property for this output target. Properties are the standard way of configuring an output target.

Parameters:
property - the name of the property to set (null not permitted).
value - the value of the property. If the value is null, the property is removed from the output target.

getProperty

public java.lang.String getProperty(java.lang.String property)
Queries the property named with property. If the property is not found, null is returned.

Parameters:
property - the name of the property to be queried
Returns:
the value stored under the given property name
Throws:
java.lang.NullPointerException - if property is null

getProperty

public java.lang.String getProperty(java.lang.String property,
                                    java.lang.String defaultValue)
Queries the property named with property. If the property is not found, the default value is returned.

Parameters:
property - the name of the property to be queried
defaultValue - the defaultvalue returned if there is no such property
Returns:
the value stored under the given property name
Throws:
java.lang.NullPointerException - if property is null

getPropertyNames

protected java.util.Iterator getPropertyNames()
Returns an enumeration of the property names.

Returns:
the enumeration.

configure

public abstract void configure(java.util.Properties configuration)
Configures the table producer by reading the configuration settings from the given map.

Parameters:
configuration - the configuration supplied by the table processor.