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

public final Class CharBufferDecoder

extends AbstractCharSequenceDecoder<CharBuffer>
Class Inheritance
Imports
java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, java.util.List, org.springframework.core.ResolvableType, org.springframework.core.io.buffer.DataBuffer, org.springframework.lang.Nullable, org.springframework.util.MimeType, .MimeTypeUtils

Decode from a data buffer stream to a CharBuffer stream, either splitting or aggregating incoming data chunks to realign along newlines delimiters and produce a stream of char buffers. This is useful for streaming but is also necessary to ensure that multi-byte characters can be decoded correctly, avoiding split-character issues. The default delimiters used by default are \n and \r\n but that can be customized.
Authors
Markus Heiden, Arjen Poutsma
Since
6.1
See Also
CharSequenceEncoder

Field Summary

Inherited from org.springframework.core.codec.AbstractCharSequenceDecoder:
DEFAULT_CHARSETDEFAULT_DELIMITERS

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public static CharBufferDecoder
allMimeTypes()

Create a CharBufferDecoder that supports all MIME types.

public static CharBufferDecoder
allMimeTypes(List<String>
delimiter strings to use to split the input stream
delimiters
,
boolean
whether to remove delimiters from the resulting input strings
stripDelimiter
)

Create a CharBufferDecoder that supports all MIME types.

public boolean
canDecode(ResolvableType
the target element type for the output stream
elementType
,
MimeType
the mime type associated with the stream to decode (can be null if not specified)
mimeType
)

Overrides org.springframework.core.codec.AbstractDecoder.canDecode.

Implements org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.
protected CharBuffer
decodeInternal(DataBuffer dataBuffer, Charset charset)

Implements abstract org.springframework.core.codec.AbstractCharSequenceDecoder.decodeInternal.

Template method that decodes the given data buffer into T, given the charset.
public static CharBufferDecoder
textPlainOnly()

Create a CharBufferDecoder for "text/plain".

public static CharBufferDecoder
textPlainOnly(List<String>
delimiter strings to use to split the input stream
delimiters
,
boolean
whether to remove delimiters from the resulting input strings
stripDelimiter
)

Create a CharBufferDecoder for "text/plain".

Inherited from org.springframework.core.codec.AbstractCharSequenceDecoder:
decodedecodegetDefaultCharsetsetDefaultCharset

Constructor Detail

CharBufferDecoderback to summary
public CharBufferDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)

Method Detail

allMimeTypesback to summary
public static CharBufferDecoder allMimeTypes()

Create a CharBufferDecoder that supports all MIME types.

allMimeTypesback to summary
public static CharBufferDecoder allMimeTypes(List<String> delimiters, boolean stripDelimiter)

Create a CharBufferDecoder that supports all MIME types.

Parameters
delimiters:List<String>

delimiter strings to use to split the input stream

stripDelimiter:boolean

whether to remove delimiters from the resulting input strings

canDecodeback to summary
public boolean canDecode(ResolvableType elementType, MimeType mimeType)

Overrides org.springframework.core.codec.AbstractDecoder.canDecode.

Implements org.springframework.core.codec.Decoder.canDecode.

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

Whether the decoder supports the given target element type and the MIME type of the source stream.

Parameters
elementType:ResolvableType

the target element type for the output stream

mimeType:MimeType

the mime type associated with the stream to decode (can be null if not specified)

Returns:boolean

true if supported, false otherwise

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

Implements abstract org.springframework.core.codec.AbstractCharSequenceDecoder.decodeInternal.

Doc from org.springframework.core.codec.AbstractCharSequenceDecoder.decodeInternal.

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

Annotations
@Override
textPlainOnlyback to summary
public static CharBufferDecoder textPlainOnly()

Create a CharBufferDecoder for "text/plain".

textPlainOnlyback to summary
public static CharBufferDecoder textPlainOnly(List<String> delimiters, boolean stripDelimiter)

Create a CharBufferDecoder for "text/plain".

Parameters
delimiters:List<String>

delimiter strings to use to split the input stream

stripDelimiter:boolean

whether to remove delimiters from the resulting input strings