de.lmu.ifi.dbs.elki.result.textwriter
Class TextWriter

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.result.textwriter.TextWriter

public class TextWriter
extends Object

Class to write a result to human-readable text output


Field Summary
static String FILE_EXTENSION
          Extension for txt-files.
protected  Map<String,Object> filenames
          For producing unique filenames.
static HandlerList<TextWriterWriterInterface<?>> writers
          Hash map for supported classes in writer.
 
Constructor Summary
TextWriter()
           
 
Method Summary
private  String filenameFromLabel(String label)
          Derive a file name from the cluster label.
protected  String getFilename(Object result, String filenamepre)
          Try to find a unique file name.
 void output(Database db, Result r, StreamFactory streamOpener)
          Stream output.
private  void printObject(TextWriterStream out, Database db, DBID objID, List<Relation<?>> ra)
           
protected  void printSettings(TextWriterStream out, List<SettingsResult> sr)
          Writes a header providing information concerning the underlying database and the specified parameter-settings.
private  void writeClusterResult(Database db, StreamFactory streamOpener, Cluster<?> clus, List<Relation<?>> ra, NamingScheme naming, List<SettingsResult> sr)
           
private  void writeIterableResult(StreamFactory streamOpener, IterableResult<?> ri, List<SettingsResult> sr)
           
private  void writeOrderingResult(Database db, StreamFactory streamOpener, OrderingResult or, List<Relation<?>> ra, List<SettingsResult> sr)
           
private  void writeOtherResult(StreamFactory streamOpener, Result r, List<SettingsResult> rs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_EXTENSION

public static final 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 Map<String,Object> filenames
For producing unique filenames.

Constructor Detail

TextWriter

public TextWriter()
Method Detail

getFilename

protected String getFilename(Object result,
                             String filenamepre)
Try to find a unique file name.

Parameters:
result - Result we print
filenamepre - File name prefix to use
Returns:
unique filename

printSettings

protected void printSettings(TextWriterStream out,
                             List<SettingsResult> sr)
Writes a header providing information concerning the underlying database and the specified parameter-settings.

Parameters:
out - the print stream where to write
sr - the settings to be written into the header

output

public void output(Database db,
                   Result r,
                   StreamFactory streamOpener)
            throws UnableToComplyException,
                   IOException
Stream output.

Parameters:
db - Database object
r - Result class
streamOpener - output stream manager
Throws:
UnableToComplyException - when no usable results were found
IOException - on IO error

printObject

private void printObject(TextWriterStream out,
                         Database db,
                         DBID objID,
                         List<Relation<?>> ra)
                  throws UnableToComplyException,
                         IOException
Throws:
UnableToComplyException
IOException

writeOtherResult

private void writeOtherResult(StreamFactory streamOpener,
                              Result r,
                              List<SettingsResult> rs)
                       throws UnableToComplyException,
                              IOException
Throws:
UnableToComplyException
IOException

writeClusterResult

private void writeClusterResult(Database db,
                                StreamFactory streamOpener,
                                Cluster<?> clus,
                                List<Relation<?>> ra,
                                NamingScheme naming,
                                List<SettingsResult> sr)
                         throws FileNotFoundException,
                                UnableToComplyException,
                                IOException
Throws:
FileNotFoundException
UnableToComplyException
IOException

writeIterableResult

private void writeIterableResult(StreamFactory streamOpener,
                                 IterableResult<?> ri,
                                 List<SettingsResult> sr)
                          throws UnableToComplyException,
                                 IOException
Throws:
UnableToComplyException
IOException

writeOrderingResult

private void writeOrderingResult(Database db,
                                 StreamFactory streamOpener,
                                 OrderingResult or,
                                 List<Relation<?>> ra,
                                 List<SettingsResult> sr)
                          throws IOException,
                                 UnableToComplyException
Throws:
IOException
UnableToComplyException

filenameFromLabel

private String filenameFromLabel(String label)
Derive a file name from the cluster label.

Parameters:
label - cluster label
Returns:
cleaned label suitable for file names.

Release 0.4.0 (2011-09-20_1324)