org.dbunit.dataset
Class DefaultTable

java.lang.Object
  extended by org.dbunit.dataset.AbstractTable
      extended by org.dbunit.dataset.DefaultTable
All Implemented Interfaces:
ITable
Direct Known Subclasses:
CachedTable

public class DefaultTable
extends AbstractTable

Default table implementation backed by a simple java in-memory list.

Since:
Feb 17, 2002
Version:
$Revision: 771 $
Author:
Manuel Laflamme

Field Summary
 
Fields inherited from interface org.dbunit.dataset.ITable
NO_VALUE
 
Constructor Summary
DefaultTable(ITableMetaData metaData)
           
DefaultTable(ITableMetaData metaData, List list)
          Deprecated. Use public mutators to initialize table values instead
DefaultTable(String tableName)
          Creates a new empty table having the specified name.
DefaultTable(String tableName, Column[] columns)
          Creates a new empty table with specified metadata.
DefaultTable(String tableName, Column[] columns, List list)
          Deprecated. Use public mutators to initialize table values instead
 
Method Summary
 void addRow()
          Inserts a new empty row.
 void addRow(Object[] values)
          Inserts a new row initialized with specified array of values.
 void addTableRows(ITable table)
          Inserts all rows from the specified table.
 int getRowCount()
          Returns this table row count.
 ITableMetaData getTableMetaData()
          Returns this table metadata.
 Object getValue(int row, String column)
          Returns this table value for the specified row and column.
 Object setValue(int row, String column, Object value)
          Replaces the value at the specified position in this table with the specified value.
 String toString()
           
 
Methods inherited from class org.dbunit.dataset.AbstractTable
assertValidColumn, assertValidRowIndex, assertValidRowIndex, getColumnIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultTable

public DefaultTable(ITableMetaData metaData,
                    List list)
Deprecated. Use public mutators to initialize table values instead

Creates a new empty table with specified metadata and values.


DefaultTable

public DefaultTable(String tableName)
Creates a new empty table having the specified name.


DefaultTable

public DefaultTable(String tableName,
                    Column[] columns,
                    List list)
Deprecated. Use public mutators to initialize table values instead

Creates a new empty table with specified metadata and values.


DefaultTable

public DefaultTable(String tableName,
                    Column[] columns)
Creates a new empty table with specified metadata.


DefaultTable

public DefaultTable(ITableMetaData metaData)
Method Detail

addRow

public void addRow()
            throws DataSetException
Inserts a new empty row. You can add values with setValue(int, java.lang.String, java.lang.Object).

Throws:
DataSetException

addRow

public void addRow(Object[] values)
            throws DataSetException
Inserts a new row initialized with specified array of values.

Parameters:
values - The array of values. Each value correspond to the column at the same index from ITableMetaData.getColumns().
Throws:
DataSetException
See Also:
getTableMetaData()

addTableRows

public void addTableRows(ITable table)
                  throws DataSetException
Inserts all rows from the specified table.

Parameters:
table - The source table.
Throws:
DataSetException

setValue

public Object setValue(int row,
                       String column,
                       Object value)
                throws RowOutOfBoundsException,
                       NoSuchColumnException,
                       DataSetException
Replaces the value at the specified position in this table with the specified value.

Parameters:
row - The row index
column - The column name
value - The value to store at the specified location
Returns:
the value previously at the specified location
Throws:
RowOutOfBoundsException - if the row index is out of range
NoSuchColumnException - if the column does not exist
DataSetException - if an unexpected error occurs

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 column)
                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
column - The name of the column
Returns:
The value
Throws:
NoSuchColumnException - if specified column name do not exist in this table
RowOutOfBoundsException - if specified row is less than zero or equals or greater than getRowCount
DataSetException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002-2012. All Rights Reserved.