org.ujac.util.table
Class DataTable

java.lang.Object
  extended by org.ujac.util.table.BaseTable
      extended by org.ujac.util.table.DataTable
All Implemented Interfaces:
Serializable, Table, TableConstants, UjacTypes
Direct Known Subclasses:
BeanTable, PivotTable

public class DataTable
extends BaseTable
implements Serializable

Name: DataTable
Description: A class holding table data.

Author:
lauerc
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.ujac.util.table.BaseTable
columnMap, columns
 
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
DataTable()
          Constructs a DataTable instance with no specific arguments.
DataTable(FormatHelper formatHelper)
          Constructs a DataTable instance with no specific arguments.
 
Method Summary
 Table addBoolean(String name, boolean value)
          Adds a column of type boolean to the table and sets its initial value at the first row.
 Column addColumn(String name, int type)
          Adds a column to the table
 Column addColumn(String name, int type, LayoutHints layoutHints)
          Adds a column to the table
 Table addDate(String name, Date value)
          Adds a column of type Date to the table and sets its initial value at the first row.
 Table addDouble(String name, double value)
          Adds a column of type double to the table and sets its initial value at the first row.
 Table addFloat(String name, float value)
          Adds a column of type float to the table and sets its initial value at the first row.
 Table addInt(String name, int value)
          Adds a column of type int to the table and sets its initial value at the first row.
 Table addLong(String name, long value)
          Adds a column of type long to the table and sets its initial value at the first row.
 Row addRow()
          Adds a row to the table
 Row addRow(Row srcRow)
          Adds a row to the table
 Table addString(String name, String value)
          Adds a column of type String to the table and sets its initial value at the first row.
 Table addTime(String name, Date value)
          Adds a column of type Date to the table and sets its initial value at the first row.
 Table addTimestamp(String name, Date value)
          Adds a column of type Date to the table and sets its initial value at the first row.
 boolean getBoolean(int rowIdx, int columnIdx)
          Gets the boolean value from the given row.
 boolean getBoolean(int rowIdx, String columnName)
          Gets the boolean value from the given row.
 Date getDate(int rowIdx, int columnIdx)
          Gets the Date value from the given row.
 Date getDate(int rowIdx, String columnName)
          Gets the Date value from the given row.
 double getDouble(int rowIdx, int columnIdx)
          Gets the double value from the given row.
 double getDouble(int rowIdx, String columnName)
          Gets the double value from the given row.
 float getFloat(int rowIdx, int columnIdx)
          Gets the float value from the given row.
 float getFloat(int rowIdx, String columnName)
          Gets the float value from the given row.
 Row getHeaderRow()
          Gets the header row.
 int getInt(int rowIdx, int columnIdx)
          Gets the integer value from the given row.
 int getInt(int rowIdx, String columnName)
          Gets the integer value from the given row.
 long getLong(int rowIdx, int columnIdx)
          Gets the long value from the given row.
 long getLong(int rowIdx, String columnName)
          Gets the long value from the given row.
 Object getObject(int rowIdx, int columnIdx)
          Gets the Object value from the given row at the given column.
 Object getObject(int rowIdx, String columnName)
          Gets the Object value from the given row at the given column.
 Row getRow(int rowIdx)
          Gets a row from the table
 int getRowCount()
          Gets the current number of rows.
 String getString(int rowIdx, int columnIdx)
          Gets the String value from the given row at the given column.
 String getString(int rowIdx, String columnName)
          Gets the String value from the given row at the given column.
 Date getTime(int rowIdx, int columnIdx)
          Gets the Time value from the given row.
 Date getTime(int rowIdx, String columnName)
          Gets the Date value from the given row.
 Date getTimestamp(int rowIdx, int columnIdx)
          Gets the Timestamp value from the given row.
 Date getTimestamp(int rowIdx, String columnName)
          Gets the Timestamp value from the given row.
 boolean isEmpty()
          Checks if the table is empty.
 Iterator iterator()
          Returns an iterator over the rows in this table in proper sequence.
static void main(String[] args)
          The main method for testing purposes.
