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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.String
decorateNull(CsvGenerator gen)
Method called instead ofdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String)
in case where value being written is from Javanull
value: this is often left as-is, without decoration (and this is the default implementation), but may be decorated.java.lang.String
decorateValue(CsvGenerator gen, java.lang.String plainValue)
Method called during serialization when encoding a value, to produce "decorated" value to include in output (possibly escaped and/or quoted).java.lang.String
undecorateValue(CsvParser parser, java.lang.String decoratedValue)
Method called during deserialization, to remove possible decoration applied withdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String)
.
-
-
-
Method Detail
-
decorateValue
java.lang.String decorateValue(CsvGenerator gen, java.lang.String plainValue) throws java.io.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 ofCsvSchema
is applied on decorated value.- Parameters:
gen
- Generator that will be used for actual serializationplainValue
- Value to decorate- Returns:
- Decorated value (which may be
plainValue
as-is) but Must Not benull
- Throws:
java.io.IOException
- if attempt to decorate the value somehow fails (typically aStreamWriteException
)
-
decorateNull
default java.lang.String decorateNull(CsvGenerator gen) throws java.io.IOException
Method called instead ofdecorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String)
in case where value being written is from Javanull
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 returnnull
: this is the default implementation.- Parameters:
gen
- Generator that will be used for actual serialization- Returns:
- Decorated value to use, IF NOT
null
: ifnull
will use default null replacement value. - Throws:
java.io.IOException
- if attempt to decorate the value somehow fails (typically aStreamWriteException
)
-
undecorateValue
java.lang.String undecorateValue(CsvParser parser, java.lang.String decoratedValue) throws java.io.IOException
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 usingparser
and 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:
java.io.IOException
- if attempt to un-decorate the value fails (typically aStreamReadException
)
-
-