org.ujac.util.table
Class BaseTable

java.lang.Object
  extended by org.ujac.util.table.BaseTable
All Implemented Interfaces:
Table, TableConstants, UjacTypes
Direct Known Subclasses:
DataTable, FilteredTable, ReportTable, ResultSetTable

public abstract class BaseTable
extends Object
implements Table

Name: BaseTable
Description: Basic table implementation.

Author:
lauerc

Field Summary
protected  Map columnMap
          The columns of the table.
protected  List columns
          The columns of the table.
 
Fields inherited from interface org.ujac.util.table.TableConstants
DEFAULT_DATE_FORMAT, DEFAULT_DOUBLE_FORMAT, DEFAULT_INTEGER_FORMAT, DEFAULT_TIME_FORMAT, DEFAULT_TIMESTAMP_FORMAT, ROW_TYPE_FOOTER, ROW_TYPE_GROUP, ROW_TYPE_GROUP_TITLE, ROW_TYPE_HEADER, ROW_TYPE_NORMAL
 
Fields inherited from interface org.ujac.util.UjacTypes
TYPE_BOOLEAN, TYPE_DATE, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INT, TYPE_LONG, TYPE_NAME_BOOLEAN, TYPE_NAME_DATE, TYPE_NAME_DOUBLE, TYPE_NAME_FLOAT, TYPE_NAME_INT, TYPE_NAME_LONG, TYPE_NAME_OBJECT, TYPE_NAME_SHORT, TYPE_NAME_STRING, TYPE_NAME_TABLE, TYPE_NAME_TIME, TYPE_NAME_TIMESTAMP, TYPE_OBJECT, TYPE_SHORT, TYPE_STRING, TYPE_TABLE, TYPE_TIME, TYPE_TIMESTAMP
 
Constructor Summary
BaseTable()
          Constructs a BaseTable instance with no specific arguments.
BaseTable(FormatHelper formatHelper)
          Constructs a BaseTable instance with no specific arguments.
 
Method Summary
 Column addColumn(String name, boolean key, int type)
          Adds a column to the table
 Column addColumn(String name, int type)
          Adds a column to the table
 Table copyTable()
          Copies the table.
 Column getColumn(int index)
          Gets the column at the given index.
 Column getColumn(String name)
          Gets the column with the given name.
 int getColumnCount()
          Gets the current number of columns.
 int getColumnIndex(String name)
          Gets the index of the given column name.
 Set getDistinctValues(int columnIdx)
          Gets the distinct values of the specified column.
 Set getDistinctValues(String columnName)
          Gets the distinct values of the specified column.
 FormatHelper getFormatHelper()
          Getter method for the the property formatHelper.
 TypeConverter getTypeConverter()
          Getter method for the the property typeConverter.
 Column[] getVisibleColumns()
          Gets all visible columns.
 Column[] getVisibleColumns(int levelFilter)
          Gets all visible columns.
 void orderColumns(String[] columnNames)
          Orders the sequence of report columns according to the list of given column names.
protected  void readData(ObjectInputStream s)
          Reads the object's data from the given stream.
 void renameColumn(Column column, String name)
          Renames a column.
 void setFormatHelper(FormatHelper formatHelper)
          Setter method for the the property formatHelper.
 void setTypeConverter(TypeConverter typeConverter)
          Setter method for the the property typeConverter.
protected  void writeData(ObjectOutputStream s)
          Writes the object's data to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.ujac.util.table.Table
addBoolean, addColumn, addDate, addDouble, addFloat, addInt, addLong, addRow, addRow, addString, addTime, addTimestamp, getBoolean, getBoolean, getDate, getDate, getDouble, getDouble, getFloat, getFloat, getHeaderRow, getInt, getInt, getLong, getLong, getObject, getObject, getRow, getRowCount, getString, getString, getTime, getTime, getTimestamp, getTimestamp, isEmpty, iterator, removeRow, setBoolean, setBoolean, setColumnType, setColumnType, setDate, setDate, setDouble, setDouble, setFloat, setFloat, setInt, setInt, setLong, setLong, setObject, setObject, setString, setString, setTime, setTime, setTimestamp, setTimestamp, sort, sort
 

Field Detail

columns

protected List columns
The columns of the table.


columnMap

protected Map columnMap
The columns of the table.

Constructor Detail

BaseTable

public BaseTable()
Constructs a BaseTable instance with no specific arguments.


BaseTable

public BaseTable(FormatHelper formatHelper)
Constructs a BaseTable instance with no specific arguments.

Parameters:
formatHelper - The format helper to use.
Method Detail

getFormatHelper

public FormatHelper getFormatHelper()
Getter method for the the property formatHelper.

Specified by:
getFormatHelper in interface Table
Returns:
The current value of property formatHelper.

setFormatHelper

public void setFormatHelper(FormatHelper formatHelper)
Setter method for the the property formatHelper.

