Class JacksonXmlEncoder
java.lang.Object
org.springframework.http.codec.JacksonCodecSupport<tools.jackson.dataformat.xml.XmlMapper>
org.springframework.http.codec.AbstractJacksonEncoder<tools.jackson.dataformat.xml.XmlMapper>
org.springframework.http.codec.xml.JacksonXmlEncoder
- All Implemented Interfaces:
Encoder<Object>, HttpMessageEncoder<Object>
public class JacksonXmlEncoder
extends AbstractJacksonEncoder<tools.jackson.dataformat.xml.XmlMapper>
Encode from an
Object to bytes of XML objects using Jackson 3.x.
Stream encoding is currently not supported.
- Since:
- 7.0.3
- Author:
- Sebastien Deleuze
- See Also:
-
Field Summary
Fields inherited from class JacksonCodecSupport
FILTER_PROVIDER_HINT, JSON_VIEW_HINT, logger, mapperRegistrations -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance with aXmlMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader).JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper mapper) Construct a new instance with the providedXmlMapper.JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper.Builder builder) Construct a new instance with the providedXmlMapper.Buildercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader).JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper.Builder builder, MimeType... mimeTypes) Construct a new instance with the providedXmlMapper.Buildercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader), andMimeTypes.JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper mapper, MimeType... mimeTypes) Construct a new instance with the providedXmlMapperandMimeTypes. -
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.encode(Publisher<?> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Encode a stream of Objects of typeTinto aDataBufferoutput stream.Methods inherited from class AbstractJacksonEncoder
customizeWriter, encodeValue, getAnnotation, getEncodableMimeTypes, getEncodableMimeTypes, getEncodeHints, getJsonEncoding, getStreamingMediaTypes, getStreamingMediaTypeSeparator, setStreamingMediaTypesMethods inherited from class JacksonCodecSupport
getHints, getJavaType, getMapper, getMapperRegistrations, getMappersForType, getMediaTypesForProblemDetail, getMimeTypes, getMimeTypes, getParameter, registerMappersForType, selectMapper, supportsMimeType
-
Constructor Details
-
JacksonXmlEncoder
public JacksonXmlEncoder()Construct a new instance with aXmlMappercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader). -
JacksonXmlEncoder
public JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper.Builder builder) Construct a new instance with the providedXmlMapper.Buildercustomized with theJacksonModules found byMapperBuilder.findModules(ClassLoader).- See Also:
-
JacksonXmlEncoder
public JacksonXmlEncoder(tools.jackson.dataformat.xml.XmlMapper mapper) Construct a new instance with the providedXmlMapper.- See Also:
-
JacksonXmlEncoder
-
JacksonXmlEncoder
-
-
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<Object>- Overrides:
canEncodein classAbstractJacksonEncoder<tools.jackson.dataformat.xml.XmlMapper>- 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
public Flux<DataBuffer> encode(Publisher<?> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String, Object> hints) Description copied from interface:EncoderEncode a stream of Objects of typeTinto aDataBufferoutput stream.- Specified by:
encodein interfaceEncoder<Object>- Overrides:
encodein classAbstractJacksonEncoder<tools.jackson.dataformat.xml.XmlMapper>- Parameters:
inputStream- the input stream of Objects to encode. If the input should be encoded as a single value rather than as a stream of elements, an instance ofMonoshould be used.bufferFactory- for creating output streamDataBuffer'selementType- the expected type of elements in the input stream; this type must have been previously passed to theEncoder.canEncode(ResolvableType, MimeType)method and it must have returnedtrue.mimeType- the MIME type for the output content (optional)hints- additional information about how to encode- Returns:
- the output stream
-