sos.reports
Class TableReportTemplate

java.lang.Object
  |
  +--sos.reports.AbstractReportTemplate
        |
        +--sos.reports.TableReportTemplate
All Implemented Interfaces:
ReportTemplate, java.io.Serializable

public class TableReportTemplate
extends AbstractReportTemplate
implements ReportTemplate, java.io.Serializable

A report template that creates a report from an Object[], java.util.List, javax.swing.ListModel, Object[][], java.util.Map, javax.swing.text.TableModel, or ReportTableModel. The report can handle any number of header and footer tiers and cells that straddle multiple rows or columns.

Editability

Reports produced by this template allow editing of the cell content unless the content is given by a ListModel. The ListModel interface has no way to set a value. If the table data is given by a TableModel, then isCellEditable determines if the content is editable. The edited value is pushed back into the underlying data structure.

Cell Straddling

This class allows cells to straddle more than one row or column. To indicate that a cell spans more than one row or column, clients should use the constants STRADDLE_PREVIOUS_COLUMN and STRADDLE_PREVIOUS_ROW.

For example, the following example creates a report table with straddling cells:

 Object[][] data = new Object[][] {
   { "Cell 0,0", "Cell 0,1", "Spans 3 columns" },
   { "Spans 2 rows 2 columns", TableReportTemplate.STRADDLE_PREVIOUS_COLUMN, TableReportTemplate.STRADDLE_PREVIOUS_ROW },
   { TableReportTemplate.STRADDLE_PREVIOUS_ROW, TableReportTemplate.STRADDLE_PREVIOUS_ROW, TableReportTemplate.STRADDLE_PREVIOUS_ROW },
   { "Cell 3,0", "Spans 2 rows", TableReportTemplate.STRADDLE_PREVIOUS_COLUMN }
 };

 TableReportTemplate template = new TableReportTemplate();
 Report report = template.createReport( data );
 
Straddling cells should not cross header and footer tier boundaries.

Themes

This template does not provide any meaningful report themes. However, clients can create their own themes as long as they use the correct style names. For the style name of the table element, this class invokes ReportTableModel.getTableStyleName(). For the style name of a row element, this class uses the string returned by ReportTableModel.getRowStyleNameAt(int). For the style name of a column element, this class invokes ReportTableModel.getColumnStyleNameAt(int). The style names used by the cell elements are determined from ReportTableModel.getCellStyleNameAt(int, int). Last, the style names used by the cell content is given by ReportTableModel.getStyleNameAt(int, int). The client can customize these style names by providing the data as an instance of ReportTableModel and implementing these methods accordingly. All other forms of data use the style name convention set in AbstractReportTableModel.

Since:
1.0
See Also:
ReportTableModel, AbstractReportTableModel

Field Summary
static java.lang.Object STRADDLE_PREVIOUS_COLUMN
          A place holder object that indicates that this cell is a part of the cell in the previous column.
static java.lang.Object STRADDLE_PREVIOUS_ROW
          A place holder object that indicates that this cell is a part of the cell in the previous row.
static int USE_COLUMN_NAMES
          A constant (used as the number of row headers) to indicate that the template should use the column names as row headers.
 
Constructor Summary
TableReportTemplate()
          Creates an instance of TableReportTemplate with a default name and 0 as the number of header and footer rows and columns.
TableReportTemplate(java.lang.String name)
          Creates an instance of TableReportTemplate with the specified name and 0 as the number of header and footer rows and columns.
TableReportTemplate(java.lang.String name, int numHeaderRows, int numHeaderColumns, int numFooterRows, int numFooterColumns)
          Creates an instance of TableReportTemplate that has the specified number of header and footer rows and columns.
 
Method Summary
 Report createReport(java.lang.Object content, Theme theme)
          Creates a report with the specified content and theme.
 java.lang.String getName()
          Returns a localized name of this report template.
 void setColumnPrototypes(java.lang.Object[] prototypeColumnValues)
          Sets the column prototype values.
 
Methods inherited from class sos.reports.AbstractReportTemplate
createReport, getDefaultTheme, getThemes, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sos.reports.ReportTemplate
createReport, getDefaultTheme, getThemes
 

Field Detail

STRADDLE_PREVIOUS_ROW

public static final java.lang.Object STRADDLE_PREVIOUS_ROW
A place holder object that indicates that this cell is a part of the cell in the previous row.


STRADDLE_PREVIOUS_COLUMN

public static final java.lang.Object STRADDLE_PREVIOUS_COLUMN
A place holder object that indicates that this cell is a part of the cell in the previous column.


USE_COLUMN_NAMES

public static final int USE_COLUMN_NAMES
A constant (used as the number of row headers) to indicate that the template should use the column names as row headers.

See Also:
Constant Field Values
Constructor Detail

TableReportTemplate

public TableReportTemplate()
Creates an instance of TableReportTemplate with a default name and 0 as the number of header and footer rows and columns.

See Also:
TableReportTemplate(String,int,int,int,int)

TableReportTemplate

public TableReportTemplate(java.lang.String name)
Creates an instance of TableReportTemplate with the specified name and 0 as the number of header and footer rows and columns.

Parameters:
name - localized string that this template should use as its name
See Also:
TableReportTemplate(String,int,int,int,int)

TableReportTemplate

public TableReportTemplate(java.lang.String name,
                           int numHeaderRows,
                           int numHeaderColumns,
                           int numFooterRows,
                           int numFooterColumns)
Creates an instance of TableReportTemplate that has the specified number of header and footer rows and columns.

Parameters:
name - localized string that this template should use as its name
numHeaderRows - number of rows to treat as header rows
numHeaderColumns - number of columns to treat as header columns
numFooterRows - number of rows to treat as footer rows
numFooterColumns - number of columns to treat as footer columns
Throws:
java.lang.IllegalArgumentException - if numHeaderRows < 0 && numHeaderRows != USE_COLUMN_NAMES; if numHeaderColumns < 0; if numFooterRows < 0; if numFooterColumns < 0;
Method Detail

createReport

public Report createReport(java.lang.Object content,
                           Theme theme)
                    throws java.lang.IllegalArgumentException
Description copied from interface: ReportTemplate
Creates a report with the specified content and theme.

Specified by:
createReport in interface ReportTemplate
Parameters:
content - content of the report to be generated
theme - theme of the report to be generated
Returns:
a non-null report with the specified content and based on the specified theme
Throws:
java.lang.IllegalArgumentException - if content is not appropriate (wrong class, e.g.) for the reports generated by this template

getName

public java.lang.String getName()
Description copied from interface: ReportTemplate
Returns a localized name of this report template.

Specified by:
getName in interface ReportTemplate
Returns:
this template's name

setColumnPrototypes

public void setColumnPrototypes(java.lang.Object[] prototypeColumnValues)
Sets the column prototype values.

Parameters:
prototypeColumnValues - typical values for each column (may be null)


Copyright 2003, 2004 Side of Software (SOS). All rights reserved.