org.dbunit.dataset
Class DataSetUtils

java.lang.Object
  extended by org.dbunit.dataset.DataSetUtils

public class DataSetUtils
extends java.lang.Object

This class contains various methods for manipulating datasets.

Since:
Feb 19, 2002
Version:
$Revision: 675 $
Author:
Manuel Laflamme

Nested Class Summary
static class DataSetUtils.ColumnComparatorByName
           
 
Method Summary
static void assertEquals(IDataSet expectedDataSet, IDataSet actualDataSet)
          Deprecated. Use Assertion.assertEquals
static void assertEquals(ITable expectedTable, ITable actualTable)
          Deprecated. Use Assertion.assertEquals
static Column getColumn(java.lang.String columnName, Column[] columns)
          Search and returns the specified column from the specified column array.
static java.lang.String getEscapedName(java.lang.String name, java.lang.String escapePattern)
           
static java.lang.String getQualifiedName(java.lang.String prefix, java.lang.String name)
          Returns the specified name qualified with the specified prefix.
static java.lang.String getQualifiedName(java.lang.String prefix, java.lang.String name, java.lang.String escapePattern)
           
static java.lang.String[] getReverseTableNames(IDataSet dataSet)
          Returns the table names from the specified dataset in reverse order.
static java.lang.String getSqlValueString(java.lang.Object value, DataType dataType)
          Returns the specified value as a string to be use in an SQL Statement.
static ITable[] getTables(IDataSet dataSet)
          Returns the tables from the specified dataset.
static ITable[] getTables(ITableIterator iterator)
          Returns the tables from the specified iterator.
static ITable[] getTables(java.lang.String[] names, IDataSet dataSet)
          Search and returns the specified tables from the specified dataSet.
static Column[] mergeColumnsByName(Column[] referenceColumns, Column[] columnsToMerge)
           
static java.lang.String[] reverseStringArray(java.lang.String[] array)
          reverses a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

assertEquals

public static void assertEquals(IDataSet expectedDataSet,
                                IDataSet actualDataSet)
                         throws java.lang.Exception
Deprecated. Use Assertion.assertEquals

Asserts that the two specified dataset are equals. This method ignore the tables order.

Throws:
java.lang.Exception

assertEquals

public static void assertEquals(ITable expectedTable,
                                ITable actualTable)
                         throws java.lang.Exception
Deprecated. Use Assertion.assertEquals

Asserts that the two specified tables are equals. This method ignore the table names, the columns order, the columns data type and the primary keys.

Throws:
java.lang.Exception

getQualifiedName

public static java.lang.String getQualifiedName(java.lang.String prefix,
                                                java.lang.String name)
Returns the specified name qualified with the specified prefix. The name is not modified if the prefix is null or if the name is already qualified.

Example:
getQualifiedName(null, "NAME") returns "NAME". getQualifiedName("PREFIX", "NAME") returns "PREFIX.NAME" and getQualifiedName("PREFIX2", "PREFIX1.NAME") returns "PREFIX1.NAME".

Parameters:
prefix - the prefix
name - the name
Returns:
the qualified name

getQualifiedName

public static java.lang.String getQualifiedName(java.lang.String prefix,
                                                java.lang.String name,
                                                java.lang.String escapePattern)

getEscapedName

public static java.lang.String getEscapedName(java.lang.String name,
                                              java.lang.String escapePattern)

getSqlValueString

public static java.lang.String getSqlValueString(java.lang.Object value,
                                                 DataType dataType)
                                          throws TypeCastException
Returns the specified value as a string to be use in an SQL Statement. For example the string myValue is returned as 'myValue'.

Parameters:
value - the value
dataType - the value data type
Returns:
the SQL string value
Throws:
TypeCastException

getColumn

public static Column getColumn(java.lang.String columnName,
                               Column[] columns)
Search and returns the specified column from the specified column array.

Parameters:
columnName - the name of the column to search.
columns - the array of columns from which the column must be searched.
Returns:
the column or null if the column is not found

getTables

public static ITable[] getTables(java.lang.String[] names,
                                 IDataSet dataSet)
                          throws DataSetException
Search and returns the specified tables from the specified dataSet.

Parameters:
names - the names of the tables to search.
dataSet - the dataset from which the tables must be searched.
Returns:
the tables or an empty array if no tables are found.
Throws:
DataSetException

getTables

public static ITable[] getTables(IDataSet dataSet)
                          throws DataSetException
Returns the tables from the specified dataset.

Throws:
DataSetException

getTables

public static ITable[] getTables(ITableIterator iterator)
                          throws DataSetException
Returns the tables from the specified iterator.

Throws:
DataSetException

getReverseTableNames

public static java.lang.String[] getReverseTableNames(IDataSet dataSet)
                                               throws DataSetException
Returns the table names from the specified dataset in reverse order.

Throws:
DataSetException

reverseStringArray

public static java.lang.String[] reverseStringArray(java.lang.String[] array)
reverses a String array.

Parameters:
array -
Returns:
String[] - reversed array.

mergeColumnsByName

public static Column[] mergeColumnsByName(Column[] referenceColumns,
                                          Column[] columnsToMerge)


Copyright © 2002-2008. All Rights Reserved.