Enum CsvParser.Feature
- java.lang.Object
-
- java.lang.Enum<CsvParser.Feature>
-
- com.fasterxml.jackson.dataformat.csv.CsvParser.Feature
-
- All Implemented Interfaces:
com.fasterxml.jackson.core.FormatFeature
,com.fasterxml.jackson.core.util.JacksonFeature
,java.io.Serializable
,java.lang.Comparable<CsvParser.Feature>
- Enclosing class:
- CsvParser
public static enum CsvParser.Feature extends java.lang.Enum<CsvParser.Feature> implements com.fasterxml.jackson.core.FormatFeature
Enumeration that defines all togglable features for CSV parsers
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALLOW_COMMENTS
Feature that allows accepting "hash comments" by default, similar toCsvSchema.withAllowComments(boolean)
.ALLOW_TRAILING_COMMA
Feature that allows there to be a trailing single extraneous data column that is empty.EMPTY_STRING_AS_NULL
Feature that enables coercing an emptyString
to `null`.EMPTY_UNQUOTED_STRING_AS_NULL
Feature that enables coercing an empty un-quotedString
to `null`.FAIL_ON_MISSING_COLUMNS
Feature that allows failing (with aCsvReadException
) in cases where number of column values encountered is less than number of columns declared in the active schema ("missing columns").FAIL_ON_MISSING_HEADER_COLUMNS
Feature that allows failing (with aCsvReadException
) in cases where number of header columns encountered is less than number of columns declared in the active schema (if there is one).IGNORE_TRAILING_UNMAPPABLE
Feature that allows ignoring of unmappable "extra" columns; that is, values for columns that appear after columns for which types are defined.INSERT_NULLS_FOR_MISSING_COLUMNS
Feature that allows "inserting" virtual key / `null` value pairs in case a row contains fewer columns than declared by configured schema.SKIP_EMPTY_LINES
Feature that allows skipping input lines that are completely empty or blank (composed only of whitespace), instead of being decoded as lines of just a single column with an empty/blank String value (or, of being decoded as lines of just a single column with empty String value (or, depending on binding, `null`).TRIM_SPACES
Feature determines whether spaces around separator characters (commas) are to be automatically trimmed before being reported or not.WRAP_AS_ARRAY
Feature that determines how stream of records (usually CSV lines, but sometimes multiple lines when linefeeds are included in quoted values) is exposed: either as a sequence of Objects (false), or as an Array of Objects (true).
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
_defaultState
(package private) int
_mask
-
Constructor Summary
Constructors Modifier Constructor Description private
Feature(boolean defaultState)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
collectDefaults()
Method that calculates bit set (flags) of all features that are enabled by default.boolean
enabledByDefault()
boolean
enabledIn(int flags)
int
getMask()
static CsvParser.Feature
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static CsvParser.Feature[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
TRIM_SPACES
public static final CsvParser.Feature TRIM_SPACES
Feature determines whether spaces around separator characters (commas) are to be automatically trimmed before being reported or not. Note that this does NOT force trimming of possible white space from within double-quoted values, but only those surrounding unquoted values (white space outside of double-quotes is never included regardless of trimming).Default value is false, as per RFC-4180.
-
WRAP_AS_ARRAY
public static final CsvParser.Feature WRAP_AS_ARRAY
Feature that determines how stream of records (usually CSV lines, but sometimes multiple lines when linefeeds are included in quoted values) is exposed: either as a sequence of Objects (false), or as an Array of Objects (true). Using stream of Objects is convenient when usingObjectMapper.readValues(...)
and array of Objects convenient when binding toList
s or arrays of values.Default value is false, meaning that by default a CSV document is exposed as a sequence of root-level Object entries.
-
IGNORE_TRAILING_UNMAPPABLE
public static final CsvParser.Feature IGNORE_TRAILING_UNMAPPABLE
Feature that allows ignoring of unmappable "extra" columns; that is, values for columns that appear after columns for which types are defined. When disabled, an exception is thrown for such column values, but if enabled, they are silently ignored.Feature is disabled by default.
- Since:
- 2.7
-
SKIP_EMPTY_LINES
public static final CsvParser.Feature SKIP_EMPTY_LINES
Feature that allows skipping input lines that are completely empty or blank (composed only of whitespace), instead of being decoded as lines of just a single column with an empty/blank String value (or, of being decoded as lines of just a single column with empty String value (or, depending on binding, `null`).Feature is disabled by default.
- Since:
- 2.10
-
ALLOW_TRAILING_COMMA
public static final CsvParser.Feature ALLOW_TRAILING_COMMA
Feature that allows there to be a trailing single extraneous data column that is empty. When this feature is disabled, any extraneous column, regardless of content will cause an exception to be thrown. Disabling this feature is only useful when IGNORE_TRAILING_UNMAPPABLE is also disabled.
-
ALLOW_COMMENTS
public static final CsvParser.Feature ALLOW_COMMENTS
Feature that allows accepting "hash comments" by default, similar toCsvSchema.withAllowComments(boolean)
. If enabled, such comments are by default allowed on all columns of all documents.- Since:
- 2.10
-
FAIL_ON_MISSING_COLUMNS
public static final CsvParser.Feature FAIL_ON_MISSING_COLUMNS
Feature that allows failing (with aCsvReadException
) in cases where number of column values encountered is less than number of columns declared in the active schema ("missing columns").Note that this feature has precedence over
INSERT_NULLS_FOR_MISSING_COLUMNS
Feature is disabled by default.
- Since:
- 2.9
-
FAIL_ON_MISSING_HEADER_COLUMNS
public static final CsvParser.Feature FAIL_ON_MISSING_HEADER_COLUMNS
Feature that allows failing (with aCsvReadException
) in cases where number of header columns encountered is less than number of columns declared in the active schema (if there is one).Feature is enabled by default
- Since:
- 2.14
-
INSERT_NULLS_FOR_MISSING_COLUMNS
public static final CsvParser.Feature INSERT_NULLS_FOR_MISSING_COLUMNS
Feature that allows "inserting" virtual key / `null` value pairs in case a row contains fewer columns than declared by configured schema. This typically has the effect of forcing an explicit `null` assigment (or corresponding "null value", if so configured) at databinding level. If disabled, no extra work is done and values for "missing" columns are not exposed as part of the token stream.Note that this feature is only considered if
FAIL_ON_MISSING_COLUMNS
is disabled.Feature is disabled by default.
- Since:
- 2.9
-
EMPTY_STRING_AS_NULL
public static final CsvParser.Feature EMPTY_STRING_AS_NULL
Feature that enables coercing an emptyString
to `null`.Note that if this setting is enabled,
EMPTY_UNQUOTED_STRING_AS_NULL
has no effect. Feature is disabled by default for backwards compatibility.
-
EMPTY_UNQUOTED_STRING_AS_NULL
public static final CsvParser.Feature EMPTY_UNQUOTED_STRING_AS_NULL
Feature that enables coercing an empty un-quotedString
to `null`. This feature allow differentiating between an empty quotedString
and an empty un-quotedString
.Note that this feature is only considered if
EMPTY_STRING_AS_NULL
is disabled.Feature is disabled by default for backwards compatibility.
- Since:
- 2.18
-
-
Method Detail
-
values
public static CsvParser.Feature[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CsvParser.Feature c : CsvParser.Feature.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CsvParser.Feature valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.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.
-
enabledByDefault
public boolean enabledByDefault()
- Specified by:
enabledByDefault
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
enabledByDefault
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
enabledIn
public boolean enabledIn(int flags)
- Specified by:
enabledIn
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
enabledIn
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
getMask
public int getMask()
- Specified by:
getMask
in interfacecom.fasterxml.jackson.core.FormatFeature
- Specified by:
getMask
in interfacecom.fasterxml.jackson.core.util.JacksonFeature
-
-