Package org.springframework.core.codec
Class ResourceEncoder
java.lang.Object
org.springframework.core.codec.AbstractEncoder<T>
org.springframework.core.codec.AbstractSingleValueEncoder<Resource>
org.springframework.core.codec.ResourceEncoder
Encoder for
Resources
.- Since:
- 5.0
- Author:
- Arjen Poutsma
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default buffer size used by the encoder.Fields inherited from class org.springframework.core.codec.AbstractEncoder
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canEncode
(ResolvableType elementType, MimeType mimeType) Whether the encoder supports the given source element type and the MIME type for the output stream.protected reactor.core.publisher.Flux<DataBuffer>
encode
(Resource resource, DataBufferFactory bufferFactory, ResolvableType type, MimeType mimeType, Map<String, Object> hints) EncodeT
to an outputDataBuffer
stream.Methods inherited from class org.springframework.core.codec.AbstractSingleValueEncoder
encode
Methods inherited from class org.springframework.core.codec.AbstractEncoder
getEncodableMimeTypes, getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.codec.Encoder
encodeValue, getEncodableMimeTypes
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default buffer size used by the encoder.- See Also:
-
-
Constructor Details
-
ResourceEncoder
public ResourceEncoder() -
ResourceEncoder
public ResourceEncoder(int bufferSize)
-
-
Method Details
-
canEncode
Description copied from interface:Encoder
Whether the encoder supports the given source element type and the MIME type for the output stream.- Specified by:
canEncode
in interfaceEncoder<Resource>
- Overrides:
canEncode
in classAbstractEncoder<Resource>
- Parameters:
elementType
- the type of elements in the source streammimeType
- the MIME type for the output stream (can benull
if not specified)- Returns:
true
if supported,false
otherwise
-
encode
protected reactor.core.publisher.Flux<DataBuffer> encode(Resource resource, DataBufferFactory bufferFactory, ResolvableType type, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from class:AbstractSingleValueEncoder
EncodeT
to an outputDataBuffer
stream.- Specified by:
encode
in classAbstractSingleValueEncoder<Resource>
- Parameters:
resource
- the value to processbufferFactory
- a buffer factory used to create the outputtype
- the stream element type to processmimeType
- the mime type to processhints
- additional information about how to do decode, optional- Returns:
- the output stream
-