org.dbunit.dataset.xml
Class XmlDataSetWriter

java.lang.Object
  extended by org.dbunit.dataset.xml.XmlDataSetWriter
All Implemented Interfaces:
IDataSetConsumer

public class XmlDataSetWriter
extends Object
implements IDataSetConsumer

Since:
1.5.5 (Jun 13, 2003)
Version:
$Revision: 947 $ $Date: 2009-01-20 11:34:50 -0600 (Tue, 20 Jan 2009) $
Author:
Manuel Laflamme, Last changed by: $Author: gommma $

Constructor Summary
XmlDataSetWriter(OutputStream outputStream, String encoding)
           
XmlDataSetWriter(Writer writer)
           
XmlDataSetWriter(Writer writer, String encoding)
           
 
Method Summary
 void endDataSet()
          Receive notification of the end of a dataset.
 void endTable()
          Receive notification of the end of a table.
protected  XmlWriter getXmlWriter()
           
 void row(Object[] values)
          Receive notification of a table row.
 void setIncludeColumnComments(boolean includeColumnComments)
          Whether or not to write the column name as comment into the XML
 void setPrettyPrint(boolean enabled)
          Enable or disable pretty print of the XML.
 void startDataSet()
          Receive notification of the beginning of a dataset.
 void startTable(ITableMetaData metaData)
          Receive notification of the beginning of a table.
 void write(IDataSet dataSet)
          Writes the given IDataSet using this writer.
protected  void writeValue(String stringValue)
          Writes the given String as normal text using the XmlWriter.
protected  void writeValueCData(String stringValue)
          Writes the given String as CDATA using the XmlWriter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDataSetWriter

public XmlDataSetWriter(OutputStream outputStream,
                        String encoding)
                 throws UnsupportedEncodingException
Parameters:
outputStream - The stream to which the XML will be written.
encoding - The encoding to be used for the XmlWriter. Can be null. See XmlWriter.XmlWriter(OutputStream, String).
Throws:
UnsupportedEncodingException

XmlDataSetWriter

public XmlDataSetWriter(Writer writer)

XmlDataSetWriter

public XmlDataSetWriter(Writer writer,
                        String encoding)
Method Detail

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

setIncludeColumnComments

public void setIncludeColumnComments(boolean includeColumnComments)
Whether or not to write the column name as comment into the XML

Parameters:
includeColumnComments - Whether or not to write the column name as comment into the XML

write

public void write(IDataSet dataSet)
           throws DataSetException
Writes the given IDataSet using this writer.

Parameters:
dataSet - The IDataSet to be written
Throws:
DataSetException

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

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

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

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

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

writeValueCData

protected void writeValueCData(String stringValue)
                        throws IOException
Writes the given String as CDATA using the XmlWriter. Can be overridden to add custom behavior. This implementation just invokes XmlWriter.writeCData(String)

Parameters:
stringValue - The value to be written
Throws:
IOException
Since:
2.4.4

writeValue

protected void writeValue(String stringValue)
                   throws IOException
Writes the given String as normal text using the XmlWriter. Can be overridden to add custom behavior. This implementation just invokes XmlWriter.writeText(String).

Parameters:
stringValue - The value to be written
Throws:
IOException
Since:
2.4.4

getXmlWriter

protected final XmlWriter getXmlWriter()
Returns:
The XmlWriter that is used for writing out XML.
Since:
2.4.4


Copyright © 2002-2012. All Rights Reserved.