sos.reports
Class DefaultTableFormat

java.lang.Object
  |
  +--sos.reports.DefaultTableFormat
All Implemented Interfaces:
java.io.Serializable, TableFormat

public class DefaultTableFormat
extends java.lang.Object
implements TableFormat, java.io.Serializable

An implementation of TableFormat that allows clients to define attributes for the table, rows, columns, and cells, based on whether an element is in the header, body, or footer. Clients can use the setXxxAttributes methods to populate the table format with attributes. Multiple calls to the same method (with the same arguments) will replace the previously set attributes. Not all attributes must be set. If no attributes are set, then the table format behaves like an empty attribute set (see TableFormats.EMPTY_TABLE_FORMAT)

Attribute Resolution

The attribute set returned by getCellAttributes resolves attributes in the following order (suppose the cell spans rows r1-r2 and columns c1-c2):

  1. Check attributes set with a call to setCellAttributes(a,r1,c1,r2,c2)
  2. If the cell spans one column, check attributes set with a call to setColumnCellAttributes(a,c1,TYPE) where TYPE is HEADER if r2 is a header row, FOOTER if r1 is a footer row, or BODY otherwise
  3. If the cell spans one column, check attributes set with a call to setColumnCellAttributes(a,c1)
  4. If the cell spans one row, check attributes set with a call to setRowCellAttributes(a,r1,TYPE) where TYPE is HEADER if c2 is a header column, FOOTER if c1 is a footer column, or BODY otherwise
  5. If the cell spans one row, check attributes set with a call to setRowCellAttributes(a,r1)
  6. Check the attributes set with a call to setColumnCellAttributes(a,TYPE) where TYPE is HEADER if r2 is a header row, FOOTER if r1 is a footer row, or BODY otherwise
  7. Check the attributes set with a call to setRowCellAttributes(a,TYPE) where TYPE is HEADER if c2 is a header column, FOOTER if c1 is a footer column, or BODY otherwise
  8. Check the attributes set with a call to setCellAttributes(a)
The attribute set returned by getTierAttributes resolves attributes in the following order (suppose the tier is a row at index r):

  1. Check attributes set with a call to setRowAttributes(a,r)
  2. Check attributes set with a call to setRowAttributes(a,TYPE) where TYPE is HEADER if r is a header row, FOOTER if r is a footer row, or BODY otherwise
  3. Check the attributes set with a call to setTierAttributes(a)
The attribute set returned by getTableAttributes uses the attributes set in setTableAttributes(a).

Examples:

Here are some examples, where a is some attribute set:

  setCellAttributes( a, 13, 5 );           // specifies the attributes for the cell at row 13, column 5
  setColumnCellAttributes( a, 5 );         // specifies the attributes for all cells in column 5
  setColumnCellAttributes( a, 5, HEADER ); // specifies the attributes for all cells in the header portion of column 5
  setRowCellAttributes( a, HEADER );       // specifies the attributes for all cells fully in header rows
  setCellAttributes( a );                  // specifies the attributes for all cells
  setRowAttributes( a, 13 );               // specifies the attributes for Row 13
  setRowAttributes( a, BODY );             // specifies the attributes for all body rows
  setRowAttributes( a );                   // specifies the attributes for all rows
  setTierAttributes( a );                  // specifies the attributes for all rows and columns
  setTableAttributes( a );                 // specifies the table attributes
 

Since:
1.0
See Also:
TableFormats

Field Summary
static java.lang.Object BODY
          Constant that indicates a body tier (that is, a non-header and non-footer tier).
static java.lang.Object FOOTER
          Constant that indicates a footer tier.
static java.lang.Object HEADER
          Constant that indicates a header tier.
 
Constructor Summary
DefaultTableFormat()
          Creates an instance of DefaultTableFormat with no attributes defined.
 
