public final class JDBDT extends Object
This utility class defines the front-end API for database assertions, setup operations, and creation of associated class instances.
Modifier and Type | Method and Description |
---|---|
static void |
assertDeleted(DataSet... dataSets)
Assert that database changed by removal of given data sets.
|
static void |
assertDeleted(DataSet dataSet)
Assert that database changed by removal of given
data set.
|
static void |
assertDeleted(String message,
DataSet... dataSets)
Assert that database changed by removal of given
data sets (error message variant).
|
static void |
assertDeleted(String message,
DataSet dataSet)
Assert that database changed only by removal of a given
data set (error message variant).
|
static void |
assertDelta(DataSet oldData,
DataSet newData)
Assert database delta expressed by 'old' and 'new' data sets.
|
static void |
assertDelta(String message,
DataSet oldData,
DataSet newData)
Assert database delta expressed by 'old' and 'new' data sets (error message variant).
|
static void |
assertEmpty(DataSource... dataSources)
Assert that the given data sources have no rows.
|
static void |
assertEmpty(DataSource dataSource)
Assert that the given data source has no rows.
|
static void |
assertEmpty(String message,
DataSource... dataSources)
Assert that the given data sources have no rows (error message variant).
|
static void |
assertEmpty(String message,
DataSource dataSource)
Assert that the given data source has no rows (error message variant).
|
static void |
assertEquals(DataSet expected,
DataSet actual)
Assert that two data sets are equivalent.
|
static void |
assertEquals(String message,
DataSet expected,
DataSet actual)
Assert that two data sets are equivalent (error message variant).
|
static void |
assertInserted(DataSet... dataSets)
Assert that database changed only by addition of given data sets.
|
static void |
assertInserted(DataSet dataSet)
Assert that database changed only by insertion of a given data set.
|
static void |
assertInserted(String message,
DataSet... dataSets)
Assert that database changed only by insertion of given
data sets (error message variant).
|
static void |
assertInserted(String message,
DataSet dataSet)
Assert that database changed only by insertion of a given
data set (error message variant).
|
static void |
assertState(DataSet... dataSets)
Assert that the database state matches the given data sets.
|
static void |
assertState(DataSet dataSet)
Assert that the database state matches the given data set.
|
static void |
assertState(String message,
DataSet... dataSets)
Assert that the database state matches the given data sets (error message variant)
|
static void |
assertState(String message,
DataSet dataSet)
Assert that the database state matches the given data set (error message variant).
|
static void |
assertTableDoesNotExist(DB db,
String... tableNames)
Assert that tables do not exist in a database.
|
static void |
assertTableDoesNotExist(DB db,
String tableName)
Assert that table does not exist in a database.
|
static void |
assertTableDoesNotExist(String message,
DB db,
String... tableNames)
Assert that tables do not exist in a database (error message variant).
|
static void |
assertTableDoesNotExist(String message,
DB db,
String tableName)
Assert that table does not exist in a database (error message variant).
|
static void |
assertTableExists(DB db,
String... tableNames)
Assert that tables exist in the database.
|
static void |
assertTableExists(DB db,
String tableName)
Assert that table exists in the database.
|
static void |
assertTableExists(String message,
DB db,
String... tableNames)
Assert that tables exist in the database (error message variant).
|
static void |
assertTableExists(String message,
DB db,
String tableName)
Assert that table exists in the database (error message variant).
|
static void |
assertUnchanged(DataSource... dataSources)
Assert that no changes occurred for the given data sources.
|
static void |
assertUnchanged(DataSource dataSource)
Assert that no changes occurred for the given data source.
|
static void |
assertUnchanged(String message,
DataSource... dataSources)
Assert that no changes occurred for the given data sources
(error message variant).
|
static void |
assertUnchanged(String message,
DataSource dataSource)
Assert that no changes occurred for the given data source
(error message variant).
|
static DataSetBuilder |
builder(DataSource dataSource)
Create a builder for a fresh data set.
|
static boolean |
changed(DataSource... dataSources)
Check if given data sources are seen as changed.
|
static boolean |
changed(DataSource dataSource)
Check if given data source is seen as changed.
|
static void |
commit(DB db)
Commit changes in current transaction.
|
static DataSet |
data(DataSource dataSource)
Create a new data set.
|
static <T> TypedDataSet<T> |
data(DataSource dataSource,
Conversion<T> conv)
Create a new typed data set.
|
static DB |
database(Connection c)
Create a new database handle.
|
static DB |
database(DataSource xds)
Create a new database handle for given
DataSource
instance. |
static DB |
database(DataSource xds,
String user,
String password)
Create a new database handle for given
DataSource
instance, user, and password. |
static DB |
database(String url)
Create a new database handle for given database URL.
|
static DB |
database(String url,
String user,
String password)
Create a new database handle for given database
URL, user and password .
|
static void |
delete(DataSet... dataSets)
Delete data sets from the database.
|
static void |
delete(DataSet data)
Delete data set from the database.
|
static void |
deleteAll(Table... tables)
Delete all data from given tables.
|
static int |
deleteAll(Table table)
Delete all data from a table.
|
static int |
deleteAllWhere(Table table,
String where,
Object... args)
Delete all data from a table, subject to a
WHERE
clause. |
static void |
drop(DB db,
String... tableNames)
Drop tables.
|
static void |
drop(DB db,
String tableName)
Drop a table (table name variant).
|
static void |
drop(Table... tables)
Drop tables (table handle variant).
|
static void |
drop(Table table)
Drop a table (table handle variant).
|
static void |
dump(DataSet data,
File outputFile)
Dump the contents of a data set (output file variant).
|
static void |
dump(DataSet data,
PrintStream out)
Dump the contents of a data set.
|
static void |
dump(DataSource dataSource,
File outputFile)
Dump the database contents for a data source (file variant).
|
static void |
dump(DataSource dataSource,
PrintStream out)
Dump the database contents for a data source.
|
static DataSet |
empty(DataSource dataSource)
Get empty data set constant for given data source.
|
static int |
execute(DB db,
String sql,
Object... args)
Execute arbitrary SQL for a database instance.
|
static void |
insert(DataSet... dataSets)
Insert data sets into the database.
|
static void |
insert(DataSet data)
Insert a data set into the database.
|
static void |
populate(DataSet... dataSets)
Populate database with given data sets.
|
static void |
populate(DataSet data)
Populate database with given data set.
|
static void |
populateIfChanged(DataSet... dataSets)
Populate database with given data sets if the associated
tables are seen as changed.
|
static void |
populateIfChanged(DataSet data)
Populate database with given data set if the associated
table is seen as changed.
|
static Query |
query(DB db,
String sql,
Object... args)
Create a query data source from given SQL code.
|
static DataSet |
read(DataSource source,
CSV.Format format,
File file)
Read data set from CSV file.
|
static void |
restore(DB db)
Restore database state to the last JDBDT save-point.
|
static void |
save(DB db)
Set JDBDT save-point for database.
|
static QueryBuilder |
select(String... columns)
Create a query builder.
|
static TableBuilder |
table(String tableName)
Create a table builder.
|
static void |
takeSnapshot(DataSource... dataSources)
Take a database snapshot for several data sources.
|
static DataSet |
takeSnapshot(DataSource dataSource)
Take a database snapshot.
|
static void |
teardown(DB db,
boolean closeConn)
Tear-down a database handle.
|
static void |
truncate(Table... tables)
Truncate tables.
|
static void |
truncate(Table table)
Truncate table.
|
static void |
update(DataSet... dataSets)
Update database according to given data sets.
|
static void |
update(DataSet data)
Update database according to given data set.
|
static String |
version()
Get JDBDT version identifier.
|
static void |
write(DataSet dataSet,
CSV.Format format,
File file)
Write data set to CSV file.
|
public static String version()
public static DB database(Connection c)
The given connection is associated to the handle.
A reference to the connection can later be retrieved
using DB.getConnection()
.
c
- Connection.public static DB database(String url) throws SQLException
Calling this method is shorthand for:
database( DriverManager.getConnection(url) )
.
url
- Database URL.SQLException
- If the connection cannot be created.database(Connection)
,
DriverManager.getConnection(String)
public static DB database(String url, String user, String password) throws SQLException
Calling this method is shorthand for:
database( DriverManager.getConnection(url, user, password) )
.
url
- Database URL.user
- Database user.password
- Database password.SQLException
- If the connection cannot be created.database(Connection)
,
DriverManager.getConnection(String, String, String)
public static DB database(DataSource xds) throws SQLException
DataSource
instance.
Calling this method is shorthand for:
database( xds.getConnection() )
.
xds
- DataSource
instance.SQLException
- If the connection cannot be created.database(Connection)
,
DataSource.getConnection()
public static DB database(DataSource xds, String user, String password) throws SQLException
DataSource
instance, user, and password.
Calling this method is shorthand for:
database( xds.getConnection(user, password) )
.
xds
- DataSource
instance.user
- Database user.password
- Database password.SQLException
- If the connection cannot be created.database(Connection)
,
DataSource.getConnection(String, String)
public static void teardown(DB db, boolean closeConn)
Calling this method releases any associated resources to the given database handle. The database handle should not be used after a call to this method is made.
The freed-up resources include any save points, prepared statements, and opened log files. The second parameter specifies if the underlying database connection should be closed as well or not.
db
- Database handlecloseConn
- Indicates
if underlying connection should be closed.public static DataSetBuilder builder(DataSource dataSource)
dataSource
- Data source.public static DataSet empty(DataSource dataSource)
This convenience method is useful to denote the empty data set for a data source. It always returns an empty, read-only data set, and one that is guaranteed to be unique and for the given data source instance.
dataSource
- Data source.DataSet.isEmpty()
,
DataSet.isReadOnly()
public static DataSet data(DataSource dataSource)
dataSource
- Data source.public static <T> TypedDataSet<T> data(DataSource dataSource, Conversion<T> conv)
T
- Type of objects.dataSource
- Data source.conv
- Conversion function.public static TableBuilder table(String tableName)
A call to this method is equivalent to creating
a TableBuilder
instance as follows:
new TableBuilder().name(tableName)
tableName
- Table name.Table
instance.@SafeVarargs public static Query query(DB db, String sql, Object... args)
db
- Database handle.sql
- SQL code.args
- Optional query arguments.@SafeVarargs public static QueryBuilder select(String... columns)
A call to this method is equivalent to
creating a QueryBuilder
as follows:
new QueryBuilder().columns(columns)
columns
- Columns for query.public static DataSet takeSnapshot(DataSource dataSource)
The method takes a snapshot of the current database state
for the given data source. A fresh query will be issued,
yielding a new data set that is recorded internally
as the latest snapshot for the data source.
The snapshot is used as the base reference for any subsequent
delta assertions, until a new snapshot is defined with
a new call to this method or to populate(DataSet)
;
Note that the method returns the data set instance representing the snapshot,
but subsequent use of assertion methods does not require any book-keeping
by the caller. Also, the returned data set is read-only (see DataSet.isReadOnly()
).
dataSource
- Data source.assertDelta(DataSet, DataSet)
,
assertDeleted(DataSet)
,
assertInserted(DataSet)
,
assertUnchanged(DataSource)
@SafeVarargs public static void takeSnapshot(DataSource... dataSources)
dataSources
- Data sources.takeSnapshot(DataSource)
public static void assertEquals(DataSet expected, DataSet actual) throws DBAssertionError
Note that the executed data set comparison is insensitive to the order of rows in both data sets.
expected
- Expected data.actual
- Actual data.DBAssertionError
- if the assertion fails.assertEquals(String,DataSet,DataSet)
public static void assertEquals(String message, DataSet expected, DataSet actual) throws DBAssertionError
Note that the executed data set comparison is insensitive to the order of rows in both data sets.
message
- Assertion error message.expected
- Expected data.actual
- Actual data.DBAssertionError
- if the assertion fails.assertEquals(DataSet,DataSet)
public static void assertUnchanged(String message, DataSource dataSource) throws DBAssertionError
message
- Assertion error message.dataSource
- Data source.DBAssertionError
- if the assertion fails.assertDelta(DataSet,DataSet)
,
assertDeleted(String, DataSet)
,
assertInserted(String, DataSet)
public static void assertUnchanged(DataSource dataSource) throws DBAssertionError
dataSource
- Data source.DBAssertionError
- if the assertion fails.assertDelta(DataSet,DataSet)
,
assertDeleted(DataSet)
,
assertInserted(DataSet)
@SafeVarargs public static void assertUnchanged(String message, DataSource... dataSources) throws DBAssertionError
message
- Assertion error message.dataSources
- Data sources.DBAssertionError
- if the assertion fails.assertUnchanged(String,DataSource)
@SafeVarargs public static void assertUnchanged(DataSource... dataSources) throws DBAssertionError
dataSources
- Data sources.DBAssertionError
- if the assertion fails.assertUnchanged(String,DataSource)
public static void assertDeleted(String message, DataSet dataSet) throws DBAssertionError
message
- The message for the assertion error.dataSet
- Data set.DBAssertionError
- if the assertion fails.assertDelta(String, DataSet,DataSet)
,
assertInserted(String, DataSet)
,
assertUnchanged(String, DataSource)
public static void assertDeleted(DataSet dataSet) throws DBAssertionError
dataSet
- Data set.DBAssertionError
- if the assertion fails.assertUnchanged(DataSource)
,
assertInserted(DataSet)
@SafeVarargs public static void assertDeleted(String message, DataSet... dataSets) throws DBAssertionError
message
- Assertion error message.dataSets
- Data sets.DBAssertionError
- if the assertion fails.assertDeleted(String,DataSet)
@SafeVarargs public static void assertDeleted(DataSet... dataSets) throws DBAssertionError
dataSets
- Data set.DBAssertionError
- if the assertion fails.assertDeleted(DataSet)
public static void assertInserted(String message, DataSet dataSet) throws DBAssertionError
message
- Assertion error message.dataSet
- Data set.DBAssertionError
- if the assertion fails.assertUnchanged(DataSource)
,
assertDeleted(DataSet)
,
assertDelta(DataSet,DataSet)
public static void assertInserted(DataSet dataSet) throws DBAssertionError
dataSet
- Data set.DBAssertionError
- if the assertion fails.assertUnchanged(DataSource)
,
assertDeleted(DataSet)
,
assertDelta(DataSet,DataSet)
@SafeVarargs public static void assertInserted(String message, DataSet... dataSets) throws DBAssertionError
message
- Assertion error message.dataSets
- Data sets.DBAssertionError
- if the assertion fails.assertInserted(String,DataSet)
@SafeVarargs public static void assertInserted(DataSet... dataSets) throws DBAssertionError
dataSets
- Data sets.DBAssertionError
- if the assertion fails.assertInserted(DataSet)
public static void assertDelta(String message, DataSet oldData, DataSet newData) throws DBAssertionError
message
- The error message for the assertion error.oldData
- Expected 'old' data.newData
- Expected 'new' data.DBAssertionError
- if the assertion fails.assertUnchanged(String,DataSource)
,
assertDeleted(String,DataSet)
,
assertInserted(String,DataSet)
public static void assertDelta(DataSet oldData, DataSet newData) throws DBAssertionError
oldData
- Expected 'old' data.newData
- Expected 'new' data.DBAssertionError
- if the assertion fails.assertUnchanged(DataSource)
,
assertDeleted(DataSet)
,
assertInserted(DataSet)
public static void assertState(String message, DataSet dataSet) throws DBAssertionError
message
- Assertion error message.dataSet
- Data set.DBAssertionError
- if the assertion fails.assertEmpty(String, DataSource)
public static void assertState(DataSet dataSet) throws DBAssertionError
dataSet
- Data set.DBAssertionError
- if the assertion fails.assertEmpty(DataSource)
@SafeVarargs public static void assertState(String message, DataSet... dataSets) throws DBAssertionError
message
- Assertion error message.dataSets
- Data sets.DBAssertionError
- if the assertion fails.assertState(String,DataSet)
,
assertEmpty(String,DataSource...)
@SafeVarargs public static void assertState(DataSet... dataSets) throws DBAssertionError
dataSets
- Data sets.DBAssertionError
- if the assertion fails.assertState(DataSet)
public static void assertEmpty(String message, DataSource dataSource) throws DBAssertionError
A call to this method is equivalent to
assertState(message, empty(dataSource))
.
message
- Assertion error message.dataSource
- Data source.DBAssertionError
- if the assertion fails.assertState(String,DataSet)
,
empty(DataSource)
public static void assertEmpty(DataSource dataSource) throws DBAssertionError
A call to this method is equivalent to
assertState(empty(source))
.
dataSource
- Data source.DBAssertionError
- if the assertion fails.assertState(DataSet)
,
empty(DataSource)
@SafeVarargs public static void assertEmpty(String message, DataSource... dataSources) throws DBAssertionError
message
- Assertion error message.dataSources
- Data sources.DBAssertionError
- if the assertion fails.assertEmpty(String,DataSource)
,
assertState(String,DataSet...)
,
empty(DataSource)
@SafeVarargs public static void assertEmpty(DataSource... dataSources) throws DBAssertionError
dataSources
- Data sources.DBAssertionError
- if the assertion fails.assertEmpty(DataSource)
,
assertState(DataSet...)
,
empty(DataSource)
public static void assertTableExists(DB db, String tableName) throws DBAssertionError
db
- Database.tableName
- Table name.DBAssertionError
- If the assertion fails.assertTableDoesNotExist(DB, String)
,
drop(Table)
public static void assertTableExists(String message, DB db, String tableName) throws DBAssertionError
message
- Error message.db
- Database.tableName
- Table name.DBAssertionError
- If the assertion fails.assertTableDoesNotExist(String, DB, String)
,
drop(Table)
public static void assertTableDoesNotExist(DB db, String tableName) throws DBAssertionError
db
- Database.tableName
- Table name.DBAssertionError
- If the assertion fails.assertTableExists(DB,String)
,
drop(Table)
public static void assertTableDoesNotExist(String message, DB db, String tableName) throws DBAssertionError
message
- Error message.db
- Database.tableName
- Table.DBAssertionError
- If the assertion fails.assertTableExists(String, DB, String)
,
drop(Table)
@SafeVarargs public static void assertTableExists(DB db, String... tableNames) throws DBAssertionError
db
- Database.tableNames
- Table names.DBAssertionError
- If the assertion fails.assertTableDoesNotExist(DB, String...)
,
drop(Table...)
@SafeVarargs public static void assertTableExists(String message, DB db, String... tableNames) throws DBAssertionError
message
- Assertion error message.db
- Database.tableNames
- Table names.DBAssertionError
- If the assertion fails.assertTableDoesNotExist(String, DB, String...)
,
drop(Table...)
@SafeVarargs public static void assertTableDoesNotExist(DB db, String... tableNames) throws DBAssertionError
db
- Database.tableNames
- Table names.DBAssertionError
- If the assertion fails.assertTableExists(DB,String...)
,
drop(Table...)
@SafeVarargs public static void assertTableDoesNotExist(String message, DB db, String... tableNames) throws DBAssertionError
message
- Error message.db
- Database.tableNames
- Table names.DBAssertionError
- If the assertion fails.assertTableExists(String, DB, String...)
,
drop(Table...)
public static void insert(DataSet data)
data
- Data set for insertion.update(DataSet)
,
delete(DataSet)
,
populate(DataSet)
,
populateIfChanged(DataSet)
@SafeVarargs public static void insert(DataSet... dataSets)
dataSets
- Data sets for insertion.insert(DataSet)
,
delete(DataSet...)
,
update(DataSet...)
,
populate(DataSet...)
,
populateIfChanged(DataSet...)
public static void update(DataSet data)
The data set should be associated to a table with defined key columns. The key column values of each entry the data set determine the rows to be updated, and the remaining column values are used in the update.
data
- Data set for update.TableBuilder.key(String...)
,
Table.getKeyColumns()
,
update(DataSet...)
,
insert(DataSet)
,
populate(DataSet)
,
populateIfChanged(DataSet)
@SafeVarargs public static void update(DataSet... dataSets)
The data sets should be associated to tables with defined key columns. The key column values of each entry in a data set determine the rows to be updated, and the remaining column values are used in the update.
dataSets
- Data sets for update.TableBuilder.key(String...)
,
Table.getKeyColumns()
,
update(DataSet)
,
insert(DataSet...)
,
populate(DataSet...)
,
populateIfChanged(DataSet...)
public static void delete(DataSet data)
The data set should be associated to a table with defined key columns. The key column values of each entry in the data set determine the rows to delete.
data
- Data set for deletion.TableBuilder.key(String...)
,
Table.getKeyColumns()
,
update(DataSet)
,
insert(DataSet)
,
populate(DataSet)
,
populateIfChanged(DataSet)
@SafeVarargs public static void delete(DataSet... dataSets)
The data sets should be associated to tables with defined key columns. The key column values of each entry a data set determine the rows to delete.
dataSets
- Data sets for deletion.TableBuilder.key(String...)
,
Table.getKeyColumns()
,
update(DataSet...)
,
insert(DataSet...)
,
populate(DataSet...)
,
populateIfChanged(DataSet...)
public static void populate(DataSet data)
data
- Data set for insertion.populateIfChanged(DataSet)
,
insert(DataSet)
,
update(DataSet)
,
delete(DataSet)
@SafeVarargs public static void populate(DataSet... dataSets)
dataSets
- Data sets for insertion.populate(DataSet)
,
populateIfChanged(DataSet)
,
insert(DataSet...)
,
update(DataSet...)
,
delete(DataSet...)
public static void populateIfChanged(DataSet data)
A call to this method is functionally equivalent to
if ( changed(data.getSource()) ) populate(data);
data
- Data set for insertion.changed(DataSource...)
,
populate(DataSet)
,
insert(DataSet)
,
update(DataSet)
,
delete(DataSet)
@SafeVarargs public static void populateIfChanged(DataSet... dataSets)
dataSets
- Data sets for insertion.populateIfChanged(DataSet)
,
changed(DataSource...)
,
populate(DataSet...)
,
insert(DataSet...)
,
update(DataSet...)
,
delete(DataSet...)
public static int deleteAll(Table table)
table
- Table.truncate(Table)
,
deleteAllWhere(Table,String,Object...)
@SafeVarargs public static void deleteAll(Table... tables)
tables
- Tables.deleteAll(Table)
,
truncate(Table...)
,
deleteAllWhere(Table,String,Object...)
public static void drop(Table table)
A call to this method is shorthand for drop(table.getDB(), table.getName()))
.
table
- Table to drop.drop(DB, String)
,
assertTableExists(DB, String)
,
assertTableDoesNotExist(DB, String)
@SafeVarargs public static void drop(Table... tables)
tables
- Tables to drop.drop(Table)
,
drop(DB, String...)
,
assertTableExists(DB, String)
,
assertTableDoesNotExist(DB, String)
public static void drop(DB db, String tableName)
db
- Database.tableName
- Table name.drop(Table)
,
assertTableExists(DB, String)
,
assertTableDoesNotExist(DB, String)
@SafeVarargs public static void drop(DB db, String... tableNames)
db
- Database.tableNames
- Table names.drop(Table)
,
drop(Table...)
,
assertTableExists(DB, String)
,
assertTableDoesNotExist(DB, String)
@SafeVarargs public static int deleteAllWhere(Table table, String where, Object... args)
WHERE
clause.table
- Table.where
- WHERE
clauseargs
- WHERE
clause arguments, if any.deleteAll(Table)
,
truncate(Table)
public static void truncate(Table table)
table
- Table.deleteAll(Table)
,
deleteAllWhere(Table,String,Object...)
@SafeVarargs public static void truncate(Table... tables)
tables
- Tables to truncate.truncate(Table)
,
deleteAll(Table...)
,
drop(Table...)
@SafeVarargs public static int execute(DB db, String sql, Object... args)
You may use this method for arbitrary database setup actions.
db
- Database.sql
- SQL statement.args
- SQL statement arguments.Statement.getUpdateCount()
, after executing the statement.public static void save(DB db)
This method creates a save-point (through an internal
Savepoint
) which can later
be restored (rolled back to) using restore(DB)
.
Note that JDBDT maintains only one save-point per database
handle, hence successive calls to this method discard the previous
save-point set (if any).
db
- Database handle.restore(DB)
public static void restore(DB db)
A call to this method restores (rolls back) the state
to the last JDBDT save-point set using save(DB)
.
The save-point cannot be subsequently restored, i.e., only
one call to this method is allowed after each call to
save(DB)
.
db
- Database handle.save(DB)
public static void commit(DB db)
In database terms the method is simply a shorthand
for db.getConnection().commit()
.
Any database save-points will be discarded,
including the JDBDT save-point, if set through
save(DB)
.
db
- Database handle.Connection.commit()
public static boolean changed(DataSource dataSource)
A data source is marked as unchanged by a successful assertion
through
assertUnchanged(DataSource)
or assertUnchanged(String,DataSource)
.
Every other setup or assertion method will mark the associated
data source as changed.
This method may be useful for conditional setup code that is executed only if the database needs to be reinitialized, as illustrated below.
Table t = ...; if ( changed(t) ) { // Setup initial state again ... }
dataSource
- Data sources.true
if the data source is marked as changed.changed(DataSource...)
,
populateIfChanged(DataSet)
@SafeVarargs public static boolean changed(DataSource... dataSources)
dataSources
- Data sources.true
if at least one of the given data sources
is marked as changed.changed(DataSource)
,
populateIfChanged(DataSet...)
public static void dump(DataSet data, PrintStream out)
data
- Data set.out
- Output stream.public static void dump(DataSet data, File outputFile)
The output file will be GZIP-compressed if it has a .gz
extension.
data
- Data set.outputFile
- Output file.public static void dump(DataSource dataSource, PrintStream out)
dataSource
- Data source.out
- Output stream.public static void dump(DataSource dataSource, File outputFile)
The output file will be GZIP-compressed if it has a .gz
extension.
dataSource
- Data source.outputFile
- Output file.public static DataSet read(DataSource source, CSV.Format format, File file) throws InputOutputException, InvalidCSVConversionException
If the header option is set for the CSV format specification, the first line is skipped.
source
- Data source.format
- CSV format specification.file
- File.InputOutputException
- if an I/O error occurs.InvalidCSVConversionException
- if a CSV conversion error occurs.public static void write(DataSet dataSet, CSV.Format format, File file) throws InputOutputException
If the header option is set for the CSV format specification, column names will be written in the first line of the output file.
dataSet
- Data set.format
- CSV format specification.file
- Output file.InputOutputException
- if an I/O error occurs.Copyright © 2016–2021 JDBDT. All rights reserved.