类 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 that multibyte 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.- 从以下版本开始:
- 4.0
- 作者:
- Sebastien Deleuze, Brian Clozel, Arjen Poutsma, Mark Paluch
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final CharsetThe default charset to use, i.e.The default delimiter strings to use, i.e.从类继承的字段 cn.taketoday.core.codec.AbstractDecoder
logger -
方法概要
修饰符和类型方法说明static 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.decode(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode a data buffer to an Object of type T.reactor.core.publisher.Flux<String>decode(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints) Decode aDataBufferinput stream into a Flux ofT.Return the configureddefaultCharset.voidsetDefaultCharset(Charset defaultCharset) Set the default character set to fall back on if the MimeType does not specify any.static StringDecoderCreate aStringDecoderfor"text/plain".static StringDecodertextPlainOnly(List<String> delimiters, boolean stripDelimiter) Create aStringDecoderfor"text/plain".从类继承的方法 cn.taketoday.core.codec.AbstractDataBufferDecoder
decodeToMono, getMaxInMemorySize, setMaxInMemorySize从类继承的方法 cn.taketoday.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLogger从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.core.codec.Decoder
getDecodableMimeTypes
-
字段详细资料
-
DEFAULT_CHARSET
The default charset to use, i.e. "UTF-8". -
DEFAULT_DELIMITERS
The default delimiter strings to use, i.e.\r\nand\n.
-
-
方法详细资料
-
setDefaultCharset
Set the default character set to fall back on if the MimeType does not specify any.By default this is
UTF-8.- 参数:
defaultCharset- the charset to fall back on
-
getDefaultCharset
Return the configureddefaultCharset. -
canDecode
从接口复制的说明:DecoderWhether the decoder supports the given target element type and the MIME type of the source stream. -
decode
public reactor.core.publisher.Flux<String> decode(org.reactivestreams.Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) 从接口复制的说明:DecoderDecode aDataBufferinput stream into a Flux ofT.- 指定者:
decode在接口中Decoder<String>- 覆盖:
decode在类中AbstractDataBufferDecoder<String>- 参数:
input- theDataBufferinput stream to decodeelementType- the expected type of elements in the output stream; this type must have been previously passed to theDecoder.canDecode(cn.taketoday.core.ResolvableType, cn.taketoday.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- 返回:
- the output stream with decoded elements
-
decode
public String decode(DataBuffer dataBuffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) 从接口复制的说明:DecoderDecode 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.- 参数:
dataBuffer- theDataBufferto decodeelementType- the expected output typemimeType- the MIME type associated with the datahints- additional information about how to do decode- 返回:
- the decoded value, possibly
null
-
textPlainOnly
Create aStringDecoderfor"text/plain". -
textPlainOnly
Create aStringDecoderfor"text/plain".- 参数:
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.- 参数:
delimiters- delimiter strings to use to split the input streamstripDelimiter- whether to remove delimiters from the resulting input strings
-