use of de.lmu.ifi.dbs.elki.result.textwriter.naming.SimpleEnumeratingScheme in project elki by elki-project.
the class TextWriter method output.
/**
* Stream output.
*
* @param db Database object
* @param r Result class
* @param streamOpener output stream manager
* @param filter Filter pattern
* @throws IOException on IO error
*/
@SuppressWarnings("unchecked")
public void output(Database db, Result r, StreamFactory streamOpener, Pattern filter) throws IOException {
List<Relation<?>> ra = new LinkedList<>();
List<OrderingResult> ro = new LinkedList<>();
List<Clustering<?>> rc = new LinkedList<>();
List<IterableResult<?>> ri = new LinkedList<>();
List<SettingsResult> rs = new LinkedList<>();
List<Result> otherres = new LinkedList<>();
// Split result objects in different known types:
{
List<Result> results = ResultUtil.filterResults(db.getHierarchy(), r, Result.class);
for (Result res : results) {
if (filter != null) {
final String nam = res.getShortName();
if (nam == null || !filter.matcher(nam).find()) {
continue;
}
}
if (res instanceof Database) {
continue;
}
if (res instanceof Relation) {
ra.add((Relation<?>) res);
continue;
}
if (res instanceof OrderingResult) {
ro.add((OrderingResult) res);
continue;
}
if (res instanceof Clustering) {
rc.add((Clustering<?>) res);
continue;
}
if (res instanceof IterableResult) {
ri.add((IterableResult<?>) res);
continue;
}
if (res instanceof SettingsResult) {
rs.add((SettingsResult) res);
continue;
}
otherres.add(res);
}
}
writeSettingsResult(streamOpener, rs);
for (IterableResult<?> rii : ri) {
writeIterableResult(streamOpener, rii);
}
for (Clustering<?> c : rc) {
NamingScheme naming = new SimpleEnumeratingScheme(c);
for (Cluster<?> clus : c.getAllClusters()) {
writeClusterResult(db, streamOpener, (Clustering<Model>) c, (Cluster<Model>) clus, ra, naming);
}
}
for (OrderingResult ror : ro) {
writeOrderingResult(db, streamOpener, ror, ra);
}
for (Result otherr : otherres) {
writeOtherResult(streamOpener, otherr);
}
}
Aggregations