Method Summary
 javax.swing.text.AttributeSet getCellAttributes(CellElement cellElement)
          Returns the attributes to use for the specified cell element.
 javax.swing.text.AttributeSet getTableAttributes(TableElement tableElement)
          Returns the attributes to use for the table element.
 javax.swing.text.AttributeSet getTierAttributes(TierElement tierElement)
          Returns the attributes to use for the specified tier element.
 void setCellAttributes(javax.swing.text.AttributeSet attributes, int row, int column)
          Sets the attributes for cells in the specified row and column.
 void setCellAttributes(javax.swing.text.AttributeSet attributes, int firstRow, int firstColumn, int lastRow, int lastColumn)
          Sets the attributes for cells spanning the specified region.
 void setColumnAttributes(javax.swing.text.AttributeSet attributes)
          Sets the attributes for all columns.
 void setColumnAttributes(javax.swing.text.AttributeSet attributes, int column)
          Sets the attributes for columns at the specified index.
 void setColumnAttributes(javax.swing.text.AttributeSet attributes, java.lang.Object tierPortion)
          Sets the attributes for header, body, or footer columns.
 void setColumnCellAttributes(javax.swing.text.AttributeSet attributes, int column)
          Sets the attributes for cells that fall in the specified column.
 void setColumnCellAttributes(javax.swing.text.AttributeSet attributes, int column, java.lang.Object tierPortion)
          Sets the attributes for cells that fall in the header, body, or footer portion of the specified column.
 void setColumnCellAttributes(javax.swing.text.AttributeSet attributes, java.lang.Object tierPortion)
          Sets the attributes for cells that fall in the header, body, or footer columns.
 void setRowAttributes(javax.swing.text.AttributeSet attributes)
          Sets the attributes for all rows.
 void setRowAttributes(javax.swing.text.AttributeSet attributes, int row)
          Sets the attributes for rows at the specified index.
 void setRowAttributes(javax.swing.text.AttributeSet attributes, java.lang.Object tierPortion)
          Sets the attributes for header, body, or footer rows.
 void setRowCellAttributes(javax.swing.text.AttributeSet attributes, int row)
          Sets the attributes for cells that fall in the specified row.
 void setRowCellAttributes(javax.swing.text.AttributeSet attributes, int row, java.lang.Object tierPortion)
          Sets the attributes for cells that fall in the header, body, or footer portion of the specified row.
 void setRowCellAttributes(javax.swing.text.AttributeSet attributes, java.lang.Object tierPortion)
          Sets the attributes for cells that fall in the header, body, or footer rows.
 void setTableAttributes(javax.swing.text.AttributeSet attributes)
          Sets the attributes for tables.
 void setTierAttributes(javax.swing.text.AttributeSet attributes)
          Sets the attributes for all rows and columns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HEADER

public static final java.lang.Object HEADER
Constant that indicates a header tier.

See Also:
BODY, FOOTER

BODY

public static final java.lang.Object BODY
Constant that indicates a body tier (that is, a non-header and non-footer tier).

See Also:
HEADER, FOOTER

FOOTER

public static final java.lang.Object FOOTER
Constant that indicates a footer tier.

See Also:
HEADER, BODY
Constructor Detail

DefaultTableFormat

public DefaultTableFormat()
Creates an instance of DefaultTableFormat with no attributes defined.

Method Detail

getCellAttributes

public javax.swing.text.AttributeSet getCellAttributes(CellElement cellElement)
Description copied from interface: TableFormat
Returns the attributes to use for the specified cell element.

Specified by:
getCellAttributes in interface TableFormat
Parameters:
cellElement - cell for which the attributes are desired
Returns:
a set of attributes for cellElement

getTableAttributes

public javax.swing.text.AttributeSet getTableAttributes(TableElement tableElement)
Description copied from interface: TableFormat
Returns the attributes to use for the table element.

Specified by:
getTableAttributes in interface TableFormat
Parameters:
tableElement - table for which the attributes are desired
Returns:
a set of attributes for tableElement

getTierAttributes

public javax.swing.text.AttributeSet getTierAttributes(TierElement tierElement)
Description copied from interface: TableFormat
Returns the attributes to use for the specified tier element.

Specified by:
getTierAttributes in interface TableFormat
Parameters:
tierElement - row or column for which the attributes are desired
Returns:
a set of attributes for tierElement

setCellAttributes

public void setCellAttributes(javax.swing.text.AttributeSet attributes,
                              int row,
                              int column)
Sets the attributes for cells in the specified row and column. This is a convenience method for

  setCellAttributes( attributes, row, column, row, column );
 

Parameters:
attributes - cell attributes to set
row - row of cell for which to set the attributes
column - column of cell for which to set the attributes
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setCellAttributes(AttributeSet,int,int,int,int)

setCellAttributes

public void setCellAttributes(javax.swing.text.AttributeSet attributes,
                              int firstRow,
                              int firstColumn,
                              int lastRow,
                              int lastColumn)
Sets the attributes for cells spanning the specified region. All previous attributes set for the same region are replaced. A negative index indicates the offset from the end of the table.

Parameters:
attributes - cell attributes to set
firstRow - first row of cell for which to set the attributes
firstColumn - first column of cell for which to set the attributes
lastRow - first row of cell for which to set the attributes
lastColumn - last column of cell for which to set the attributes
Throws:
java.lang.IllegalArgumentException - if lastRow < firstRow or lastColumn < firstColumn
java.lang.NullPointerException - if attributes is null
See Also:
setCellAttributes(AttributeSet,int,int)

setColumnAttributes

public void setColumnAttributes(javax.swing.text.AttributeSet attributes)
Sets the attributes for all columns.

Parameters:
attributes - column attributes to set
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setColumnAttributes(AttributeSet,int), setRowAttributes(AttributeSet), setTierAttributes(AttributeSet)

setColumnAttributes

public void setColumnAttributes(javax.swing.text.AttributeSet attributes,
                                int column)
Sets the attributes for columns at the specified index. A negative column index indicates an offset from the last column of the table.

