Class ResourceEncoder
java.lang.Object
org.springframework.core.codec.AbstractEncoder<Resource>
org.springframework.core.codec.AbstractSingleValueEncoder<Resource>
org.springframework.core.codec.ResourceEncoder
Encoder for
Resources.- Since:
- 5.0
- Author:
- Arjen Poutsma
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default buffer size used by the encoder.Fields inherited from class AbstractEncoder
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncode(ResolvableType elementType, @nullable 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, @nullable MimeType mimeType, @nullable Map<String, Object> hints) EncodeTto an outputDataBufferstream.Methods inherited from class AbstractSingleValueEncoder
encodeMethods inherited from class AbstractEncoder
getEncodableMimeTypes, getLogger, setLoggerMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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:EncoderWhether the encoder supports the given source element type and the MIME type for the output stream.- Specified by:
canEncodein interfaceEncoder<Resource>- Overrides:
canEncodein classAbstractEncoder<Resource>- Parameters:
elementType- the type of elements in the source streammimeType- the MIME type for the output stream (can benullif not specified)- Returns:
trueif supported,falseotherwise
-
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:AbstractSingleValueEncoderEncodeTto an outputDataBufferstream.- Specified by:
encodein 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
-