Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.dataformat.csv

public Class CsvValueDecorators

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.Objects

Container class for default CsvValueDecorator implementations
Since
2.18

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CsvValueDecorators.StringPrefixSuffixDecorator

Decorated that adds static prefix and suffix around value to decorate value; removes the same when un-decorating.

Field Summary

Modifier and TypeField and Description
public static final CsvValueDecorator
OPTIONAL_BRACKETS_DECORATOR

StringPrefixSuffixDecorator that uses square brackets ([]) around decorated value, but does not require their use (removes if used, ignores it not).

public static final CsvValueDecorator
STRICT_BRACKETS_DECORATOR

StringPrefixSuffixDecorator that uses square brackets ([]) around decorated value, and requires their use (if value has no matching decoration, an exception is thrown when attempting to read the value).

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static CsvValueDecorator
optionalPrefixSuffixDecorator(String prefix, String suffix)

Factory method for constructing a StringPrefixSuffixDecorator with given prefix and suffix, both optional.

public static CsvValueDecorator
requiredPrefixSuffixDecorator(String prefix, String suffix)

Factory method for constructing a StringPrefixSuffixDecorator with given prefix and suffix, both required.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

OPTIONAL_BRACKETS_DECORATORback to summary
public static final CsvValueDecorator OPTIONAL_BRACKETS_DECORATOR

StringPrefixSuffixDecorator that uses square brackets ([]) around decorated value, but does not require their use (removes if used, ignores it not).

STRICT_BRACKETS_DECORATORback to summary
public static final CsvValueDecorator STRICT_BRACKETS_DECORATOR

StringPrefixSuffixDecorator that uses square brackets ([]) around decorated value, and requires their use (if value has no matching decoration, an exception is thrown when attempting to read the value).

Constructor Detail

CsvValueDecoratorsback to summary
public CsvValueDecorators()

Method Detail

optionalPrefixSuffixDecoratorback to summary
public static CsvValueDecorator optionalPrefixSuffixDecorator(String prefix, String suffix)

Factory method for constructing a StringPrefixSuffixDecorator with given prefix and suffix, both optional.

requiredPrefixSuffixDecoratorback to summary
public static CsvValueDecorator requiredPrefixSuffixDecorator(String prefix, String suffix)

Factory method for constructing a StringPrefixSuffixDecorator with given prefix and suffix, both required.

com.fasterxml.jackson.dataformat.csv back to summary

public Class CsvValueDecorators.StringPrefixSuffixDecorator

extends Object
implements CsvValueDecorator
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.dataformat.csv.CsvValueDecorators.StringPrefixSuffixDecorator
All Implemented Interfaces
com.fasterxml.jackson.dataformat.csv.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#StringPrefixSuffixDecorator).

Field Summary

Modifier and TypeField and Description
protected final boolean
_optional

Whether 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 String
_prefix

Decoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket [ .

protected final String
_suffix

Decoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket ] .

Constructor Summary

AccessConstructor and Description
public
StringPrefixSuffixDecorator(String prefix, String suffix, boolean optional)

Method Summary

Modifier and TypeMethod and Description
public String
decorateValue(CsvGenerator
Generator that will be used for actual serialization
gen
,
String
Value to decorate
plainValue
)

Implements com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.decorateValue.

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

public String
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
)

Implements com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.undecorateValue.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_optionalback to summary
protected final boolean _optional

Whether 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.

_prefixback to summary
protected final String _prefix

Decoration added before value being decorated: for example, if decorating with brackets, this would be opening bracket [ .

_suffixback to summary
protected final String _suffix

Decoration added after value being decorated: for example, if decorating with brackets, this would be closing bracket ] .

Constructor Detail

StringPrefixSuffixDecoratorback to summary
public StringPrefixSuffixDecorator(String prefix, String suffix, boolean optional)

Method Detail

decorateValueback to summary
public String decorateValue(CsvGenerator gen, String plainValue) throws IOException

Implements com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.decorateValue.

Doc from com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.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 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

Annotations
@Override
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

Implements com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.undecorateValue.

Doc from com.fasterxml.jackson.dataformat.csv.CsvValueDecorator.undecorateValue.

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.

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