Package elki.result.textwriter
Class TextWriter
- java.lang.Object
-
- elki.result.textwriter.TextWriter
-
public class TextWriter extends java.lang.Object
Class to write a result to human-readable text output.Note: these classes need to be redesigned. Contributions welcome!
- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private TextWriterWriterInterface<?>
fallback
Fallback writer for unknown objects.static java.lang.String
FILE_EXTENSION
Extension for txt-files.protected java.util.Map<java.lang.String,java.lang.Object>
filenames
For producing unique filenames.static HandlerList<TextWriterWriterInterface<?>>
writers
Hash map for supported classes in writer.
-
Constructor Summary
Constructors Constructor Description TextWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
filenameFromLabel(java.lang.String label)
Derive a file name from the cluster label.protected java.lang.String
getFilename(java.lang.Object result, java.lang.String filenamepre)
Try to find a unique file name.void
output(Database db, java.lang.Object r, StreamFactory streamOpener, java.util.regex.Pattern filter)
Stream output.private void
printObject(TextWriterStream out, Database db, DBIDRef objID, java.util.List<Relation<?>> ra)
private void
writeClusterResult(Database db, StreamFactory streamOpener, Clustering<Model> clustering, Cluster<Model> clus, java.util.List<Relation<?>> ra, NamingScheme naming)
private void
writeIterableResult(StreamFactory streamOpener, IterableResult<?> ri)
private void
writeOrderingResult(Database db, StreamFactory streamOpener, OrderingResult or, java.util.List<Relation<?>> ra)
private void
writeOtherResult(StreamFactory streamOpener, java.lang.Object r)
private void
writeSettingsResult(StreamFactory streamOpener, java.util.List<SettingsResult> rs)
-
-
-
Field Detail
-
FILE_EXTENSION
public static final java.lang.String FILE_EXTENSION
Extension for txt-files.- See Also:
- Constant Field Values
-
writers
public static final HandlerList<TextWriterWriterInterface<?>> writers
Hash map for supported classes in writer.
-
filenames
protected java.util.Map<java.lang.String,java.lang.Object> filenames
For producing unique filenames.
-
fallback
private TextWriterWriterInterface<?> fallback
Fallback writer for unknown objects.
-
-
Method Detail
-
getFilename
protected java.lang.String getFilename(java.lang.Object result, java.lang.String filenamepre)
Try to find a unique file name.- Parameters:
result
- Result we printfilenamepre
- File name prefix to use- Returns:
- unique filename
-
output
public void output(Database db, java.lang.Object r, StreamFactory streamOpener, java.util.regex.Pattern filter) throws java.io.IOException
Stream output.- Parameters:
db
- Database objectr
- Result classstreamOpener
- output stream managerfilter
- Filter pattern- Throws:
java.io.IOException
- on IO error
-
printObject
private void printObject(TextWriterStream out, Database db, DBIDRef objID, java.util.List<Relation<?>> ra) throws java.io.IOException
- Throws:
java.io.IOException
-
writeClusterResult
private void writeClusterResult(Database db, StreamFactory streamOpener, Clustering<Model> clustering, Cluster<Model> clus, java.util.List<Relation<?>> ra, NamingScheme naming) throws java.io.FileNotFoundException, java.io.IOException
- Throws:
java.io.FileNotFoundException
java.io.IOException
-
writeIterableResult
private void writeIterableResult(StreamFactory streamOpener, IterableResult<?> ri) throws java.io.IOException
- Throws:
java.io.IOException
-
writeOrderingResult
private void writeOrderingResult(Database db, StreamFactory streamOpener, OrderingResult or, java.util.List<Relation<?>> ra) throws java.io.IOException
- Throws:
java.io.IOException
-
writeSettingsResult
private void writeSettingsResult(StreamFactory streamOpener, java.util.List<SettingsResult> rs) throws java.io.IOException
- Throws:
java.io.IOException
-
writeOtherResult
private void writeOtherResult(StreamFactory streamOpener, java.lang.Object r) throws java.io.IOException
- Throws:
java.io.IOException
-
filenameFromLabel
private java.lang.String filenameFromLabel(java.lang.String label)
Derive a file name from the cluster label.- Parameters:
label
- cluster label- Returns:
- cleaned label suitable for file names.
-
-