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

Fields
Modifier and Type
Field
Description
`static final Charset`
`DEFAULT_CHARSET`
The default charset to use, i.e.
`static final List<String>`
`DEFAULT_DELIMITERS`
The default delimiter strings to use, i.e.

### Fields inherited from class org.springframework.core.codec.AbstractDecoder

`logger`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`AbstractCharSequenceDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)`
Create a new `AbstractCharSequenceDecoder` with the given parameters.

## Method Summary

Modifier and Type
Method
Description
`final reactor.core.publisher.Flux<T>`
`decode(Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)`
Decode a `DataBuffer` input stream into a Flux of `T`.
`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 into `T`, given the charset.
`Charset`
`getDefaultCharset()`
Return the configured `defaultCharset`.
`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

public static final Charset DEFAULT_CHARSET
The default charset to use, i.e. "UTF-8".

### DEFAULT_DELIMITERS

public static final List<String> DEFAULT_DELIMITERS
The default delimiter strings to use, i.e. `\r\n` and `\n`.

## Constructor Details

### AbstractCharSequenceDecoder

protected AbstractCharSequenceDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)
Create a new `AbstractCharSequenceDecoder` with the given parameters.

## Method Details

### setDefaultCharset

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` - the charset to fall back on

### getDefaultCharset

public Charset getDefaultCharset()
Return the configured `defaultCharset`.

### 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 a `DataBuffer` input stream into a Flux of `T`.

Specified by:
  `decode` in interface `Decoder<T extends CharSequence>`
Overrides:
  `decode` in class `AbstractDataBufferDecoder<T extends CharSequence>`
Parameters:
  `input` - the `DataBuffer` input stream to decode
  `elementType` - the expected type of elements in the output stream; this type must have been previously passed to the `Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)` method and it must have returned `true`.
  `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` - the `DataBuffer` to decode
  `elementType` - the expected output type
  `mimeType` - the MIME type associated with the data
  `hints` - additional information about how to do decode
Returns:
  the decoded value, possibly `null`

### decodeInternal

protected abstract T decodeInternal(DataBuffer dataBuffer, Charset charset)
Template method that decodes the given data buffer into `T`, given the charset.