Class SSVFileWriter


  • public class SSVFileWriter
    extends CSVFileWriter
    CSVFileWriter subclass to write the SSV format:
    • Line feed (0x0A) is row separator
    • Field separator (0x1C) is column separator
    • No quote or escape characters are used
    • Carriage return (0x0D) represents embedded newline
    • Cell content is arbitrary binary except 0x0A, 0x1C (and NUL)
    Author:
    mirabilos (t.glaser@tarent.de)
    See Also:
    SSV at shellsnippets @ Evolvis
    • Constructor Detail

      • SSVFileWriter

        public SSVFileWriter​(String outputFileName)
                      throws IOException
        SSVFileWriter constructor just needing the name of the SSV file that will be written. The SSV file will be written in UTF-8 encoding.
        Parameters:
        outputFileName - The name of the SSV file to be opened for writing
        Throws:
        IOException - if an error occurs while creating the file
      • SSVFileWriter

        public SSVFileWriter​(Writer writer)
        SSVFileWriter constructor.
        Parameters:
        writer - The Writer to be opened for writing, which MUST be using an ASCII-compatible charset (such as UTF-8); we sadly cannot test that
    • Method Detail

      • setFieldSeparator

        public void setFieldSeparator​(char sep)
        Throws an exception, the field separator is constant for SSV.
        Overrides:
        setFieldSeparator in class CSVFile
        Parameters:
        sep - The new field separator to be ignored
      • setTextQualifier

        public void setTextQualifier​(char qual)
        Throws an exception, SSV has no quote character.
        Overrides:
        setTextQualifier in class CSVFile
        Parameters:
        qual - The new text qualifier to be ignored
      • getTextQualifier

        public char getTextQualifier()
        Throws an exception, SSV has no quote character.
        Overrides:
        getTextQualifier in class CSVFile
        Returns:
        The char containing the current text qualifier
      • emitRowSeparator

        protected void emitRowSeparator()
        Called after a list of fields has been output.
        Overrides:
        emitRowSeparator in class CSVFileWriter
      • prepareField

        protected String prepareField​(Object field)
        Prepares a field for output by stringifying the passed object according to SSV rules.
        Overrides:
        prepareField in class CSVFileWriter
        Parameters:
        field - to prepare
        Returns:
        string for output