Interface CsvValueDecorator
- All Known Implementing Classes:
CsvValueDecorators.StringPrefixSuffixDecorator
public interface CsvValueDecorator
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 TypeMethodDescriptiondefault StringdecorateNull(CsvGenerator gen) Method called instead ofdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String)in case where value being written is from Javanullvalue: this is often left as-is, without decoration (and this is the default implementation), but may be decorated.decorateValue(CsvGenerator gen, String plainValue) Method called during serialization when encoding a value, to produce "decorated" value to include in output (possibly escaped and/or quoted).undecorateValue(CsvParser parser, String decoratedValue) Method called during deserialization, to remove possible decoration applied withdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String).
-
Method Details
-
decorateValue
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 ofCsvSchemais applied on decorated value.- Parameters:
gen- Generator that will be used for actual serializationplainValue- Value to decorate- Returns:
- Decorated value (which may be
plainValueas-is) but Must Not benull - Throws:
IOException- if attempt to decorate the value somehow fails (typically aStreamWriteException)
-
decorateNull
Method called instead ofdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String)in case where value being written is from Javanullvalue: 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 returnnull: this is the default implementation.- Parameters:
gen- Generator that will be used for actual serialization- Returns:
- Decorated value to use, IF NOT
null: ifnullwill use default null replacement value. - Throws:
IOException- if attempt to decorate the value somehow fails (typically aStreamWriteException)
-
undecorateValue
Method called during deserialization, to remove possible decoration applied withdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String). Call is made after textual value for a cell (column value) has been read usingparserand after removing (decoding) possible quoting and/or escaping of the value. Value passed in has no escaping or quoting left.- Parameters:
parser- Parser that was used to decode textual value from inputdecoratedValue- Value from which to remove decorations, if any (some decorators can allow optional decorations; others may fail if none found)- Returns:
- Value after removing decorations, if any.
- Throws:
IOException- if attempt to un-decorate the value fails (typically aStreamReadException)
-