Class TextWriterStream


  • public class TextWriterStream
    extends java.lang.Object
    Representation of an output stream to a text file.
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.StringBuilder comment
      Buffer for comment data to output.
      static java.lang.String COMMENTSEP
      Comment separator line.
      private TextWriterWriterInterface<?> fallbackwriter
      Fallback writer, using toString.
      private java.lang.StringBuilder inline
      Buffer for inline data to output.
      private static java.lang.String NEWLINE
      System newline character(s)
      private java.io.PrintStream outStream
      Actual stream to write to.
      static java.lang.String QUOTE
      String to separate different entries while printing.
      static java.lang.String SEPARATOR
      String to separate different entries while printing.
      static java.lang.String SER_MARKER
      Marker used in text serialization (and re-parsing)
      private HandlerList<TextWriterWriterInterface<?>> writers
      Handlers for various object types.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void commentPrint​(java.lang.CharSequence line)
      Print an object into the comments section
      void commentPrint​(java.lang.Object line)
      Print an object into the comments section
      void commentPrintLn()
      Print a newline into the comments section.
      void commentPrintLn​(java.lang.CharSequence line)
      Print an object into the comments section with trailing newline.
      void commentPrintLn​(java.lang.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​(java.lang.Object o)
      Retrieve an appropriate writer from the handler list.
      void inlinePrint​(java.lang.Object o)
      Print data into the inline part of the file.
      void inlinePrintNoQuotes​(java.lang.Object o)
      Print data into the inline part of the file WITHOUT checking for separators (and thus quoting).
      private void quotePrintln​(java.io.PrintStream outStream, java.lang.String data)
      Quoted println.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outStream

        private java.io.PrintStream outStream
        Actual stream to write to.
      • inline

        private java.lang.StringBuilder inline
        Buffer for inline data to output.
      • comment

        private java.lang.StringBuilder comment
        Buffer for comment data to output.
      • SEPARATOR

        public static final java.lang.String SEPARATOR
        String to separate different entries while printing.
        See Also:
        Constant Field Values
      • QUOTE

        public static final java.lang.String QUOTE
        String to separate different entries while printing.
        See Also:
        Constant Field Values
      • COMMENTSEP

        public static final java.lang.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 java.lang.String NEWLINE
        System newline character(s)
      • SER_MARKER

        public static final java.lang.String SER_MARKER
        Marker used in text serialization (and re-parsing)
        See Also:
        Constant Field Values
    • Method Detail

      • commentPrint

        public void commentPrint​(java.lang.Object line)
        Print an object into the comments section
        Parameters:
        line - object to print into commments
      • commentPrint

        public void commentPrint​(java.lang.CharSequence line)
        Print an object into the comments section
        Parameters:
        line - object to print into commments
      • commentPrintLn

        public void commentPrintLn​(java.lang.CharSequence line)
        Print an object into the comments section with trailing newline.
        Parameters:
        line - object to print into comments
      • commentPrintLn

        public void commentPrintLn​(java.lang.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​(java.lang.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​(java.lang.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​(java.io.PrintStream outStream,
                                  java.lang.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​(java.lang.Object o)
        Retrieve an appropriate writer from the handler list.
        Parameters:
        o - query object
        Returns:
        appropriate write, if available