Parameters:
attributes - column attributes to set
column - index of column for which to set the attributes
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setColumnAttributes(AttributeSet), setRowAttributes(AttributeSet,int)

setColumnAttributes

public void setColumnAttributes(javax.swing.text.AttributeSet attributes,
                                java.lang.Object tierPortion)
Sets the attributes for header, body, or footer columns.

Parameters:
attributes - column attributes to set
tierPortion - the type of column for which to set the attributes
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setRowAttributes(AttributeSet,Object), setColumnAttributes(AttributeSet,int), setColumnAttributes(AttributeSet)

setColumnCellAttributes

public void setColumnCellAttributes(javax.swing.text.AttributeSet attributes,
                                    int column)
Sets the attributes for cells that fall in the specified column. A negative column index indicates an offset from the last column of the table.

Parameters:
attributes - cell attributes to set
column - cells in this column will have these attributes
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setRowCellAttributes(javax.swing.text.AttributeSet, int)

setColumnCellAttributes

public void setColumnCellAttributes(javax.swing.text.AttributeSet attributes,
                                    java.lang.Object tierPortion)
Sets the attributes for cells that fall in the header, body, or footer columns.

Parameters:
attributes - column attributes to set
tierPortion - cells in this column portion will have these attributes
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setRowCellAttributes(AttributeSet,Object), setColumnCellAttributes(AttributeSet,int)

setColumnCellAttributes

public void setColumnCellAttributes(javax.swing.text.AttributeSet attributes,
                                    int column,
                                    java.lang.Object tierPortion)
Sets the attributes for cells that fall in the header, body, or footer portion of the specified column. A negative column index indicates an offset from the last column of the table.

Parameters:
attributes - cell attributes to set
column - cells in this column and portion will have these attributes
tierPortion - the applicable portion of the column
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setRowCellAttributes(AttributeSet,int,Object), setColumnCellAttributes(AttributeSet,int)

setRowAttributes

public void setRowAttributes(javax.swing.text.AttributeSet attributes)
Sets the attributes for all rows.

Parameters:
attributes - row attributes to set
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setRowAttributes(AttributeSet,int), setColumnAttributes(AttributeSet), setTierAttributes(AttributeSet)

setRowAttributes

public void setRowAttributes(javax.swing.text.AttributeSet attributes,
                             int row)
Sets the attributes for rows at the specified index.

A negative row index indicates an offset from the last row of the table.

Parameters:
attributes - row attributes to set
row - index of row for which to set the attributes
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setRowAttributes(AttributeSet), setColumnAttributes(AttributeSet,int)

setRowAttributes

public void setRowAttributes(javax.swing.text.AttributeSet attributes,
                             java.lang.Object tierPortion)
Sets the attributes for header, body, or footer rows.

Parameters:
attributes - row attributes to set
tierPortion - the type of row for which to set the attributes
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setColumnAttributes(AttributeSet,Object), setRowAttributes(AttributeSet,int), setRowAttributes(AttributeSet)

setRowCellAttributes

public void setRowCellAttributes(javax.swing.text.AttributeSet attributes,
                                 int row)
Sets the attributes for cells that fall in the specified row. A negative column index indicates an offset from the last column of the table.

Parameters:
attributes - cell attributes to set
row - cells in this row will have these attributes
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setColumnCellAttributes(javax.swing.text.AttributeSet, int)

setRowCellAttributes

public void setRowCellAttributes(javax.swing.text.AttributeSet attributes,
                                 java.lang.Object tierPortion)
Sets the attributes for cells that fall in the header, body, or footer rows.

Parameters:
attributes - row attributes to set
tierPortion - cells in this row portion will have these attributes
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setColumnCellAttributes(AttributeSet,Object), setRowCellAttributes(AttributeSet,int)

setRowCellAttributes

public void setRowCellAttributes(javax.swing.text.AttributeSet attributes,
                                 int row,
                                 java.lang.Object tierPortion)
Sets the attributes for cells that fall in the header, body, or footer portion of the specified row. A negative column index indicates an offset from the last column of the table.

Parameters:
attributes - cell attributes to set
row - cells in this row and portion will have these attributes
tierPortion - the applicable portion of the row
Throws:
java.lang.IllegalArgumentException - if tierPortion is not one of HEADER, BODY, or FOOTER
java.lang.NullPointerException - if attributes is null
See Also:
setColumnCellAttributes(AttributeSet,int,Object), setRowCellAttributes(AttributeSet,int)

setTableAttributes

public void setTableAttributes(javax.swing.text.AttributeSet attributes)
Sets the attributes for tables.

Parameters:
attributes - table attributes to set
Throws:
java.lang.NullPointerException - if attributes is null

setTierAttributes

public void setTierAttributes(javax.swing.text.AttributeSet attributes)
Sets the attributes for all rows and columns.

Parameters:
attributes - tier attributes to set
Throws:
java.lang.NullPointerException - if attributes is null
See Also:
setRowAttributes(AttributeSet), setColumnAttributes(AttributeSet)


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