Package org.dbunit.dataset.csv
Class CsvDataSetWriter
java.lang.Object
org.dbunit.dataset.csv.CsvDataSetWriter
- All Implemented Interfaces:
IDataSetConsumer
IDataSetConsumer that writes a dataset's tables and rows to CSV files.- Since:
- 24-set-2003 15.27.05
- Version:
- $Revision$
- Author:
- fede
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCsvDataSetWriter(File theDirectory) Creates a writer that writes CSV files to the given directory.CsvDataSetWriter(String theDirectory) Creates a writer that writes CSV files to the given directory. -
Method Summary
Modifier and TypeMethodDescriptionvoidReceive notification of the end of a dataset.voidendTable()Receive notification of the end of a table.protected static StringEscapes quote and backslash characters in the given string by prefixing them with a backslash.protected voidfinalize()Returns the directory CSV files are written to.Returns the writer for the currently active table.voidReceive notification of a table row.voidsetTheDirectory(String theDirectory) Sets the directory CSV files are written to.voidSets the writer for the currently active table.voidReceive notification of the beginning of a dataset.voidstartTable(ITableMetaData metaData) Receive notification of the beginning of a table.voidWrites the given dataset's tables and rows to CSV files.static voidWrites the given dataset's tables and rows as CSV files to the given directory.
-
Field Details
-
NULL
todo: customizable separators (field, lines), manage the writers opened for each table- See Also:
-
-
Constructor Details
-
CsvDataSetWriter
Creates a writer that writes CSV files to the given directory.- Parameters:
theDirectory- the path of the directory to write CSV files to.
-
CsvDataSetWriter
Creates a writer that writes CSV files to the given directory.- Parameters:
theDirectory- the directory to write CSV files to.
-
-
Method Details
-
write
Writes the given dataset's tables and rows to CSV files.- Parameters:
dataSet- the dataset to write.- Throws:
DataSetException- if writing the dataset fails.
-
startDataSet
Receive notification of the beginning of a dataset. This method is invoked only once, before any other methods in this interface.- Specified by:
startDataSetin interfaceIDataSetConsumer- Throws:
DataSetException- if the notification cannot be processed.
-
endDataSet
Receive notification of the end of a dataset. This method is invoked only once, and it will be the last method invoked in this interface.- Specified by:
endDataSetin interfaceIDataSetConsumer- Throws:
DataSetException- if the notification cannot be processed.
-
startTable
Receive notification of the beginning of a table. This method is invoked at the beginning of every table in the dataset; there will be a correspondingIDataSetConsumer.endDataSet()event for everystartTableevent (even when the table is empty).- Specified by:
startTablein interfaceIDataSetConsumer- Parameters:
metaData- the table metadata- Throws:
DataSetException- if the notification cannot be processed.
-
endTable
Description copied from interface:IDataSetConsumerReceive notification of the end of a table.- Specified by:
endTablein interfaceIDataSetConsumer- Throws:
DataSetException- if the notification cannot be processed.
-
row
Description copied from interface:IDataSetConsumerReceive notification of a table row. This method is invoked to report each row of a table.- Specified by:
rowin interfaceIDataSetConsumer- Parameters:
values- The row values.- Throws:
DataSetException- if the notification cannot be processed.
-
escape
Escapes quote and backslash characters in the given string by prefixing them with a backslash.- Parameters:
stringValue- the string to escape.- Returns:
- the escaped string.
-
getWriter
Returns the writer for the currently active table.- Returns:
- the writer for the currently active table.
-
setWriter
Sets the writer for the currently active table.- Parameters:
writer- the writer for the currently active table.
-
getTheDirectory
Returns the directory CSV files are written to.- Returns:
- the directory CSV files are written to.
-
setTheDirectory
Sets the directory CSV files are written to.- Parameters:
theDirectory- the directory CSV files are written to.
-
write
Writes the given dataset's tables and rows as CSV files to the given directory.- Parameters:
dataset- the dataset to write.dest- the directory to write CSV files to.- Throws:
DataSetException- if writing the dataset fails.
-
finalize
-