public class FlatXmlDataSet extends CachedDataSet
Flat XML dataset document sample:
<!DOCTYPE dataset SYSTEM "my-dataset.dtd"> <dataset> <TEST_TABLE COL0="row 0 col 0" COL1="row 0 col 1" COL2="row 0 col 2"/> <TEST_TABLE COL1="row 1 col 1"/> <SECOND_TABLE COL0="row 0 col 0" COL1="row 0 col 1" /> <EMPTY_TABLE/> </dataset>
To specify null values, omit corresponding attribute. In the above example, missing COL0 and COL2 attributes of TEST_TABLE second row represents null values.
Table metadata is deduced from the first row of each table by default. Beware that DbUnit may think a table misses some columns if the first row of that table has one or more null values. You can do one of the following things to avoid this:
boolean enableColumnSensing = true; IDataSet dataSet = new FlatXmlDataSet( new File("src/xml/flatXmlTableTest.xml"), false, enableColumnSensing);
Constructor and Description |
---|
FlatXmlDataSet(File xmlFile)
Creates an FlatXmlDataSet object with the specified xml file.
|
FlatXmlDataSet(File xmlFile,
boolean dtdMetadata)
Creates an FlatXmlDataSet object with the specified xml file.
|
FlatXmlDataSet(File xmlFile,
boolean dtdMetadata,
boolean columnSensing)
Creates an FlatXmlDataSet object with the specified xml file.
|
FlatXmlDataSet(File xmlFile,
boolean dtdMetadata,
boolean columnSensing,
boolean caseSensitiveTableNames)
Creates an FlatXmlDataSet object with the specified xml file.
|
FlatXmlDataSet(InputSource source)
Creates an FlatXmlDataSet object with the specified InputSource.
|
FlatXmlDataSet(InputStream xmlStream)
Creates an FlatXmlDataSet object with the specified xml input stream.
|
FlatXmlDataSet(InputStream xmlStream,
boolean dtdMetadata)
Creates an FlatXmlDataSet object with the specified xml input stream.
|
FlatXmlDataSet(InputStream xmlStream,
IDataSet metaDataSet)
Creates an FlatXmlDataSet object with the specified xml input stream.
|
FlatXmlDataSet(InputStream xmlStream,
InputStream dtdStream)
Creates an FlatXmlDataSet object with the specified xml and dtd input
stream.
|
FlatXmlDataSet(Reader xmlReader)
Creates an FlatXmlDataSet object with the specified xml reader.
|
FlatXmlDataSet(Reader xmlReader,
boolean dtdMetadata)
Creates an FlatXmlDataSet object with the specified xml reader.
|
FlatXmlDataSet(Reader xmlReader,
IDataSet metaDataSet)
Creates an FlatXmlDataSet object with the specified xml reader.
|
FlatXmlDataSet(Reader xmlReader,
Reader dtdReader)
Creates an FlatXmlDataSet object with the specified xml and dtd readers.
|
FlatXmlDataSet(URL xmlUrl)
Creates an FlatXmlDataSet object with the specified xml URL.
|
FlatXmlDataSet(URL xmlUrl,
boolean dtdMetadata)
Creates an FlatXmlDataSet object with the specified xml URL.
|
FlatXmlDataSet(URL xmlUrl,
boolean dtdMetadata,
boolean columnSensing)
Creates an FlatXmlDataSet object with the specified xml URL.
|
FlatXmlDataSet(URL xmlUrl,
boolean dtdMetadata,
boolean columnSensing,
boolean caseSensitiveTableNames)
Creates an FlatXmlDataSet object with the specified xml file.
|
Modifier and Type | Method and Description |
---|---|
static void |
write(IDataSet dataSet,
OutputStream out)
Write the specified dataset to the specified output stream as xml.
|
static void |
write(IDataSet dataSet,
Writer writer)
Write the specified dataset to the specified writer as xml.
|
static void |
write(IDataSet dataSet,
Writer writer,
String encoding)
Write the specified dataset to the specified writer as xml.
|
static void |
writeDtd(IDataSet dataSet,
OutputStream out)
|
createIterator, endDataSet, endTable, row, startDataSet, startTable
createTableNameMap, getTable, getTableMetaData, getTableNames, getTables, isCaseSensitiveTableNames, iterator, reverseIterator, toString
public FlatXmlDataSet(InputSource source) throws IOException, DataSetException
IOException
DataSetException
public FlatXmlDataSet(File xmlFile) throws IOException, DataSetException
xmlFile
- the xml fileIOException
DataSetException
public FlatXmlDataSet(File xmlFile, boolean dtdMetadata) throws IOException, DataSetException
xmlFile
- the xml filedtdMetadata
- if false
do not use DTD as metadataIOException
DataSetException
public FlatXmlDataSet(File xmlFile, boolean dtdMetadata, boolean columnSensing) throws IOException, DataSetException
xmlFile
- the xml filedtdMetadata
- if false
do not use DTD as metadatacolumnSensing
- Whether or not the columns should be sensed automatically. Every XML row
is scanned for columns that have not been there in a previous column.IOException
DataSetException
public FlatXmlDataSet(File xmlFile, boolean dtdMetadata, boolean columnSensing, boolean caseSensitiveTableNames) throws IOException, DataSetException
xmlFile
- the xml filedtdMetadata
- if false
do not use DTD as metadatacolumnSensing
- Whether or not the columns should be sensed automatically. Every XML row
is scanned for columns that have not been there in a previous column.caseSensitiveTableNames
- Whether or not this dataset should use case sensitive table namesIOException
DataSetException
public FlatXmlDataSet(URL xmlUrl) throws IOException, DataSetException
xmlUrl
- the xml URLIOException
DataSetException
public FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata) throws IOException, DataSetException
xmlUrl
- the xml URLdtdMetadata
- if false
do not use DTD as metadataIOException
DataSetException
public FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata, boolean columnSensing) throws IOException, DataSetException
xmlUrl
- the xml URLdtdMetadata
- if false
do not use DTD as metadatacolumnSensing
- Whether or not the columns should be sensed automatically. Every XML row
is scanned for columns that have not been there in a previous column.IOException
DataSetException
public FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata, boolean columnSensing, boolean caseSensitiveTableNames) throws IOException, DataSetException
xmlUrl
- the xml filedtdMetadata
- if false
do not use DTD as metadatacolumnSensing
- Whether or not the columns should be sensed automatically. Every XML row
is scanned for columns that have not been there in a previous column.caseSensitiveTableNames
- Whether or not this dataset should use case sensitive table namesIOException
DataSetException
public FlatXmlDataSet(Reader xmlReader) throws IOException, DataSetException
xmlReader
- the xml readerIOException
DataSetException
public FlatXmlDataSet(Reader xmlReader, boolean dtdMetadata) throws IOException, DataSetException
xmlReader
- the xml readerdtdMetadata
- if false
do not use DTD as metadataIOException
DataSetException
public FlatXmlDataSet(Reader xmlReader, Reader dtdReader) throws IOException, DataSetException
xmlReader
- the xml readerdtdReader
- the dtd readerIOException
DataSetException
public FlatXmlDataSet(Reader xmlReader, IDataSet metaDataSet) throws IOException, DataSetException
xmlReader
- the xml readermetaDataSet
- the dataset used as metadata source.IOException
DataSetException
public FlatXmlDataSet(InputStream xmlStream) throws IOException, DataSetException
xmlStream
- the xml input streamIOException
DataSetException
public FlatXmlDataSet(InputStream xmlStream, boolean dtdMetadata) throws IOException, DataSetException
xmlStream
- the xml input streamdtdMetadata
- if false
do not use DTD as metadataIOException
DataSetException
public FlatXmlDataSet(InputStream xmlStream, InputStream dtdStream) throws IOException, DataSetException
xmlStream
- the xml input streamdtdStream
- the dtd input streamIOException
DataSetException
public FlatXmlDataSet(InputStream xmlStream, IDataSet metaDataSet) throws IOException, DataSetException
xmlStream
- the xml input streammetaDataSet
- the dataset used as metadata source.IOException
DataSetException
public static void write(IDataSet dataSet, OutputStream out) throws IOException, DataSetException
IOException
DataSetException
public static void write(IDataSet dataSet, Writer writer) throws IOException, DataSetException
IOException
DataSetException
public static void write(IDataSet dataSet, Writer writer, String encoding) throws IOException, DataSetException
IOException
DataSetException
public static void writeDtd(IDataSet dataSet, OutputStream out) throws IOException, DataSetException
IOException
DataSetException
Copyright © 2002-2012. All Rights Reserved.