Top Description Fields Constructors Methods
org.springframework.core.codec

public abstract Class AbstractCharSequenceDecoder<T extends java.lang.CharSequence>

extends AbstractDataBufferDecoder<T extends CharSequence>
Class Inheritance
Known Direct Subclasses
org.springframework.core.codec.CharBufferDecoder, org.springframework.core.codec.StringDecoder
Type Parameters
<T>
the character sequence type
Imports
java.nio.charset.Charset, .StandardCharsets, java.util.ArrayList, .Collection, .Collections, .List, .Map, java.util.concurrent.ConcurrentHashMap, .ConcurrentMap, org.reactivestreams.Publisher, reactor.core.publisher.Flux, .Mono, org.springframework.core.ResolvableType, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, .LimitedDataBufferList, org.springframework.core.log.LogFormatUtils, org.springframework.lang.Nullable, org.springframework.util.Assert, .MimeType

Abstract base class that decodes from a data buffer stream to a CharSequence stream.
Author
Arjen Poutsma
Since
6.1

Field Summary

Modifier and TypeField and Description
public static final Charset
DEFAULT_CHARSET

The default charset to use, i.e. "UTF-8".

public static final List<String>
DEFAULT_DELIMITERS

The default delimiter strings to use, i.e. \r\n and \n.

private Charset
private final List<String>
private final ConcurrentMap<Charset, byte[][]>
private final boolean

Constructor Summary

AccessConstructor and Description
protected
AbstractCharSequenceDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)

Create a new AbstractCharSequenceDecoder with the given parameters.

Method Summary

Modifier and TypeMethod and Description
public final Flux<T>
decode(Publisher<DataBuffer>
the DataBuffer input stream to decode
input
,
ResolvableType
the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.
elementType
,
MimeType
the MIME type associated with the input stream (optional)
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Overrides org.springframework.core.codec.AbstractDataBufferDecoder.decode.

Implements org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.
public final T
decode(DataBuffer
the DataBuffer to decode
dataBuffer
,
ResolvableType
the expected output type
elementType
,
MimeType
the MIME type associated with the data
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Overrides default org.springframework.core.codec.Decoder.decode.

Decode a data buffer to an Object of type T.
protected abstract T
decodeInternal(DataBuffer dataBuffer, Charset charset)

Template method that decodes the given data buffer into T, given the charset.

private Charset
getCharset(MimeType mimeType)

public Charset
getDefaultCharset()

Return the configured defaultCharset.

private byte[][]
private Collection<DataBuffer>
public void
setDefaultCharset(Charset
the charset to fall back on
defaultCharset
)

Set the default character set to fall back on if the MimeType does not specify any.

Inherited from org.springframework.core.codec.AbstractDataBufferDecoder:
decodeDataBufferdecodeToMonogetMaxInMemorySizesetMaxInMemorySize

Field Detail

DEFAULT_CHARSETback to summary
public static final Charset DEFAULT_CHARSET

The default charset to use, i.e. "UTF-8".

DEFAULT_DELIMITERSback to summary
public static final List<String> DEFAULT_DELIMITERS

The default delimiter strings to use, i.e. \r\n and \n.

defaultCharsetback to summary
private Charset defaultCharset
delimitersback to summary
private final List<String> delimiters
delimitersCacheback to summary
private final ConcurrentMap<Charset, byte[][]> delimitersCache
stripDelimiterback to summary
private final boolean stripDelimiter

Constructor Detail

AbstractCharSequenceDecoderback to summary
protected AbstractCharSequenceDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)

Create a new AbstractCharSequenceDecoder with the given parameters.

Method Detail

decodeback to summary
public final Flux<T> decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Overrides org.springframework.core.codec.AbstractDataBufferDecoder.decode.

Implements org.springframework.core.codec.Decoder.decode.

Doc from org.springframework.core.codec.Decoder.decode.

Decode a DataBuffer input stream into a Flux of T.

Parameters
input:Publisher<DataBuffer>

the DataBuffer input stream to decode

elementType:ResolvableType

the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.

mimeType:MimeType

the MIME type associated with the input stream (optional)

hints:Map<String, Object>

additional information about how to do decode

Returns:Flux<T>

the output stream with decoded elements

Annotations
@Override
decodeback to summary
public final T decode(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Overrides default org.springframework.core.codec.Decoder.decode.

Doc from org.springframework.core.codec.Decoder.decode.

Decode a data buffer to an Object of type T. This is useful for scenarios, that distinct messages (or events) are decoded and handled individually, in fully aggregated form.

Parameters
dataBuffer:DataBuffer

the DataBuffer to decode

elementType:ResolvableType

the expected output type

mimeType:MimeType

the MIME type associated with the data

hints:Map<String, Object>

additional information about how to do decode

Returns:T

the decoded value, possibly null

Annotations
@Override
decodeInternalback to summary
protected abstract T decodeInternal(DataBuffer dataBuffer, Charset charset)

Template method that decodes the given data buffer into T, given the charset.

getCharsetback to summary
private Charset getCharset(MimeType mimeType)
getDefaultCharsetback to summary
public Charset getDefaultCharset()

Return the configured defaultCharset.

getDelimiterBytesback to summary
private byte[][] getDelimiterBytes(MimeType mimeType)
processDataBufferback to summary
private Collection<DataBuffer> processDataBuffer(DataBuffer buffer, DataBufferUtils.Matcher matcher, LimitedDataBufferList chunks)
setDefaultCharsetback to summary
public void setDefaultCharset(Charset defaultCharset)

Set the default character set to fall back on if the MimeType does not specify any.

By default this is UTF-8.

Parameters
defaultCharset:Charset

the charset to fall back on