Class SortedTable

java.lang.Object
org.dbunit.dataset.AbstractTable
org.dbunit.dataset.SortedTable
All Implemented Interfaces:
ITable

public class SortedTable extends AbstractTable
This is a ITable decorator that provide a sorted view of the decorated table. This implementation does not keep a separate copy of the decorated table data.
Since:
Feb 19, 2003
Version:
$Revision$ $Date: 2009-05-01 02:56:07 -0500 (Fri, 01 May 2009) $
Author:
Manuel Laflamme, Last changed by: $Author$
  • Constructor Details

    • SortedTable

      public SortedTable(ITable table, Column[] columns) throws DataSetException
      Sort the decorated table by specified columns order. Resulting table uses column definitions from the specified table's metadata, not the specified columns.
      Parameters:
      table - decorated table
      columns - columns to be used for sorting
      Throws:
      DataSetException
    • SortedTable

      public SortedTable(ITable table, Column[] columns, boolean useSpecifiedColumns) throws DataSetException
      Sort the decorated table by specified columns order. Resulting table uses column definitions from the specified columns, not the ones from the specified table's metadata.
      Parameters:
      table - decorated table
      columns - columns to be used for sorting
      useSpecifiedColumns - true to use the column definitions specified by the columns parameter, false to use the column definitions from the specified table's metadata.
      Throws:
      DataSetException
    • SortedTable

      public SortedTable(ITable table, String[] columnNames) throws DataSetException
      Sort the decorated table by specified columns order. Resulting table uses column definitions from the specified table's metadata.
      Parameters:
      table - decorated table
      columnNames - names of columns to be used for sorting
      Throws:
      DataSetException
    • SortedTable

      public SortedTable(ITable table, ITableMetaData metaData) throws DataSetException
      Sort the decorated table by specified metadata columns order. All metadata columns will be used.
      Parameters:
      table - The decorated table
      metaData - The metadata used to retrieve all columns which in turn are used for sorting the table
      Throws:
      DataSetException
    • SortedTable

      public SortedTable(ITable table) throws DataSetException
      Sort the decorated table by its own columns order which is defined by ITable.getTableMetaData(). All table columns will be used.
      Parameters:
      table - The decorated table
      Throws:
      DataSetException
  • Method Details

    • getSortColumns

      public Column[] getSortColumns()
      Returns:
      The columns that are used for sorting the table
    • setUseComparable

      public void setUseComparable(boolean useComparable)
      Whether or not the comparable interface should be used of the compared columns instead of the plain strings Default value is false for backwards compatibility Set whether or not to use the Comparable implementation of the corresponding column DataType for comparing values or not. Default value is false which means that the old string comparison is used.
      Parameters:
      useComparable -
      Since:
      2.3.0
    • setRowComparator

      public void setRowComparator(Comparator comparator)
      Sets the comparator to be used for sorting the table rows.
      Parameters:
      comparator - that sorts the table rows
      Since:
      2.4.2
    • getTableMetaData

      public ITableMetaData getTableMetaData()
      Description copied from interface: ITable
      Returns this table metadata.
    • getRowCount

      public int getRowCount()
      Description copied from interface: ITable
      Returns this table row count.
    • getValue

      public Object getValue(int row, String columnName) throws DataSetException
      Description copied from interface: ITable
      Returns this table value for the specified row and column.
      Parameters:
      row - The row index, starting with 0
      columnName - The name of the column
      Returns:
      The value
      Throws:
      DataSetException
    • toString

      public String toString()
      Overrides:
      toString in class Object