1 21 22 package org.dbunit.dataset.xml; 23 24 import org.dbunit.dataset.CachedDataSet; 25 import org.dbunit.dataset.DataSetException; 26 import org.dbunit.dataset.IDataSet; 27 import org.xml.sax.InputSource ; 28 29 import java.io.*; 30 31 51 public class XmlDataSet extends CachedDataSet 52 { 53 private static final String DEFAULT_ENCODING = "UTF8"; 54 55 58 public XmlDataSet(Reader reader) throws DataSetException 59 { 60 super(new XmlProducer(new InputSource (reader))); 61 } 62 63 66 public XmlDataSet(InputStream in) throws DataSetException 67 { 68 super(new XmlProducer(new InputSource (in))); 69 } 70 71 74 public static void write(IDataSet dataSet, OutputStream out) 75 throws IOException, DataSetException 76 { 77 OutputStreamWriter writer = new OutputStreamWriter(out, DEFAULT_ENCODING); 78 write(dataSet, writer); 79 } 80 81 84 public static void write(IDataSet dataSet, Writer writer) 85 throws IOException, DataSetException 86 { 87 write(dataSet, writer, null); 88 } 89 90 93 public static void write(IDataSet dataSet, Writer writer, String encoding) 94 throws IOException, DataSetException 95 { 96 XmlDataSetWriter datasetWriter = new XmlDataSetWriter(writer, encoding); 97 datasetWriter.write(dataSet); 98 } 99 } | Popular Tags |