Class CsvValueDecorators.StringPrefixSuffixDecorator
java.lang.Object
com.fasterxml.jackson.dataformat.csv.CsvValueDecorators.StringPrefixSuffixDecorator
- All Implemented Interfaces:
CsvValueDecorator
- Enclosing class:
CsvValueDecorators
public static class CsvValueDecorators.StringPrefixSuffixDecorator
extends Object
implements CsvValueDecorator
Decorated that adds static prefix and suffix around value to decorate value;
removes the same when un-decorating. Handling of the case where decoration
is missing on deserialization (reading) depends on where decorator is
created with "optional" or "strict" setting
(see
StringPrefixSuffixDecorator(java.lang.String, java.lang.String, boolean)).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanWhether existence of prefix and suffix decoration is optional (true) or required (false): if required and value does does not have decorations, deserialization (reading) will fail with an exception; if optional value is exposed as is.protected final StringDecoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket[.protected final StringDecoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket]. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondecorateValue(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 withCsvValueDecorator.decorateValue(com.fasterxml.jackson.dataformat.csv.CsvGenerator, java.lang.String).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.fasterxml.jackson.dataformat.csv.CsvValueDecorator
decorateNull
-
Field Details
-
_prefix
Decoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket[. -
_suffix
Decoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket]. -
_optional
protected final boolean _optionalWhether existence of prefix and suffix decoration is optional (true) or required (false): if required and value does does not have decorations, deserialization (reading) will fail with an exception; if optional value is exposed as is.
-
-
Constructor Details
-
StringPrefixSuffixDecorator
-
-
Method Details
-
decorateValue
Description copied from interface:CsvValueDecoratorMethod 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.- Specified by:
decorateValuein interfaceCsvValueDecorator- 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)
-
undecorateValue
Description copied from interface:CsvValueDecoratorMethod called during deserialization, to remove possible decoration applied withCsvValueDecorator.decorateValue(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.- Specified by:
undecorateValuein interfaceCsvValueDecorator- 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)
-