com.ibm.commerce.pa.widget.beans
Class TableDataBean

java.lang.Object
  |
  +--com.ibm.commerce.pa.beans.DynamicDataBeanImpl
        |
        +--com.ibm.commerce.pa.widget.beans.TableDataBean
All Implemented Interfaces:
CommandDataBean, DataBean, DynamicDataBean, InputDataBean, java.io.Serializable
Direct Known Subclasses:
CompareListDataBean, ProductCompareDataBean, SalesAssistantHistoryDataBean

public class TableDataBean
extends DynamicDataBeanImpl

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable columnNameCache
           
protected  java.lang.Boolean removeIrrelevant
           
protected  java.util.Vector table
           
 
Fields inherited from class com.ibm.commerce.pa.beans.DynamicDataBeanImpl
constraintList, COPYRIGHT, defaultWidget, errorCode, errorMessage, interfaceName, metaData, pageName, parent, parentName, requestProperties, scriptName
 
Fields inherited from interface com.ibm.commerce.beans.DataBean
emptyString
 
Constructor Summary
TableDataBean()
          TableDataBean constructor.
 
Method Summary
 void addColumn(ColumnDataBean ds)
          This method adds a column to the table as long as the table contains columns.
 void addRow(ListDataBean ds)
          This method adds a row to the table as long as the table contains rows.
 void copy(DynamicDataBean ds)
          Copies a databean into this databean.
 void createColumnNameCache()
          This method will create a cache of column names and their indexes.
 ColumnDataBean getColumn(java.lang.String columnName)
          This method will return a column given the name.
 ColumnDataBean getColumnAt(int columnIndex)
          This method will return the Nth column of a table.
 int getColumnCount()
          This method returns the number of columns in the table.
 int getColumnIndex(java.lang.String columnName)
          This method will return the index of a column given the name.
 ElementDataBean getElementAt(int rowIndex, int columnIndex)
          This method returns one ElementDataBean cell from the table.
 boolean getRemoveIrrelevant()
          If a column is empty it is considered irrelevant.
 ListDataBean getRowAt(int rowIndex)
          This method returns a single row from the table.
 int getRowCount()
          Retrieve the number of rows in the table.
 ListDataBean[] getRowElements()
          Retrieve the rows in the table.
protected  java.util.Vector getTable()
          This method gets the table with one call
 java.lang.String[] getTableHeaderPresentation()
          Each column has a display name associated with it to be used as column headings when the table is displayed.
 void insertColumn(ColumnDataBean ds, int index)
          This method inserts a column to the table as long as the table contains columns.
 void insertRow(ListDataBean ds, int index)
          This method inserts a row to the table as long as the table contains ListDataBeans.
 int removeIrrelevantColumns()
          This method will remove empty columns from the table.
 void setRemoveIrrelevant(java.lang.Boolean newValue)
          Set the flag indicating whether empty columns should be removed from the form.
protected  void setTable(java.util.Vector newValue)
          This method sets the table with one call
 
Methods inherited from class com.ibm.commerce.pa.beans.DynamicDataBeanImpl
addConstraint, getCommandInterfaceName, getConstraintList, getDefaultWidget, getErrorCode, getErrorMessage, getMetaData, getPageName, getParent, getParentName, getRequestProperties, getScriptName, setCommandInterfaceName, setConstraintList, setDefaultWidget, setErrorCode, setErrorMessage, setMetaData, setPageName, setParent, setParentName, setRequestProperties, setScriptName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnNameCache

protected java.util.Hashtable columnNameCache

removeIrrelevant

protected java.lang.Boolean removeIrrelevant

table

protected java.util.Vector table
Constructor Detail

TableDataBean

public TableDataBean()
TableDataBean constructor.
Method Detail

addColumn

public void addColumn(ColumnDataBean ds)
This method adds a column to the table as long as the table contains columns. If the table contains ListDataBeans it will convert the Column into rows by adding it to each row. If the table is empty it will always add the column.
Parameters:
ds - The column you want to add.