protected  void readData(ObjectInputStream s)
          Reads the object's data from the given stream.
 void removeRow(int rowIdx)
          Removes a row from the table
 void setBoolean(int rowIdx, int columnIdx, boolean value)
          Sets the boolean value at the given row.
 void setBoolean(int rowIdx, String columnName, boolean value)
          Sets the boolean value at the given row.
 void setColumnType(int columnIdx, int typeId)
          Changes the type of the given column.
 void setColumnType(String columnName, int typeId)
          Changes the type of the given column.
 void setDate(int rowIdx, int columnIdx, Date value)
          Sets the Date value at the given row.
 void setDate(int rowIdx, String columnName, Date value)
          Sets the Time value at the given row.
 void setDouble(int rowIdx, int columnIdx, double value)
          Sets the double value at the given row.
 void setDouble(int rowIdx, String columnName, double value)
          Sets the double value at the given row.
 void setFloat(int rowIdx, int columnIdx, float value)
          Sets the float value at the given row.
 void setFloat(int rowIdx, String columnName, float value)
          Sets the float value at the given row.
 void setInt(int rowIdx, int columnIdx, int value)
          Sets the integer value at the given row.
 void setInt(int rowIdx, String columnName, int value)
          Sets the integer value at the given row.
 void setLong(int rowIdx, int columnIdx, long value)
          Sets the long value at the given row.
 void setLong(int rowIdx, String columnName, long value)
          Sets the integer value at the given row.
 void setObject(int rowIdx, int columnIdx, Object value)
          Sets the Object value at the given row.
 void setObject(int rowIdx, String columnName, Object value)
          Sets the Object value at the given row.
 void setString(int rowIdx, int columnIdx, String value)
          Sets the String value at the given row.
 void setString(int rowIdx, String columnName, String value)
          Sets the String value at the given row.
 void setTime(int rowIdx, int columnIdx, Date value)
          Sets the Date value at the given row.
 void setTime(int rowIdx, String columnName, Date value)
          Sets the Time value at the given row.
 void setTimestamp(int rowIdx, int columnIdx, Date value)
          Sets the Timestamp value at the given row.
 void setTimestamp(int rowIdx, String columnName, Date value)
          Sets the Timestamp value at the given row.
 void sort(CompareItem[] compareColumns)
          Sorts the table according to the given compare item definitions.
 void sort(int columnIdx, int direction)
          Sorts the table according to the given column and direction.
 void swapRows(int a, int b)
          Swaps the rows with the given two indices.
 String toString()
          Converts the table to String.
protected  void writeData(ObjectOutputStream s)
          Writes the object's data to the given stream.
 
Methods inherited from class org.ujac.util.table.BaseTable
addColumn, copyTable, getColumn, getColumn, getColumnCount, getColumnIndex, getDistinctValues, getDistinctValues, getFormatHelper, getTypeConverter, getVisibleColumns, getVisibleColumns, orderColumns, renameColumn, setFormatHelper, setTypeConverter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataTable

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


DataTable

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

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

addColumn

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

Specified by:
addColumn in interface Table
Overrides:
addColumn in class BaseTable
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,
                        int type,
                        LayoutHints layoutHints)
                 throws ColumnAlreadyDefinedException,
                        OperationNotSupportedException
Adds a column to the table

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

addString

public Table addString(String name,
                       String value)
                throws TableException
Adds a column of type String to the table and sets its initial value at the first row.

Specified by:
addString in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addInt

public Table addInt(String name,
                    int value)
             throws TableException
Adds a column of type int to the table and sets its initial value at the first row.

Specified by:
addInt in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addLong

public Table addLong(String name,
                     long value)
              throws TableException
Adds a column of type long to the table and sets its initial value at the first row.

Specified by:
addLong in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addFloat

public Table addFloat(String name,
                      float value)
               throws TableException
Adds a column of type float to the table and sets its initial value at the first row.

Specified by:
addFloat in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addDouble

public Table addDouble(String name,
                       double value)
                throws TableException
Adds a column of type double to the table and sets its initial value at the first row.

Specified by:
addDouble in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addBoolean

public Table addBoolean(String name,
                        boolean value)
                 throws TableException
Adds a column of type boolean to the table and sets its initial value at the first row.

Specified by:
addBoolean in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addDate

public Table addDate(String name,
                     Date value)
              throws TableException
Adds a column of type Date to the table and sets its initial value at the first row.

