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 28 import org.xml.sax.InputSource ; 29 30 import java.io.File ; 31 import java.io.IOException ; 32 import java.io.InputStream ; 33 import java.io.OutputStream ; 34 import java.io.Reader ; 35 import java.io.Writer ; 36 import java.net.URL ; 37 38 70 public class FlatXmlDataSet extends CachedDataSet 71 { 72 75 public FlatXmlDataSet(InputSource source) throws IOException , DataSetException 76 { 77 super(new FlatXmlProducer(source)); 78 } 79 80 86 public FlatXmlDataSet(File xmlFile) throws IOException , DataSetException 87 { 88 this(xmlFile, true); 89 } 90 91 98 public FlatXmlDataSet(File xmlFile, boolean dtdMetadata) 99 throws IOException , DataSetException 100 { 101 this(xmlFile.toURL(), dtdMetadata); 102 } 103 104 110 public FlatXmlDataSet(URL xmlUrl) throws IOException , DataSetException 111 { 112 this(xmlUrl, true); 113 } 114 115 122 public FlatXmlDataSet(URL xmlUrl, boolean dtdMetadata) 123 throws IOException , DataSetException 124 { 125 super(new FlatXmlProducer( 126 new InputSource (xmlUrl.toString()), dtdMetadata)); 127 } 128 129 135 public FlatXmlDataSet(Reader xmlReader) throws IOException , DataSetException 136 { 137 this(xmlReader, true); 138 } 139 140 147 public FlatXmlDataSet(Reader xmlReader, boolean dtdMetadata) 148 throws IOException , DataSetException 149 { 150 super(new FlatXmlProducer( 151 new InputSource (xmlReader), dtdMetadata)); 152 } 153 154 160 public FlatXmlDataSet(Reader xmlReader, Reader dtdReader) 161 throws IOException , DataSetException 162 { 163 this(xmlReader, new FlatDtdDataSet(dtdReader)); 164 } 165 166 172 public FlatXmlDataSet(Reader xmlReader, IDataSet metaDataSet) 173 throws IOException , DataSetException 174 { 175 super(new FlatXmlProducer( 176 new InputSource (xmlReader), metaDataSet)); 177 } 178 179 185 public FlatXmlDataSet(InputStream xmlStream) throws IOException , DataSetException 186 { 187 this(xmlStream, true); 188 } 189 190 197 public FlatXmlDataSet(InputStream xmlStream, boolean dtdMetadata) 198 throws IOException , DataSetException 199 { 200 super(new FlatXmlProducer( 201 new InputSource (xmlStream), dtdMetadata)); 202 } 203 204 211 public FlatXmlDataSet(InputStream xmlStream, InputStream dtdStream) 212 throws IOException , DataSetException 213 { 214 this(xmlStream, new FlatDtdDataSet(dtdStream)); 215 } 216 217 223 public FlatXmlDataSet(InputStream xmlStream, IDataSet metaDataSet) 224 throws IOException , DataSetException 225 { 226 super(new FlatXmlProducer( 227 new InputSource (xmlStream), metaDataSet)); 228 } 229 230 233 public static void write(IDataSet dataSet, OutputStream out) 234 throws IOException , DataSetException 235 { 236 FlatXmlWriter datasetWriter = new FlatXmlWriter(out); 237 datasetWriter.setIncludeEmptyTable(true); 238 datasetWriter.write(dataSet); 239 } 240 241 244 public static void write(IDataSet dataSet, Writer writer) 245 throws IOException , DataSetException 246 { 247 write(dataSet, writer, null); 248 } 249 250 253 public static void write(IDataSet dataSet, Writer writer, String encoding) 254 throws IOException , DataSetException 255 { 256 FlatXmlWriter datasetWriter = new FlatXmlWriter(writer, encoding); 257 datasetWriter.setIncludeEmptyTable(true); 258 datasetWriter.write(dataSet); 259 } 260 261 265 public static void writeDtd(IDataSet dataSet, OutputStream out) 266 throws IOException , DataSetException 267 { 268 FlatDtdDataSet.write(dataSet, out); 269 } 270 } 271 272 273 274 275 276 277 278 279 280 281 282 | Popular Tags |