Enum Class CsvWriteFeature

java.lang.Object
java.lang.Enum<CsvWriteFeature>
tools.jackson.dataformat.csv.CsvWriteFeature
All Implemented Interfaces:
Serializable, Comparable<CsvWriteFeature>, Constable, tools.jackson.core.FormatFeature, tools.jackson.core.util.JacksonFeature

public enum CsvWriteFeature extends Enum<CsvWriteFeature> implements tools.jackson.core.FormatFeature
Enumeration that defines all togglable features for CSV writers

NOTE: in Jackson 2.x this was named CsvGenerator.Feature.

  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Feature that determines whether values written as empty Strings (from java.lang.String valued POJO properties) should be forced to be quoted.
    Feature that determines whether values written as Nymbers (from java.lang.Number valued POJO properties) should be forced to be quoted, regardless of whether they actually need this.
    Feature that determines whether values written as Strings (from java.lang.String valued POJO properties) should be forced to be quoted, regardless of whether they actually need this.
    Feature that determines whether control characters (non-printable) are escaped using the configured escape character.
    Feature that determines whether quote characters within quoted String values are escaped using configured escape character, instead of being "doubled up" (that is: a quote character is written twice in a row).
    Feature that determines whether columns without matching value may be omitted, when they are the last values of the row.
    Feature that determines how much work is done before determining that a column value requires quoting: when set as true, full check is made to only use quoting when it is strictly necessary; but when false, a faster but more conservative check is made, and possibly quoting is used for values that might not need it.
    Feature that determines whether a line-feed will be written at the end of content, after the last row of output.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final boolean
     
    private final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    CsvWriteFeature(boolean defaultState)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Method that calculates bit set (flags) of all features that are enabled by default.
    boolean
     
    boolean
    enabledIn(int flags)
     
    int
     
    Returns the enum constant of this class with the specified name.
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • STRICT_CHECK_FOR_QUOTING

      public static final CsvWriteFeature STRICT_CHECK_FOR_QUOTING
      Feature that determines how much work is done before determining that a column value requires quoting: when set as true, full check is made to only use quoting when it is strictly necessary; but when false, a faster but more conservative check is made, and possibly quoting is used for values that might not need it. Trade-off is basically between optimal/minimal quoting (true), and faster handling (false). Faster check involves only checking first N characters of value, as well as possible looser checks.

      Note, however, that regardless setting, all values that need to be quoted will be: it is just that when set to false, other values may also be quoted (to avoid having to do more expensive checks).

      Default value is false for "loose" (approximate, conservative) checking.

    • OMIT_MISSING_TAIL_COLUMNS

      public static final CsvWriteFeature OMIT_MISSING_TAIL_COLUMNS
      Feature that determines whether columns without matching value may be omitted, when they are the last values of the row. If true, values and separators between values may be omitted, to slightly reduce length of the row; if false, separators need to stay in place and values are indicated by empty Strings.
    • ALWAYS_QUOTE_STRINGS

      public static final CsvWriteFeature ALWAYS_QUOTE_STRINGS
      Feature that determines whether values written as Strings (from java.lang.String valued POJO properties) should be forced to be quoted, regardless of whether they actually need this. Note that this feature has precedence over STRICT_CHECK_FOR_QUOTING, when both would be applicable. Note that this setting does NOT affect quoting of typed values like Numbers or Booleans.
    • ALWAYS_QUOTE_EMPTY_STRINGS

      public static final CsvWriteFeature ALWAYS_QUOTE_EMPTY_STRINGS
      Feature that determines whether values written as empty Strings (from java.lang.String valued POJO properties) should be forced to be quoted.
    • ALWAYS_QUOTE_NUMBERS

      public static final CsvWriteFeature ALWAYS_QUOTE_NUMBERS
      Feature that determines whether values written as Nymbers (from java.lang.Number valued POJO properties) should be forced to be quoted, regardless of whether they actually need this.
    • ESCAPE_QUOTE_CHAR_WITH_ESCAPE_CHAR

      public static final CsvWriteFeature ESCAPE_QUOTE_CHAR_WITH_ESCAPE_CHAR
      Feature that determines whether quote characters within quoted String values are escaped using configured escape character, instead of being "doubled up" (that is: a quote character is written twice in a row).

      Default value is false so that quotes are doubled as necessary, not escaped.

    • ESCAPE_CONTROL_CHARS_WITH_ESCAPE_CHAR

      public static final CsvWriteFeature ESCAPE_CONTROL_CHARS_WITH_ESCAPE_CHAR
      Feature that determines whether control characters (non-printable) are escaped using the configured escape character. This feature allows LF and CR characters to be output as
      \n
      and
      \r
      instead of being echoed out. This is a compatibility feature for some parsers that can not read such output back in.

      Default value is false so that control characters are echoed out (backwards compatible).

    • WRITE_LINEFEED_AFTER_LAST_ROW

      public static final CsvWriteFeature WRITE_LINEFEED_AFTER_LAST_ROW
      Feature that determines whether a line-feed will be written at the end of content, after the last row of output.

      NOTE! When disabling this feature it is important that CsvGenerator.flush() is NOT called before CsvGenerator.close() is called; the current implementation relies on ability to essentially remove the last linefeed that was appended in the output buffer.

      Default value is true so all rows, including the last, are terminated by a line feed.

  • Field Details

    • _defaultState

      private final boolean _defaultState
    • _mask

      private final int _mask
  • Constructor Details

    • CsvWriteFeature

      private CsvWriteFeature(boolean defaultState)
  • Method Details

    • values

      public static CsvWriteFeature[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CsvWriteFeature valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • collectDefaults

      public static int collectDefaults()
      Method that calculates bit set (flags) of all features that are enabled by default.
    • enabledIn

      public boolean enabledIn(int flags)
      Specified by:
      enabledIn in interface tools.jackson.core.util.JacksonFeature
    • enabledByDefault

      public boolean enabledByDefault()
      Specified by:
      enabledByDefault in interface tools.jackson.core.util.JacksonFeature
    • getMask

      public int getMask()
      Specified by:
      getMask in interface tools.jackson.core.util.JacksonFeature