Class AbstractCharSequenceDecoder<T extends CharSequence>

Type Parameters:
T - the character sequence type
All Implemented Interfaces:
Decoder<T>
Direct Known Subclasses:
CharBufferDecoder, StringDecoder

public abstract class AbstractCharSequenceDecoder<T extends CharSequence> extends AbstractDataBufferDecoder<T>
Abstract base class that decodes from a data buffer stream to a CharSequence stream.
Since:
6.1
Author:
Arjen Poutsma
  • Field Details

    • DEFAULT_CHARSET

      public static final Charset DEFAULT_CHARSET
      The default charset to use, i.e. "UTF-8".
    • DEFAULT_DELIMITERS

      public static final List<String> DEFAULT_DELIMITERS
      The default delimiter strings to use, i.e. \r\n and \n.
  • Constructor Details

    • AbstractCharSequenceDecoder

      protected AbstractCharSequenceDecoder(List<String> delimiters, boolean stripDelimiter, MimeType... mimeTypes)
      Create a new AbstractCharSequenceDecoder with the given parameters.
  • Method Details

    • setDefaultCharset

      public void setDefaultCharset(Charset defaultCharset)
      Set the default character set to fall back on if the MimeType does not specify any.

      By default this is UTF-8.

      Parameters:
      defaultCharset - the charset to fall back on
    • getDefaultCharset

      public Charset getDefaultCharset()
      Return the configured defaultCharset.
    • decode

      public final reactor.core.publisher.Flux<T> decode(Publisher<DataBuffer> input, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
      Description copied from interface: Decoder
      Decode a DataBuffer input stream into a Flux of T.
      Specified by:
      decode in interface Decoder<T extends CharSequence>
      Overrides:
      decode in class AbstractDataBufferDecoder<T extends CharSequence>
      Parameters:
      input - 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 Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.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
      Returns:
      the output stream with decoded elements
    • decode

      public final T decode(DataBuffer dataBuffer, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
      Description copied from interface: Decoder
      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.
      Parameters:
      dataBuffer - the DataBuffer to decode
      elementType - the expected output type
      mimeType - the MIME type associated with the data
      hints - additional information about how to do decode
      Returns:
      the decoded value, possibly null
    • decodeInternal

      protected abstract T decodeInternal(DataBuffer dataBuffer, Charset charset)
      Template method that decodes the given data buffer into T, given the charset.