Specified by:
addDate in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addTime

public Table addTime(String name,
                     Date value)
              throws TableException
Adds a column of type Date to the table and sets its initial value at the first row.

Specified by:
addTime in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

addTimestamp

public Table addTimestamp(String name,
                          Date value)
                   throws TableException
Adds a column of type Date to the table and sets its initial value at the first row.

Specified by:
addTimestamp in interface Table
Parameters:
name - The column name.
value - The initial value at the first row.
Returns:
A reference to this table.
Throws:
TableException - If an error occured.

isEmpty

public boolean isEmpty()
Checks if the table is empty.

Specified by:
isEmpty in interface Table
Returns:
true if the table has no rows, else false.

getRowCount

public int getRowCount()
Gets the current number of rows.

Specified by:
getRowCount in interface Table
Returns:
The number of rows.

addRow

public Row addRow()
Adds a row to the table

Specified by:
addRow in interface Table
Returns:
The new row.

addRow

public Row addRow(Row srcRow)
           throws OperationNotSupportedException
Adds a row to the table

Specified by:
addRow in interface Table
Parameters:
srcRow - The row to copy.
Returns:
The new row.
Throws:
OperationNotSupportedException - In case the operation is not supported.

getRow

public Row getRow(int rowIdx)
           throws RowNotDefinedException
Gets a row from the table

Specified by:
getRow in interface Table
Parameters:
rowIdx - The index of the desired row.
Returns:
The new row.
Throws:
RowNotDefinedException - In case the requested row does not exist.

removeRow

public void removeRow(int rowIdx)
               throws RowNotDefinedException
Removes a row from the table

Specified by:
removeRow in interface Table
Parameters:
rowIdx - The index of the row to remove.
Throws:
RowNotDefinedException - In case the requested row does not exist.

getHeaderRow

public Row getHeaderRow()
Gets the header row.

Specified by:
getHeaderRow in interface Table
Returns:
The header row for the table.

iterator

public Iterator iterator()
Returns an iterator over the rows in this table in proper sequence.

Specified by:
iterator in interface Table
Returns:
an iterator over the rows in this table in proper sequence.

getString

public String getString(int rowIdx,
                        int columnIdx)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException,
                        TypeMismatchException
Gets the String value from the given row at the given column.

Specified by:
getString in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the String conversion failed.

getString

public String getString(int rowIdx,
                        String columnName)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException,
                        TypeMismatchException
Gets the String value from the given row at the given column.

Specified by:
getString in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the String conversion failed.

setString

