Class FlatXmlWriter

java.lang.Object
org.dbunit.dataset.xml.FlatXmlWriter
All Implemented Interfaces:
IDataSetConsumer

public class FlatXmlWriter extends Object implements IDataSetConsumer
IDataSetConsumer that writes a dataset to the DbUnit flat XML dataset format.
Since:
1.5.5 (Apr 19, 2003)
Version:
$Revision$ $Date$
Author:
Manuel Laflamme, Last changed by: $Author$
  • Constructor Details

    • FlatXmlWriter

      public FlatXmlWriter(OutputStream out) throws IOException
      Creates a writer that writes XML to the given output stream, using the platform default charset.
      Parameters:
      out - the stream to write to.
      Throws:
      IOException - if the writer cannot be created.
    • FlatXmlWriter

      public FlatXmlWriter(OutputStream outputStream, Charset charset)
      Creates a writer that writes XML to the given output stream.
      Parameters:
      outputStream - The stream to which the XML will be written.
      charset - The character set to be used for the XmlWriter. Can be null. See XmlWriter(OutputStream, Charset).
    • FlatXmlWriter

      public FlatXmlWriter(Writer writer)
      Creates a writer that writes XML to the given writer.
      Parameters:
      writer - the writer to write to.
    • FlatXmlWriter

      public FlatXmlWriter(Writer writer, Charset charset)
      Creates a writer that writes XML to the given writer.
      Parameters:
      writer - the writer to write to.
      charset - the charset to declare in the XML prolog, may be null.
  • Method Details

    • setIncludeEmptyTable

      public void setIncludeEmptyTable(boolean includeEmptyTable)
      Sets whether or not empty tables are included in the output.
      Parameters:
      includeEmptyTable - whether or not empty tables are included in the output.
    • setDocType

      public void setDocType(String systemId)
      Sets the DOCTYPE system id to declare in the output.
      Parameters:
      systemId - the DOCTYPE system id.
    • setPrettyPrint

      public void setPrettyPrint(boolean enabled)
      Enable or disable pretty print of the XML.
      Parameters:
      enabled - true to enable pretty print (which is the default). false otherwise.
      Since:
      2.4
    • write

      public void write(IDataSet dataSet) throws DataSetException
      Writes the given IDataSet using this writer.
      Parameters:
      dataSet - The IDataSet to be written
      Throws:
      DataSetException - if reading the dataset fails.
    • startDataSet

      public void startDataSet() throws DataSetException
      Description copied from interface: IDataSetConsumer
      Receive notification of the beginning of a dataset. This method is invoked only once, before any other methods in this interface.
      Specified by:
      startDataSet in interface IDataSetConsumer
      Throws:
      DataSetException - if the notification cannot be processed.
    • endDataSet

      public void endDataSet() throws DataSetException
      Description copied from interface: IDataSetConsumer
      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:
      endDataSet in interface IDataSetConsumer
      Throws:
      DataSetException - if the notification cannot be processed.
    • startTable

      public void startTable(ITableMetaData metaData) throws DataSetException
      Description copied from interface: IDataSetConsumer
      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 corresponding IDataSetConsumer.endDataSet() event for every startTable event (even when the table is empty).
      Specified by:
      startTable in interface IDataSetConsumer
      Parameters:
      metaData - the table metadata
      Throws:
      DataSetException - if the notification cannot be processed.
    • endTable

      public void endTable() throws DataSetException
      Description copied from interface: IDataSetConsumer
      Receive notification of the end of a table.
      Specified by:
      endTable in interface IDataSetConsumer
      Throws:
      DataSetException - if the notification cannot be processed.
    • row

      public void row(Object[] values) throws DataSetException
      Description copied from interface: IDataSetConsumer
      Receive notification of a table row. This method is invoked to report each row of a table.
      Specified by:
      row in interface IDataSetConsumer
      Parameters:
      values - The row values.
      Throws:
      DataSetException - if the notification cannot be processed.