Package org.dbunit.dataset
Class SortedTable
java.lang.Object
org.dbunit.dataset.AbstractTable
org.dbunit.dataset.SortedTable
- All Implemented Interfaces:
ITable
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$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstract class for sorting the table rows of a given table in a specific orderprotected static classCompares the rows with each other in order to sort them in the correct order using the data type and the Comparable implementation the current column has.protected static classCompares the rows with each other in order to sort them in the correct order using the string value of both values for the comparison. -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSortedTable(ITable table) Sort the decorated table by its own columns order which is defined byITable.getTableMetaData().SortedTable(ITable table, String[] columnNames) Sort the decorated table by specified columns order.SortedTable(ITable table, Column[] columns) Sort the decorated table by specified columns order.SortedTable(ITable table, Column[] columns, boolean useSpecifiedColumns) Sort the decorated table by specified columns order.SortedTable(ITable table, ITableMetaData metaData) Sort the decorated table by specified metadata columns order. -
Method Summary
Modifier and TypeMethodDescriptionintReturns this table row count.Column[]Returns this table metadata.Returns this table value for the specified row and column.voidsetRowComparator(Comparator comparator) Sets the comparator to be used for sorting the table rows.voidsetUseComparable(boolean useComparable) Whether or not the comparable interface should be used of the compared columns instead of the plain strings Default value isfalsefor backwards compatibility Set whether or not to use the Comparable implementation of the corresponding column DataType for comparing values or not.toString()Methods inherited from class org.dbunit.dataset.AbstractTable
assertValidColumn, assertValidRowIndex, assertValidRowIndex, getColumnIndex
-
Constructor Details
-
SortedTable
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 tablecolumns- 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 tablecolumns- columns to be used for sortinguseSpecifiedColumns- 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
Sort the decorated table by specified columns order. Resulting table uses column definitions from the specified table's metadata.- Parameters:
table- decorated tablecolumnNames- names of columns to be used for sorting- Throws:
DataSetException
-
SortedTable
Sort the decorated table by specified metadata columns order. All metadata columns will be used.- Parameters:
table- The decorated tablemetaData- The metadata used to retrieve all columns which in turn are used for sorting the table- Throws:
DataSetException
-
SortedTable
Sort the decorated table by its own columns order which is defined byITable.getTableMetaData(). All table columns will be used.- Parameters:
table- The decorated table- Throws:
DataSetException
-
-
Method Details
-
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 isfalsefor backwards compatibility Set whether or not to use the Comparable implementation of the corresponding column DataType for comparing values or not. Default value isfalsewhich means that the old string comparison is used.- Parameters:
useComparable-- Since:
- 2.3.0
-
setRowComparator
Sets the comparator to be used for sorting the table rows.- Parameters:
comparator- that sorts the table rows- Since:
- 2.4.2
-
getTableMetaData
Description copied from interface:ITableReturns this table metadata. -
getRowCount
public int getRowCount()Description copied from interface:ITableReturns this table row count. -
getValue
Description copied from interface:ITableReturns this table value for the specified row and column.- Parameters:
row- The row index, starting with 0columnName- The name of the column- Returns:
- The value
- Throws:
DataSetException
-
toString
-