Top Description Methods
com.fasterxml.jackson.dataformat.csv

public Interface CsvValueDecorator

Known Direct Implementers
com.fasterxml.jackson.dataformat.csv.CsvValueDecorators.StringPrefixSuffixDecorator
Imports
java.io.IOException

Interface defining API for handlers that can add and remove "decorations" to CSV values: for example, brackets around Array (List) values encoded in a single physical String column.

Decorations are handled after handling other encoding aspects such as optional quoting and/or escaping.

Decorators can be registered on specific columns of CsvSchema.

Since
2.18

Method Summary

Modifier and TypeMethod and Description
public default String

Returns:

Decorated value to use, IF NOT null: if null will use default null replacement value.
decorateNull
(CsvGenerator
Generator that will be used for actual serialization
gen
)

Method called instead of decorateValue in case where value being written is from Java null value: this is often left as-is, without decoration (and this is the default implementation), but may be decorated.

public String

Returns:

Decorated value (which may be plainValue as-is) but Must Not be null
decorateValue
(CsvGenerator
Generator that will be used for actual serialization
gen
,
String
Value to decorate
plainValue
)

Method called during serialization when encoding a value, to produce "decorated" value to include in output (possibly escaped and/or quoted).

public String

Returns:

Value after removing decorations, if any.
undecorateValue
(CsvParser
Parser that was used to decode textual value from input
parser
,
String
Value from which to remove decorations, if any (some decorators can allow optional decorations; others may fail if none found)
decoratedValue
)

Method called during deserialization, to remove possible decoration applied with decorateValue.

Method Detail

decorateNullback to summary
public default String decorateNull(CsvGenerator gen) throws IOException

Method called instead of decorateValue in case where value being written is from Java null value: this is often left as-is, without decoration (and this is the default implementation), but may be decorated. To let default Null Value Replacement be used, should return null: this is the default implementation.

Parameters
gen:CsvGenerator

Generator that will be used for actual serialization

Returns:String

Decorated value to use, IF NOT null: if null will use default null replacement value.

Exceptions
IOException:
if attempt to decorate the value somehow fails (typically a com.fasterxml.jackson.core.exc.StreamWriteException)
decorateValueback to summary
public String decorateValue(CsvGenerator gen, String plainValue) throws IOException

Method called during serialization when encoding a value, to produce "decorated" value to include in output (possibly escaped and/or quoted). Note that possible escaping and/or quoting (as per configuration of CsvSchema is applied on decorated value.

Parameters
gen:CsvGenerator

Generator that will be used for actual serialization

plainValue:String

Value to decorate

Returns:String

Decorated value (which may be plainValue as-is) but Must Not be null

Exceptions
IOException:
if attempt to decorate the value somehow fails (typically a com.fasterxml.jackson.core.exc.StreamWriteException)
undecorateValueback to summary
public String undecorateValue(CsvParser parser, String decoratedValue) throws IOException

Method called during deserialization, to remove possible decoration applied with decorateValue. Call is made after textual value for a cell (column value) has been read using parser and after removing (decoding) possible quoting and/or escaping of the value. Value passed in has no escaping or quoting left.

Parameters
parser:CsvParser

Parser that was used to decode textual value from input

decoratedValue:String

Value from which to remove decorations, if any (some decorators can allow optional decorations; others may fail if none found)

Returns:String

Value after removing decorations, if any.

Exceptions
IOException:
if attempt to un-decorate the value fails (typically a com.fasterxml.jackson.core.exc.StreamReadException)