Top Description Fields Constructors Methods
org.springframework.core.codec

public abstract Class AbstractDecoder<T>

extends Object
implements Decoder<T>
Class Inheritance
All Implemented Interfaces
org.springframework.core.codec.Decoder
Known Direct Subclasses
org.springframework.core.codec.AbstractDataBufferDecoder
Type Parameters
<T>
the element type
Imports
java.util.Arrays, .List, .Map, org.apache.commons.logging.Log, .LogFactory, org.reactivestreams.Publisher, reactor.core.publisher.Mono, org.springframework.core.ResolvableType, org.springframework.core.io.buffer.DataBuffer, org.springframework.lang.Nullable, org.springframework.util.MimeType

Abstract base class for Decoder implementations.
Authors
Sebastien Deleuze, Arjen Poutsma
Since
5.0

Field Summary

Modifier and TypeField and Description
private final List<MimeType>
protected Log

Constructor Summary

AccessConstructor and Description
protected
AbstractDecoder(MimeType... supportedMimeTypes)

Method Summary

Modifier and TypeMethod and Description
public boolean
canDecode(ResolvableType
the target element type for the output stream
elementType
,
MimeType
the mime type associated with the stream to decode (can be null if not specified)
mimeType
)

Implements org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.

public Mono<T>
decodeToMono(Publisher<DataBuffer>
the DataBuffer input stream to decode
inputStream
,
ResolvableType
the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.
elementType
,
MimeType
the MIME type associated with the input stream (optional)
mimeType
,
Map<String, Object>
additional information about how to do decode
hints
)

Implements org.springframework.core.codec.Decoder.decodeToMono.

Decode a DataBuffer input stream into a Mono of T.

public List<MimeType>
getDecodableMimeTypes()

Implements org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Return the list of MIME types supported by this Decoder.

public Log
getLogger()

Return the currently configured Logger.

public void
setLogger(Log
the logger to use
logger
)

Set an alternative logger to use than the one based on the class name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decodableMimeTypesback to summary
private final List<MimeType> decodableMimeTypes
loggerback to summary
protected Log logger

Constructor Detail

AbstractDecoderback to summary
protected AbstractDecoder(MimeType... supportedMimeTypes)

Method Detail

canDecodeback to summary
public boolean canDecode(ResolvableType elementType, MimeType mimeType)

Implements org.springframework.core.codec.Decoder.canDecode.

Doc from org.springframework.core.codec.Decoder.canDecode.

Whether the decoder supports the given target element type and the MIME type of the source stream.

Parameters
elementType:ResolvableType

the target element type for the output stream

mimeType:MimeType

the mime type associated with the stream to decode (can be null if not specified)

Returns:boolean

true if supported, false otherwise

Annotations
@Override
decodeToMonoback to summary
public Mono<T> decodeToMono(Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, Map<String, Object> hints)

Implements org.springframework.core.codec.Decoder.decodeToMono.

Doc from org.springframework.core.codec.Decoder.decodeToMono.

Decode a DataBuffer input stream into a Mono of T.

Parameters
inputStream:Publisher<DataBuffer>

the DataBuffer input stream to decode

elementType:ResolvableType

the expected type of elements in the output stream; this type must have been previously passed to the canDecode method and it must have returned true.

mimeType:MimeType

the MIME type associated with the input stream (optional)

hints:Map<String, Object>

additional information about how to do decode

Returns:Mono<T>

the output stream with the decoded element

Annotations
@Override
getDecodableMimeTypesback to summary
public List<MimeType> getDecodableMimeTypes()

Implements org.springframework.core.codec.Decoder.getDecodableMimeTypes.

Doc from org.springframework.core.codec.Decoder.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.

Returns:List<MimeType>

the list of supported MIME types

Annotations
@Override
getLoggerback to summary
public Log getLogger()

Return the currently configured Logger.

Since
5.1
setLoggerback to summary
public void setLogger(Log logger)

Set an alternative logger to use than the one based on the class name.

Parameters
logger:Log

the logger to use

Since
5.1