* Writes the given configuration to the given file.
*/
public static void write(Configuration config, String file)
throws IOException {
FileOutputStream fos = new FileOutputStream(file);
XMLPrettyPrinter pp = new XMLPrettyPrinter(fos);
pp.startDocument();
pp.startElement("duke", null);
// FIXME: here we should write the objects, but that's not
// possible with the current API. we don't need that for the
// genetic algorithm at the moment, but it would be useful.
pp.startElement("schema", null);
writeElement(pp, "threshold", "" + config.getThreshold());
if (config.getMaybeThreshold() != 0.0)
writeElement(pp, "maybe-threshold", "" + config.getMaybeThreshold());
for (Property p : config.getProperties())
writeProperty(pp, p);
pp.endElement("schema");
String dbclass = config.getDatabase(false).getClass().getName();
AttributeListImpl atts = new AttributeListImpl();
atts.addAttribute("class", "CDATA", dbclass);
pp.startElement("database", atts);
pp.endElement("database");
if (config.isDeduplicationMode())
for (DataSource src : config.getDataSources())
writeDataSource(pp, src);
else {
pp.startElement("group", null);
for (DataSource src : config.getDataSources(1))
writeDataSource(pp, src);
pp.endElement("group");
pp.startElement("group", null);
for (DataSource src : config.getDataSources(2))
writeDataSource(pp, src);
pp.endElement("group");
}
pp.endElement("duke");
pp.endDocument();
fos.close();
}