/** * Set the metadata information (column info etc.) to be used from the given DTD input. This has precedence to the * other builder's properties. * * @param dtdReader A reader that provides the DTD content * @throws DataSetException * @throws IOException * @return this */ public FlyWeightFlatXmlDataSetBuilder setMetaDataSetFromDtd(Reader dtdReader) throws DataSetException, IOException { this.metaDataSet = new FlatDtdDataSet(dtdReader); return this; }
@Override public void doInDbUnit(IDatabaseConnection connection) throws Exception { IDataSet dataSet = new FilteredDataSet(new DatabaseSequenceFilter(connection), connection.createDataSet()); File parent = new File(dir); if (!parent.exists()) { parent.mkdirs(); } Writer out = new OutputStreamWriter(new FileOutputStream(new File(dir, fileName))); FlatDtdDataSet.write(new SortedDataSet(dataSet), out); } });
/** * Export the schema of a database as a DTD. * * @return the schema of a database as a DTD. */ public String exportDtd() { try { ITableFilter tableFilter = new DatabaseSequenceFilter(connection); IDataSet dataSet = new FilteredDataSet(tableFilter, connection.createDataSet()); StringWriter buffer = new StringWriter(); FlatDtdDataSet.write(dataSet, buffer); return buffer.toString(); } catch (DataSetException | IOException | SQLException e) { throw new RuntimeException("Error while exporting schema", e); } }
FlatDtdDataSet.write(dataSet, fosDtd);
/** * Set the metadata information (column info etc.) to be used from the given DTD input. This has precedence to the * other builder's properties. * * @param dtdStream * @throws DataSetException * @throws IOException * @return this */ public FlyWeightFlatXmlDataSetBuilder setMetaDataSetFromDtd(InputStream dtdStream) throws DataSetException, IOException { this.metaDataSet = new FlatDtdDataSet(dtdStream); return this; }
@Override protected IDataSet fromResource(Resource resource, DataSetFormatOptions options) throws DataSetException, IOException { return new FlatDtdDataSet(new LinkedHashMapFlatDtdProducer(new InputSource(resource.getInputStream()))); } },
@Override public void startDTD(String name, String publicId, String systemId) throws SAXException { if (flatDtdLogger.isDebugEnabled()) flatDtdLogger.debug("startDTD(name={}, publicId={}, systemId={}) - start", new Object[] { name, publicId, systemId }); _dtdPresent = true; try { // Cache the DTD content to use it as metadata FlatDtdDataSet metaDataSet = new FlatDtdDataSet(); this.setConsumer(metaDataSet); // Set the metaData on the xmlProducer xmlProducer._metaDataSet = metaDataSet; super.startDTD(name, publicId, systemId); } catch (DataSetException e) { throw new SAXException(e); } } }