Class 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 Detail

      • FILE_EXTENSION

        public static final java.lang.String FILE_EXTENSION
        Extension for txt-files.
        See Also:
        Constant Field Values
      • filenames

        protected java.util.Map<java.lang.String,​java.lang.Object> filenames
        For producing unique filenames.
    • Constructor Detail

      • TextWriter

        public TextWriter()
    • 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 print
        filenamepre - 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 object
        r - Result class
        streamOpener - output stream manager
        filter - Filter pattern
        Throws:
        java.io.IOException - on IO error
      • writeIterableResult

        private void writeIterableResult​(StreamFactory streamOpener,
                                         IterableResult<?> ri)
                                  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.