类 CharSequenceEncoder
- java.lang.Object
- org.springframework.core.codec.AbstractEncoder<CharSequence>
- org.springframework.core.codec.CharSequenceEncoder
- 所有已实现的接口:
Encoder<CharSequence>
public final class CharSequenceEncoder extends AbstractEncoder<CharSequence>
Encode from aCharSequence
stream to a bytes stream.- 从以下版本开始:
- 5.0
- 作者:
- Sebastien Deleuze, Arjen Poutsma, Rossen Stoyanchev
- 另请参阅:
StringDecoder
字段概要
字段 修饰符和类型 字段 说明 static Charset
DEFAULT_CHARSET
The default charset used by the encoder.从类继承的字段 org.springframework.core.codec.AbstractEncoder
logger
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static CharSequenceEncoder
allMimeTypes()
Create aCharSequenceEncoder
that supports all MIME types.boolean
canEncode(ResolvableType elementType, MimeType mimeType)
Whether the encoder supports the given source element type and the MIME type for the output stream.reactor.core.publisher.Flux<DataBuffer>
encode(org.reactivestreams.Publisher<? extends CharSequence> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)
Encode a stream of Objects of typeT
into aDataBuffer
output stream.DataBuffer
encodeValue(CharSequence charSequence, DataBufferFactory bufferFactory, ResolvableType valueType, MimeType mimeType, Map<String,Object> hints)
Encode an Object of type T to a data buffer.static CharSequenceEncoder
textPlainOnly()
Create aCharSequenceEncoder
that supports only "text/plain".从类继承的方法 org.springframework.core.codec.AbstractEncoder
getEncodableMimeTypes, getLogger, setLogger
字段详细资料
DEFAULT_CHARSET
public static final Charset DEFAULT_CHARSET
The default charset used by the encoder.
方法详细资料
canEncode
public boolean canEncode(ResolvableType elementType, @Nullable MimeType mimeType)
从接口复制的说明:Encoder
Whether the encoder supports the given source element type and the MIME type for the output stream.- 指定者:
canEncode
在接口中Encoder<CharSequence>
- 覆盖:
canEncode
在类中AbstractEncoder<CharSequence>
- 参数:
elementType
- the type of elements in the source streammimeType
- the MIME type for the output stream (can benull
if not specified)- 返回:
true
if supported,false
otherwise
encode
public reactor.core.publisher.Flux<DataBuffer> encode(org.reactivestreams.Publisher<? extends CharSequence> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
从接口复制的说明:Encoder
Encode a stream of Objects of typeT
into aDataBuffer
output stream.- 参数:
inputStream
- the input stream of Objects to encode. If the input should be encoded as a single value rather than as a stream of elements, an instance ofMono
should be used.bufferFactory
- for creating output streamDataBuffer
'selementType
- the expected type of elements in the input stream; this type must have been previously passed to theEncoder.canEncode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returnedtrue
.mimeType
- the MIME type for the output content (optional)hints
- additional information about how to encode- 返回:
- the output stream
encodeValue
public DataBuffer encodeValue(CharSequence charSequence, DataBufferFactory bufferFactory, ResolvableType valueType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
从接口复制的说明:Encoder
Encode an Object of type T to a data buffer. This is useful for scenarios, that distinct messages (or events) are encoded and handled individually, in fully aggregated form.By default this method raises
UnsupportedOperationException
and it is expected that some encoders cannot produce a single buffer or cannot do so synchronously (e.g. encoding aResource
).- 参数:
charSequence
- the value to be encodedbufferFactory
- for creating the outputDataBuffer
valueType
- the type for the value being encodedmimeType
- the MIME type for the output content (optional)hints
- additional information about how to encode- 返回:
- the encoded content
textPlainOnly
public static CharSequenceEncoder textPlainOnly()
Create aCharSequenceEncoder
that supports only "text/plain".
allMimeTypes
public static CharSequenceEncoder allMimeTypes()
Create aCharSequenceEncoder
that supports all MIME types.