Specified by:
setFormatHelper in interface Table
Parameters:
formatHelper - The value to set for the property formatHelper.

getTypeConverter

public TypeConverter getTypeConverter()
Getter method for the the property typeConverter.

Specified by:
getTypeConverter in interface Table
Returns:
The current value of property typeConverter.

setTypeConverter

public void setTypeConverter(TypeConverter typeConverter)
Setter method for the the property typeConverter.

Specified by:
setTypeConverter in interface Table
Parameters:
typeConverter - The value to set for the property typeConverter.

getColumnCount

public int getColumnCount()
Gets the current number of columns.

Specified by:
getColumnCount in interface Table
Returns:
The number of columns.

addColumn

public Column addColumn(String name,
                        int type)
                 throws ColumnAlreadyDefinedException,
                        OperationNotSupportedException
Adds a column to the table

Specified by:
addColumn in interface Table
Parameters:
name - The column name.
type - The column type.
Returns:
The new column.
Throws:
ColumnAlreadyDefinedException - In case the column was already defined.
OperationNotSupportedException - In case the operation is not supported.

addColumn

public Column addColumn(String name,
                        boolean key,
                        int type)
                 throws ColumnAlreadyDefinedException
Adds a column to the table

Parameters:
name - The column name.
key - Tells whether or not the column defines a key value.
type - The column type.
Returns:
The new column.
Throws:
ColumnAlreadyDefinedException - In case the column was already defined.

getColumn

public Column getColumn(int index)
                 throws ColumnNotDefinedException
Gets the column at the given index.

Specified by:
getColumn in interface Table
Parameters:
index - The column index.
Returns:
The desired column.
Throws:
ColumnNotDefinedException - If the column does not exist.

getColumn

public Column getColumn(String name)
                 throws ColumnNotDefinedException
Gets the column with the given name.

Specified by:
getColumn in interface Table
Parameters:
name - The column name.
Returns:
The desired column.
Throws:
ColumnNotDefinedException - If the column does not exist.

getColumnIndex

public int getColumnIndex(String name)
                   throws ColumnNotDefinedException
Gets the index of the given column name.

Specified by:
getColumnIndex in interface Table
Parameters:
name - The column name
Returns:
int The index of the column.
Throws:
ColumnNotDefinedException - If the column does not exist.

renameColumn

public void renameColumn(Column column,
                         String name)
                  throws ColumnAlreadyDefinedException
Renames a column.

Specified by:
renameColumn in interface Table
Parameters:
column - The column to rename.
name - The column name to set.
Throws:
ColumnAlreadyDefinedException - In case a column with that name already exists.

orderColumns

public void orderColumns(String[] columnNames)
                  throws ColumnNotDefinedException,
                         ColumnAlreadyDefinedException
Orders the sequence of report columns according to the list of given column names.

Specified by:
orderColumns in interface Table
Parameters:
columnNames - The list of column names after which to order the columns.
Throws:
ColumnNotDefinedException - In case a column from the given order list does not exist.
ColumnAlreadyDefinedException - In case a column was defined more than once at the given order list.

getVisibleColumns

public Column[] getVisibleColumns()
Gets all visible columns.

Specified by:
getVisibleColumns in interface Table
Returns:
An array holding all visible columns.

getVisibleColumns

public Column[] getVisibleColumns(int levelFilter)
Gets all visible columns.

Specified by:
getVisibleColumns in interface Table
Parameters:
levelFilter - The maximum level of importance to support.
Returns:
An array holding all visible columns.

copyTable

public Table copyTable()
                throws TableException
Copies the table.

Specified by:
copyTable in interface Table
Returns:
A copy holding the filtered contents of the handled table.
Throws:
TableException - In case an unexpected failure occurred.

getDistinctValues

public Set getDistinctValues(int columnIdx)
                      throws TableException
Gets the distinct values of the specified column.

Specified by:
getDistinctValues in interface Table
Parameters:
columnIdx - The index of the desired column.
Returns:
A set of distinct values.
Throws:
TableException - In case an unexpected failure occurred.

getDistinctValues

public Set getDistinctValues(String columnName)
                      throws TableException
Gets the distinct values of the specified column.

Specified by:
getDistinctValues in interface Table
Parameters:
columnName - The name of the desired column.
Returns:
A set of distinct values.
Throws:
TableException - In case an unexpected failure occurred.

writeData

protected void writeData(ObjectOutputStream s)
                  throws IOException
Writes the object's data to the given stream.

Parameters:
s - The stream to write to
Throws:
IOException - In case the data output failed.

readData

protected void readData(ObjectInputStream s)
                 throws IOException,
                        ClassNotFoundException
Reads the object's data from the given stream.

Parameters:
s - The stream to read from.
Throws:
IOException - In case the data reading failed.
ClassNotFoundException - In case the class to deserialize could not be found


Copyright © 2003-2004 UJAC.org. All Rights Reserved.