Package org.springframework.core.codec
Class AbstractCharSequenceDecoder<T extends CharSequence>
java.lang.Object
org.springframework.core.codec.AbstractDecoder<T>
org.springframework.core.codec.AbstractDataBufferDecoder<T>
org.springframework.core.codec.AbstractCharSequenceDecoder<T>
- Type Parameters:
T
- the character sequence type
- All Implemented Interfaces:
Decoder<T>
- Direct Known Subclasses:
CharBufferDecoder
,StringDecoder
public abstract class AbstractCharSequenceDecoder<T extends CharSequence>
extends AbstractDataBufferDecoder<T>
Abstract base class that decodes from a data buffer stream to a
CharSequence
stream.- Since:
- 6.1
- Author:
- Arjen Poutsma
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Charset
The default charset to use, i.e.The default delimiter strings to use, i.e.Fields inherited from class org.springframework.core.codec.AbstractDecoder
logger
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractCharSequenceDecoder
(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes) Create a newAbstractCharSequenceDecoder
with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionfinal reactor.core.publisher.Flux<T>
decode
(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBuffer
input stream into a Flux ofT
.final T
decode
(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) 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 intoT
, given the charset.Return the configureddefaultCharset
.void
setDefaultCharset
(Charset defaultCharset) Set the default character set to fall back on if the MimeType does not specify any.Methods inherited from class org.springframework.core.codec.AbstractDataBufferDecoder
decodeDataBuffer, decodeToMono, getMaxInMemorySize, setMaxInMemorySize
Methods inherited from class org.springframework.core.codec.AbstractDecoder
canDecode, getDecodableMimeTypes, getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.codec.Decoder
getDecodableMimeTypes
-
Field Details
-
DEFAULT_CHARSET
The default charset to use, i.e. "UTF-8". -
DEFAULT_DELIMITERS
The default delimiter strings to use, i.e.\r\n
and\n
.
-
-
Constructor Details
-
Method Details
-
setDefaultCharset
Set the default character set to fall back on if the MimeType does not specify any.By default this is
UTF-8
.- Parameters:
defaultCharset
- the charset to fall back on
-
getDefaultCharset
Return the configureddefaultCharset
. -
decode
public final reactor.core.publisher.Flux<T> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:Decoder
Decode aDataBuffer
input stream into a Flux ofT
.- Specified by:
decode
in interfaceDecoder<T extends CharSequence>
- Overrides:
decode
in classAbstractDataBufferDecoder<T extends CharSequence>
- Parameters:
input
- theDataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returnedtrue
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do decode- Returns:
- the output stream with decoded elements
-
decode
public final T decode(DataBuffer dataBuffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:Decoder
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
- theDataBuffer
to decodeelementType
- the expected output typemimeType
- the MIME type associated with the datahints
- additional information about how to do decode- Returns:
- the decoded value, possibly
null
-
decodeInternal
Template method that decodes the given data buffer intoT
, given the charset.
-