Class DefaultCsvEncoder

  • All Implemented Interfaces:
    CsvEncoder
    Direct Known Subclasses:
    SelectiveCsvEncoder

    public class DefaultCsvEncoder
    extends java.lang.Object
    implements CsvEncoder
    The default CsvEncoder implementation.
    Since:
    2.1.0
    Author:
    James Bassett
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCsvEncoder()
      Constructs a new DefaultCsvEncoder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String encode​(java.lang.String input, CsvContext context, CsvPreference preference)
      Encodes a String to be written to a CSV file.
      • Methods inherited from class java.lang.Object

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

      • DefaultCsvEncoder

        public DefaultCsvEncoder()
        Constructs a new DefaultCsvEncoder.
    • Method Detail

      • encode

        public java.lang.String encode​(java.lang.String input,
                                       CsvContext context,
                                       CsvPreference preference)
        Encodes a String to be written to a CSV file. The encoder should honour all CSV preferences including updating the current lineNumber (in the CSV context - it will be updated in the calling CsvWriter after encoding has completed) as line terminators are encountered in the String to be escaped (converting all 3 variations of line terminators to the end of line symbols specified in the preferences). The CsvContext can also be used to encode based on the current context (e.g. you may want to always put quotes around a particular column).
        Specified by:
        encode in interface CsvEncoder
        Parameters:
        input - the String to be encoded
        context - the context
        preference - the CSV preferences
        Returns:
        the encoded CSV