addRow

public void addRow(ListDataBean ds)
This method adds a row to the table as long as the table contains rows. If the table contains ColumnDataBeans it will convert the row by adding it to each column. If the table is empty it will always add the row.
Parameters:
ds - The row you want to add.

copy

public void copy(DynamicDataBean ds)
Copies a databean into this databean. The databean must be a TableDataBean.
Overrides:
copy in class DynamicDataBeanImpl
Parameters:
ds - The databean to copy.

createColumnNameCache

public void createColumnNameCache()
This method will create a cache of column names and their indexes.

getColumn

public ColumnDataBean getColumn(java.lang.String columnName)
This method will return a column given the name. The first time this is called, the names and indexes are cached so that subsequent calls are much faster.
Parameters:
columnName - The name of the column to be retrieved.
Returns:
The column with the supplied name, or null if not found.

getColumnAt

public ColumnDataBean getColumnAt(int columnIndex)
This method will return the Nth column of a table. If the table is row based, this method will convert the Nth member of each row into a ColumnDataBean.
Parameters:
columnIndex - The index of the column to retrieve.
Returns:
The column at index, columnIndex.

getColumnCount

public int getColumnCount()
This method returns the number of columns in the table.
Returns:
The number of columns in the table.

getColumnIndex

public int getColumnIndex(java.lang.String columnName)
This method will return the index of a column given the name. Since it is more efficient to iterate over a DataBean by index, this method will tell you the various indexes of column names so you don't have to incurr the expense of finding the column name each time.
Parameters:
columnName - The name of the column you want the index of.
Returns:
The index of the column or -1 if the column name wasn't found.

getElementAt

public ElementDataBean getElementAt(int rowIndex,
                                    int columnIndex)
This method returns one ElementDataBean cell from the table.
Parameters:
rowIndex - The row that the cell is in.
columnIndex - The column of the cell you want.
Returns:
The cell at rowIndex,columnIndex in the table.

getRemoveIrrelevant

public boolean getRemoveIrrelevant()
If a column is empty it is considered irrelevant. Retrieve the setting for whether empty columns should be removed from the table.
Returns:
true if empty columns should be removed; false otherwise.

getRowAt

public ListDataBean getRowAt(int rowIndex)
This method returns a single row from the table.
Parameters:
rowIndex - The index of the row starting at zero for the first row.
Returns:
The row at rowIndex.

getRowCount

public int getRowCount()
Retrieve the number of rows in the table.
Returns:
The number of rows.

getRowElements

public ListDataBean[] getRowElements()
Retrieve the rows in the table.
Returns:
The collection of rows in the table.

getTable

protected java.util.Vector getTable()
This method gets the table with one call
Returns:
java.util.Vector

getTableHeaderPresentation

public java.lang.String[] getTableHeaderPresentation()
Each column has a display name associated with it to be used as column headings when the table is displayed. This method returns those names.
Returns:
The display names for the columns in the table.

insertColumn

public void insertColumn(ColumnDataBean ds,
                         int index)
This method inserts a column to the table as long as the table contains columns. If the table is empty it will always add the column. This method is good for adding virtual columns in an already constructed TableDataBean
Parameters:
ds - The column you want to add.

insertRow

public void insertRow(ListDataBean ds,
                      int index)
This method inserts a row to the table as long as the table contains ListDataBeans. If the table is empty it will always add the column. This method is good for adding virtual columns in an already constructed TableDataBean
Parameters:
ds - The row you want to insert.

removeIrrelevantColumns

public int removeIrrelevantColumns()
This method will remove empty columns from the table.
Returns:
int The number of columns removed.

setRemoveIrrelevant

public void setRemoveIrrelevant(java.lang.Boolean newValue)
Set the flag indicating whether empty columns should be removed from the form.
Parameters:
newValue - true to remove empty columns; false otherwise.

setTable

protected void setTable(java.util.Vector newValue)
This method sets the table with one call
Parameters:
newValue - java.util.Vector