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

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

public class TextWriterStream
extends Object

Representation of an output stream to a text file.


Field Summary
private  StringBuffer comment
          Buffer for comment data to output.
static String COMMENTSEP
          Comment separator line.
private  boolean forceincomments
          Force incomments flag
private  StringBuffer inline
          Buffer for inline data to output.
private static String NEWLINE
          System newline character(s)
private  PrintStream outStream
          Actual stream to write to.
static String QUOTE
          String to separate different entries while printing.
static String SEPARATOR
          String to separate different entries while printing.
static String SER_MARKER
          Marker used in text serialization (and re-parsing)
private  HandlerList<TextWriterWriterInterface<?>> writers
          Handlers for various object types.
 
Constructor Summary
TextWriterStream(PrintStream out, HandlerList<TextWriterWriterInterface<?>> writers)
          Constructor.
 
Method Summary
 void commentPrint(Object line)
          Print an object into the comments section
 void commentPrintLn()
          Print a newline into the comments section.
 void commentPrintLn(Object line)
          Print an object into the comments section with trailing newline.
 void commentPrintSeparator()
          Print a separator line in the comments section.
 void flush()
          Flush output: write inline data, then write comment section.
 TextWriterWriterInterface<?> getWriterFor(Object o)
          Retrieve an appropriate writer from the handler list.
 void inlinePrint(Object o)
          Print data into the inline part of the file.
 void inlinePrintNoQuotes(Object o)
          Print data into the inline part of the file WITHOUT checking for separators (and thus quoting).
protected  boolean isForceincomments()
          Test force-in-comments flag.
<O> O
normalizationRestore(O v)
          Restore a vector undoing any normalization that was applied.
private  void quotePrintln(PrintStream outStream, String data)
          Quoted println.
protected  void setForceincomments(boolean forceincomments)
          Set the force-in-comments flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outStream

private PrintStream outStream
Actual stream to write to.


inline

private StringBuffer inline
Buffer for inline data to output.


comment

private StringBuffer comment
Buffer for comment data to output.


writers

private HandlerList<TextWriterWriterInterface<?>> writers
Handlers for various object types.


SEPARATOR

public static final String SEPARATOR
String to separate different entries while printing.

See Also:
Constant Field Values

QUOTE

public static final String QUOTE
String to separate different entries while printing.

See Also:
Constant Field Values

COMMENTSEP

public static final String COMMENTSEP
Comment separator line. Since this will be printed without QUOTE infront, it should be quoted string itself.

See Also:
Constant Field Values

NEWLINE

private static final String NEWLINE
System newline character(s)


SER_MARKER

public static final String SER_MARKER
Marker used in text serialization (and re-parsing)

See Also:
Constant Field Values

forceincomments

private boolean forceincomments
Force incomments flag

Constructor Detail

TextWriterStream

public TextWriterStream(PrintStream out,
                        HandlerList<TextWriterWriterInterface<?>> writers)
Constructor.

Parameters:
out - Actual stream to write to
writers - Handlers for various data types
Method Detail

commentPrint

public void commentPrint(Object line)
Print an object into the comments section

Parameters:
line - object to print into commments

commentPrintLn

public void commentPrintLn(Object line)
Print an object into the comments section with trailing newline.

Parameters:
line - object to print into comments

commentPrintLn

public void commentPrintLn()
Print a newline into the comments section.


commentPrintSeparator

public void commentPrintSeparator()
Print a separator line in the comments section.


inlinePrint

public void inlinePrint(Object o)
Print data into the inline part of the file. Data is sanitized: newlines are replaced with spaces, and text containing separators is put in quotes. Quotes and escape characters are escaped.

Parameters:
o - object to print

inlinePrintNoQuotes

public void inlinePrintNoQuotes(Object o)
Print data into the inline part of the file WITHOUT checking for separators (and thus quoting).

Parameters:
o - object to print.

flush

public void flush()
Flush output: write inline data, then write comment section. Reset streams.


quotePrintln

private void quotePrintln(PrintStream outStream,
                          String data)
Quoted println. All lines written will be prefixed with QUOTE

Parameters:
outStream - output stream to write to
data - data to print

getWriterFor

public TextWriterWriterInterface<?> getWriterFor(Object o)
Retrieve an appropriate writer from the handler list.

Parameters:
o - query object
Returns:
appropriate write, if available

normalizationRestore

public <O> O normalizationRestore(O v)
Restore a vector undoing any normalization that was applied. (This class does not support normalization, it is only provided by derived classes, which will then have to use generics.)

Type Parameters:
O - Object class
Parameters:
v - vector to restore
Returns:
restored value.

isForceincomments

protected boolean isForceincomments()
Test force-in-comments flag.

Returns:
flag value

setForceincomments

protected void setForceincomments(boolean forceincomments)
Set the force-in-comments flag.

Parameters:
forceincomments - the new flag value

Release 0.4.0 (2011-09-20_1324)