Package org.springframework.core.codec
Class StringDecoder
java.lang.Object
org.springframework.core.codec.AbstractDecoder<T>
org.springframework.core.codec.AbstractDataBufferDecoder<T>
org.springframework.core.codec.AbstractCharSequenceDecoder<String>
org.springframework.core.codec.StringDecoder
Decode from a data buffer stream to a
String stream, either splitting
or aggregating incoming data chunks to realign along newlines delimiters
and produce a stream of strings. 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.- Since:
- 5.0
- Author:
- Sebastien Deleuze, Brian Clozel, Arjen Poutsma, Mark Paluch
- See Also:
-
Field Summary
Fields inherited from class org.springframework.core.codec.AbstractCharSequenceDecoder
DEFAULT_CHARSET, DEFAULT_DELIMITERSFields inherited from class org.springframework.core.codec.AbstractDecoder
logger -
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecoderCreate aStringDecoderthat supports all MIME types.static StringDecoderallMimeTypes(List<String> delimiters, boolean stripDelimiter) Create aStringDecoderthat supports all MIME types.booleancanDecode(ResolvableType elementType, MimeType mimeType) Whether the decoder supports the given target element type and the MIME type of the source stream.protected StringdecodeInternal(DataBuffer dataBuffer, Charset charset) Template method that decodes the given data buffer intoT, given the charset.static StringDecoderCreate aStringDecoderfor"text/plain".static StringDecodertextPlainOnly(List<String> delimiters, boolean stripDelimiter) Create aStringDecoderfor"text/plain".Methods inherited from class org.springframework.core.codec.AbstractCharSequenceDecoder
decode, decode, getDefaultCharset, setDefaultCharsetMethods inherited from class org.springframework.core.codec.AbstractDataBufferDecoder
decodeDataBuffer, decodeToMono, getMaxInMemorySize, setMaxInMemorySizeMethods inherited from class org.springframework.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLoggerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.codec.Decoder
getDecodableMimeTypes
-
Method Details
-
canDecode
Description copied from interface:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
canDecodein interfaceDecoder<String>- Overrides:
canDecodein classAbstractDecoder<String>- Parameters:
elementType- the target element type for the output streammimeType- the mime type associated with the stream to decode (can benullif not specified)- Returns:
trueif supported,falseotherwise
-
decodeInternal
Description copied from class:AbstractCharSequenceDecoderTemplate method that decodes the given data buffer intoT, given the charset.- Specified by:
decodeInternalin classAbstractCharSequenceDecoder<String>
-
textPlainOnly
Create aStringDecoderfor"text/plain". -
textPlainOnly
Create aStringDecoderfor"text/plain".- Parameters:
delimiters- delimiter strings to use to split the input streamstripDelimiter- whether to remove delimiters from the resulting input strings
-
allMimeTypes
Create aStringDecoderthat supports all MIME types. -
allMimeTypes
Create aStringDecoderthat supports all MIME types.- Parameters:
delimiters- delimiter strings to use to split the input streamstripDelimiter- whether to remove delimiters from the resulting input strings
-