public void setString(int rowIdx,
                      int columnIdx,
                      String value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the String value at the given row.

Specified by:
setString in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the String conversion failed.

setString

public void setString(int rowIdx,
                      String columnName,
                      String value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the String value at the given row.

Specified by:
setString in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the String conversion failed.

getInt

public int getInt(int rowIdx,
                  int columnIdx)
           throws RowNotDefinedException,
                  ColumnNotDefinedException,
                  TypeMismatchException
Gets the integer value from the given row.

Specified by:
getInt in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the int conversion failed.

getInt

public int getInt(int rowIdx,
                  String columnName)
           throws RowNotDefinedException,
                  ColumnNotDefinedException,
                  TypeMismatchException
Gets the integer value from the given row.

Specified by:
getInt in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the int conversion failed.

setInt

public void setInt(int rowIdx,
                   int columnIdx,
                   int value)
            throws RowNotDefinedException,
                   ColumnNotDefinedException,
                   TypeMismatchException
Sets the integer value at the given row.

Specified by:
setInt in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the int conversion failed.

setInt

public void setInt(int rowIdx,
                   String columnName,
                   int value)
            throws RowNotDefinedException,
                   ColumnNotDefinedException,
                   TypeMismatchException
Sets the integer value at the given row.

Specified by:
setInt in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the int conversion failed.

getLong

public long getLong(int rowIdx,
                    int columnIdx)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the long value from the given row.

Specified by:
getLong in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the long conversion failed.

getLong

public long getLong(int rowIdx,
                    String columnName)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the long value from the given row.

Specified by:
getLong in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the long conversion failed.

setLong

public void setLong(int rowIdx,
                    int columnIdx,
                    long value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the long value at the given row.

Specified by:
setLong in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the long conversion failed.

setLong

public void setLong(int rowIdx,
                    String columnName,
                    long value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the integer value at the given row.

Specified by:
setLong in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the long conversion failed.

getFloat

public float getFloat(int rowIdx,
                      int columnIdx)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Gets the float value from the given row.

Specified by:
getFloat in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the float conversion failed.

getFloat

public float getFloat(int rowIdx,
                      String columnName)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Gets the float value from the given row.

Specified by:
getFloat in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the float conversion failed.

setFloat

public void setFloat(int rowIdx,
                     int columnIdx,
                     float value)
              throws RowNotDefinedException,
                     ColumnNotDefinedException,
                     TypeMismatchException
Sets the float value at the given row.

Specified by:
setFloat in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the float conversion failed.

setFloat

public void setFloat(int rowIdx,
                     String columnName,
                     float value)
              throws RowNotDefinedException,
                     ColumnNotDefinedException,
                     TypeMismatchException
Sets the float value at the given row.

Specified by:
setFloat in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the float conversion failed.

getDouble

public double getDouble(int rowIdx,
                        int columnIdx)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException,
                        TypeMismatchException
Gets the double value from the given row.

Specified by:
getDouble in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the double conversion failed.

getDouble

public double getDouble(int rowIdx,
                        String columnName)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException,
                        TypeMismatchException
Gets the double value from the given row.

Specified by:
getDouble in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the double conversion failed.

setDouble

public void setDouble(int rowIdx,
                      int columnIdx,
                      double value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the double value at the given row.

Specified by:
setDouble in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the double conversion failed.

setDouble

public void setDouble(int rowIdx,
                      String columnName,
                      double value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the double value at the given row.

Specified by:
setDouble in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the double conversion failed.

getBoolean

public boolean getBoolean(int rowIdx,
                          int columnIdx)
                   throws RowNotDefinedException,
                          ColumnNotDefinedException,
                          TypeMismatchException
Gets the boolean value from the given row.

Specified by:
getBoolean in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the boolean conversion failed.

getBoolean

public boolean getBoolean(int rowIdx,
                          String columnName)
                   throws RowNotDefinedException,
                          ColumnNotDefinedException,
                          TypeMismatchException
Gets the boolean value from the given row.

Specified by:
getBoolean in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the boolean conversion failed.

setBoolean

public void setBoolean(int rowIdx,
                       int columnIdx,
                       boolean value)
                throws RowNotDefinedException,
                       ColumnNotDefinedException,
                       TypeMismatchException
Sets the boolean value at the given row.

Specified by:
setBoolean in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the boolean conversion failed.

setBoolean

public void setBoolean(int rowIdx,
                       String columnName,
                       boolean value)
                throws RowNotDefinedException,
                       ColumnNotDefinedException,
                       TypeMismatchException
Sets the boolean value at the given row.

Specified by:
setBoolean in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the boolean conversion failed.

getDate

public Date getDate(int rowIdx,
                    int columnIdx)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the Date value from the given row.

Specified by:
getDate in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the date conversion failed.

getDate

public Date getDate(int rowIdx,
                    String columnName)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the Date value from the given row.

Specified by:
getDate in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the date conversion failed.

setDate

public void setDate(int rowIdx,
                    int columnIdx,
                    Date value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the Date value at the given row.

Specified by:
setDate in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the date conversion failed.

setDate

public void setDate(int rowIdx,
                    String columnName,
                    Date value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the Time value at the given row.

Specified by:
setDate in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the date conversion failed.

getTime

public Date getTime(int rowIdx,
                    int columnIdx)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the Time value from the given row.

Specified by:
getTime in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the date conversion failed.

getTime

public Date getTime(int rowIdx,
                    String columnName)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Gets the Date value from the given row.

Specified by:
getTime in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the time conversion failed.

setTime

public void setTime(int rowIdx,
                    int columnIdx,
                    Date value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the Date value at the given row.

Specified by:
setTime in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the time conversion failed.

setTime

public void setTime(int rowIdx,
                    String columnName,
                    Date value)
             throws RowNotDefinedException,
                    ColumnNotDefinedException,
                    TypeMismatchException
Sets the Time value at the given row.

Specified by:
setTime in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the time conversion failed.

getTimestamp

public Date getTimestamp(int rowIdx,
                         int columnIdx)
                  throws RowNotDefinedException,
                         ColumnNotDefinedException,
                         TypeMismatchException
Gets the Timestamp value from the given row.

Specified by:
getTimestamp in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the timestamp conversion failed.

getTimestamp

public Date getTimestamp(int rowIdx,
                         String columnName)
                  throws RowNotDefinedException,
                         ColumnNotDefinedException,
                         TypeMismatchException
Gets the Timestamp value from the given row.

Specified by:
getTimestamp in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the timestamp conversion failed.

setTimestamp

public void setTimestamp(int rowIdx,
                         int columnIdx,
                         Date value)
                  throws RowNotDefinedException,
                         ColumnNotDefinedException,
                         TypeMismatchException
Sets the Timestamp value at the given row.

Specified by:
setTimestamp in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the timestamp conversion failed.

setTimestamp

public void setTimestamp(int rowIdx,
                         String columnName,
                         Date value)
                  throws RowNotDefinedException,
                         ColumnNotDefinedException,
                         TypeMismatchException
Sets the Timestamp value at the given row.

Specified by:
setTimestamp in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the timestamp conversion failed.

getObject

public Object getObject(int rowIdx,
                        int columnIdx)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException
Gets the Object value from the given row at the given column.

Specified by:
getObject in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.

getObject

public Object getObject(int rowIdx,
                        String columnName)
                 throws RowNotDefinedException,
                        ColumnNotDefinedException
Gets the Object value from the given row at the given column.

Specified by:
getObject in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The index of the desired column.
Returns:
The detected value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.

setObject

public void setObject(int rowIdx,
                      int columnIdx,
                      Object value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the Object value at the given row.

Specified by:
setObject in interface Table
Parameters:
rowIdx - The index of the desired row.
columnIdx - The index of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the object conversion failed.

setObject

public void setObject(int rowIdx,
                      String columnName,
                      Object value)
               throws RowNotDefinedException,
                      ColumnNotDefinedException,
                      TypeMismatchException
Sets the Object value at the given row.

Specified by:
setObject in interface Table
Parameters:
rowIdx - The index of the desired row.
columnName - The name of the desired column.
value - The new value.
Throws:
RowNotDefinedException - In case the requested row does not exist.
ColumnNotDefinedException - In case the requested column does not exist.
TypeMismatchException - In case the object conversion failed.

sort

public void sort(CompareItem[] compareColumns)
Sorts the table according to the given compare item definitions.

Specified by:
sort in interface Table
Parameters:
compareColumns - The column definition for the sort process.

sort

public void sort(int columnIdx,
                 int direction)
Sorts the table according to the given column and direction.

Specified by:
sort in interface Table
Parameters:
columnIdx - The column to sort by.
direction - The sort directon.

swapRows

public void swapRows(int a,
                     int b)
Swaps the rows with the given two indices.

Parameters:
a - The index of the first row.
b - The index of the second row.

setColumnType

public void setColumnType(int columnIdx,
                          int typeId)
                   throws ColumnNotDefinedException,
                          TypeConverterException
Changes the type of the given column.

Specified by:
setColumnType in interface Table
Parameters:
columnIdx - The index of the column which has been changed.
typeId - The new column type ID.
Throws:
ColumnNotDefinedException - In case the desired column does not exist.
TypeConverterException - In case the object conversion failed.

setColumnType

public void setColumnType(String columnName,
                          int typeId)
                   throws ColumnNotDefinedException,
                          TypeConverterException
Changes the type of the given column.

Specified by:
setColumnType in interface Table
Parameters:
columnName - The name of the column which has been changed.
typeId - The new column type ID.
Throws:
ColumnNotDefinedException - In case the desired column does not exist.
TypeConverterException - In case the object conversion failed.

toString

public String toString()
Converts the table to String.

Overrides:
toString in class Object
Returns:
the textual representation of the table.

main

public static final void main(String[] args)
The main method for testing purposes.

Parameters:
args - The command line arguments.

writeData

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

Overrides:
writeData in class BaseTable
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.

Overrides:
readData in class BaseTable
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.