Class DelimitedOutput

java.lang.Object
com.invirgance.convirgance.output.DelimitedOutput
All Implemented Interfaces:
Output
Direct Known Subclasses:
PipeDelimitedOutput, TabDelimitedOutput

@Wiring public class DelimitedOutput extends Object implements Output
Support for writing delimited file formats like tab delimited and pipe delimited formats. Note that this format does not protect against delimiters appearing in the data. If you are writing a command-delimited file, it is recommended to use CSVOutput instead.
Author:
jbanes
See Also:
  • Constructor Details

    • DelimitedOutput

      public DelimitedOutput()
      Creates a new DelimitedOutput defaulting to the pipe character '|'.
    • DelimitedOutput

      public DelimitedOutput(char delimiter)
      Creates a new DelimitedOutput using the provided character to delimit content
      Parameters:
      delimiter - the delimiting character
    • DelimitedOutput

      public DelimitedOutput(String... columns)
      Creates a DelimitedOuput with specified columns defaulting to the pipe character '|'
      Parameters:
      columns - A String array of column names.
    • DelimitedOutput

      public DelimitedOutput(String[] columns, char delimiter)
      Creates a DelimitedOuput with specified columns and delimiter
      Parameters:
      columns - an array of column names.
      delimiter - the character to delimit on
  • Method Details

    • getDelimiter

      public char getDelimiter()
      Gets the current character used when writing delimited output
      Returns:
      the delimiting character
    • setDelimiter

      public void setDelimiter(char delimiter)
      Sets the character to use when writing delimited content
      Parameters:
      delimiter - the delimiter character
    • getEncoding

      public String getEncoding()
      Gets the current text encoding. Default encoding is "UTF-8".
      Returns:
      the current text encoding format
    • setEncoding

      public void setEncoding(String encoding)
      Set the text encoding format. This will override the default of "UTF-8".
      Parameters:
      encoding - text encoding format
    • write

      public OutputCursor write(Target target)
      Creates a new writer to output delimited data to the specified target. Uses the current column definitions of this object to format the output.
      Specified by:
      write in interface Output
      Parameters:
      target - the target writeable output stream
      Returns:
      the OutputCursor to write delimited data
    • getContentType

      public String getContentType()
      Returns text/plain for most delimiters. The exception is a comma which returns text/csv instead.
      Specified by:
      getContentType in interface Output
      Returns:
      the MIME type for this format