Package org.springframework.core.codec
Class ByteArrayDecoder
- java.lang.Object
- org.springframework.core.codec.AbstractDecoder<T>
- org.springframework.core.codec.AbstractDataBufferDecoder<byte[]>
- org.springframework.core.codec.ByteArrayDecoder
- All Implemented Interfaces:
Decoder<byte[]>
public class ByteArrayDecoder extends AbstractDataBufferDecoder<byte[]>
Decoder forbyte
arrays.- Since:
- 5.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
Field Summary
Fields inherited from class org.springframework.core.codec.AbstractDecoder
logger
Constructor Summary
Constructors Constructor Description ByteArrayDecoder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canDecode(ResolvableType elementType, MimeType mimeType)
Whether the decoder supports the given target element type and the MIME type of the source stream.byte[]
decode(DataBuffer dataBuffer, ResolvableType elementType, MimeType mimeType, Map<String,Object> hints)
Decode a data buffer to an Object of type T.Methods inherited from class org.springframework.core.codec.AbstractDataBufferDecoder
decode, decodeDataBuffer, decodeToMono, getMaxInMemorySize, setMaxInMemorySize
Methods inherited from class org.springframework.core.codec.AbstractDecoder
getDecodableMimeTypes, getLogger, setLogger
Constructor Detail
ByteArrayDecoder
public ByteArrayDecoder()
Method Detail
canDecode
public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
Description copied from interface:Decoder
Whether the decoder supports the given target element type and the MIME type of the source stream.- Specified by:
canDecode
in interfaceDecoder<byte[]>
- Overrides:
canDecode
in classAbstractDecoder<byte[]>
- Parameters:
elementType
- the target element type for the output streammimeType
- the mime type associated with the stream to decode (can benull
if not specified)- Returns:
true
if supported,false
otherwise
decode
public byte[] 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
- theDataBuffer
to decodeelementType
- the expected output typemimeType
- the MIME type associated with the datahints
- additional information about how to do encode- Returns:
- the decoded value, possibly
null