接口 Decoder<T>

类型参数:
T - the type of elements in the output stream
所有已知实现类:
AbstractDataBufferDecoder, AbstractDecoder, ByteArrayDecoder, ByteBufferDecoder, DataBufferDecoder, Netty5BufferDecoder, NettyByteBufDecoder, ResourceDecoder, StringDecoder

public interface Decoder<T>
Strategy for decoding a DataBuffer input stream into an output stream of elements of type <T>.
从以下版本开始:
4.0
作者:
Sebastien Deleuze, Rossen Stoyanchev
  • 方法详细资料

    • canDecode

      boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
      Whether the decoder supports the given target element type and the MIME type of the source stream.
      参数:
      elementType - the target element type for the output stream
      mimeType - the mime type associated with the stream to decode (can be null if not specified)
      返回:
      true if supported, false otherwise
    • decode

      reactor.core.publisher.Flux<T> decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
      Decode a DataBuffer input stream into a Flux of T.
      参数:
      inputStream - 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 canDecode(cn.taketoday.core.ResolvableType, cn.taketoday.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
      返回:
      the output stream with decoded elements
    • decodeToMono

      reactor.core.publisher.Mono<T> decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
      Decode a DataBuffer input stream into a Mono of T.
      参数:
      inputStream - 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 canDecode(cn.taketoday.core.ResolvableType, cn.taketoday.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
      返回:
      the output stream with the decoded element
    • decode

      @Nullable default T decode(DataBuffer buffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints) throws DecodingException
      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.
      参数:
      buffer - the DataBuffer to decode
      targetType - the expected output type
      mimeType - the MIME type associated with the data
      hints - additional information about how to do decode
      返回:
      the decoded value, possibly null
      抛出:
      DecodingException
    • getDecodableMimeTypes

      List<MimeType> getDecodableMimeTypes()
      Return the list of MIME types supported by this Decoder. The list may not apply to every possible target element type and calls to this method should typically be guarded via canDecode(elementType, null). The list may also exclude MIME types supported only for a specific element type. Alternatively, use getDecodableMimeTypes(ResolvableType) for a more precise list.
      返回:
      the list of supported MIME types
    • getDecodableMimeTypes

      default List<MimeType> getDecodableMimeTypes(ResolvableType targetType)
      Return the list of MIME types supported by this Decoder for the given type of element. This list may differ from getDecodableMimeTypes() if the Decoder doesn't support the given element type or if it supports it only for a subset of MIME types.
      参数:
      targetType - the type of element to check for decoding
      返回:
      the list of MIME types supported for the given target type