Class JacksonXmlModule
java.lang.Object
com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.databind.module.SimpleModule
com.fasterxml.jackson.dataformat.xml.JacksonXmlModule
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
,Serializable
public class JacksonXmlModule
extends com.fasterxml.jackson.databind.module.SimpleModule
implements Serializable
Module that implements most functionality needed to support producing and
consuming XML instead of JSON, used by
XmlMapper
for registering
handlers for XML-specific processing.
NOTE: please do NOT register this directly on XmlMapper
: mapper
registers an instance (either one explicitly given in constructor, or, if none,
one it configures) and attempts to re-register is unlikely to work as
you'd expect.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module
com.fasterxml.jackson.databind.Module.SetupContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
Determination of whether indexed properties (arrays, Lists) that are not explicitly annotated (withJacksonXmlElementWrapper
or equivalent) should default to using implicit wrapper (with same name as property) or not.protected String
Name used for pseudo-property used for returning XML Text value (which does not have actual element name to use).protected com.fasterxml.jackson.databind.ser.SerializerFactory
Optional override forSerializerFactory
used byXmlMapper
.private static final long
Fields inherited from class com.fasterxml.jackson.databind.module.SimpleModule
_abstractTypes, _deserializerModifier, _deserializers, _hasExplicitName, _keyDeserializers, _keySerializers, _mixins, _name, _namingStrategy, _serializerModifier, _serializers, _subtypes, _valueInstantiators, _version
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.fasterxml.jackson.databind.AnnotationIntrospector
overrideSerializerFactory
(com.fasterxml.jackson.databind.ser.SerializerFactory factory) Method to use for overriding defaultSerializerFactory
usedcom.fasterxml.jackson.databind.ser.SerializerFactory
void
setDefaultUseWrapper
(boolean state) Method that can be used to define whetherAnnotationIntrospector
we register will use wrapper for indexed (List, array) properties or not, if there are no explicit annotations.void
setupModule
(com.fasterxml.jackson.databind.Module.SetupContext context) void
setXMLTextElementName
(String name) Method that can be used to define alternate "virtual name" to use for XML CDATA segments; that is, text values.Methods inherited from class com.fasterxml.jackson.databind.module.SimpleModule
_checkNotNull, addAbstractTypeMapping, addDeserializer, addKeyDeserializer, addKeySerializer, addSerializer, addSerializer, addValueInstantiator, getModuleName, getTypeId, registerSubtypes, registerSubtypes, registerSubtypes, setAbstractTypes, setDeserializerModifier, setDeserializers, setKeyDeserializers, setKeySerializers, setMixInAnnotation, setNamingStrategy, setSerializerModifier, setSerializers, setValueInstantiators, version
Methods inherited from class com.fasterxml.jackson.databind.Module
getDependencies
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
_cfgDefaultUseWrapper
protected boolean _cfgDefaultUseWrapperDetermination of whether indexed properties (arrays, Lists) that are not explicitly annotated (withJacksonXmlElementWrapper
or equivalent) should default to using implicit wrapper (with same name as property) or not. If enabled, wrapping is used by default; if false, it is not.Note that JAXB annotation introspector always assumes "do not wrap by default". Jackson annotations have different default due to backwards compatibility.
- Since:
- 2.1
-
_cfgNameForTextElement
Name used for pseudo-property used for returning XML Text value (which does not have actual element name to use). Defaults to empty String, but may be changed for inter-operability reasons: JAXB, for example, uses "value" as name.- Since:
- 2.1
-
_serializerFactoryOverride
protected com.fasterxml.jackson.databind.ser.SerializerFactory _serializerFactoryOverrideOptional override forSerializerFactory
used byXmlMapper
. Needed to allow proper override and configurability using custom implementations.- Since:
- 2.18.2
-
-
Constructor Details
-
JacksonXmlModule
public JacksonXmlModule()
-
-
Method Details
-
setupModule
public void setupModule(com.fasterxml.jackson.databind.Module.SetupContext context) - Overrides:
setupModule
in classcom.fasterxml.jackson.databind.module.SimpleModule
-
setDefaultUseWrapper
public void setDefaultUseWrapper(boolean state) Method that can be used to define whetherAnnotationIntrospector
we register will use wrapper for indexed (List, array) properties or not, if there are no explicit annotations. SeeJacksonXmlElementWrapper
for details.Note that method MUST be called before registering the module; otherwise change will not have any effect.
- Parameters:
state
- Whether to enable or disable "use wrapper for non-annotated List properties"- Since:
- 2.1
-
setXMLTextElementName
Method that can be used to define alternate "virtual name" to use for XML CDATA segments; that is, text values. Default name is empty String (""); but some frameworks use other names: JAXB, for example, uses "value".Note that method MUST be called before registering the module; otherwise change will not have any effect.
- Parameters:
name
- Virtual name to use when exposing XML character data sections- Since:
- 2.1
-
overrideSerializerFactory
public JacksonXmlModule overrideSerializerFactory(com.fasterxml.jackson.databind.ser.SerializerFactory factory) Method to use for overriding defaultSerializerFactory
used- Since:
- 2.18.2
-
serializerFactoryOverride
public com.fasterxml.jackson.databind.ser.SerializerFactory serializerFactoryOverride()- Since:
- 2.18.2
-
_constructIntrospector
protected com.fasterxml.jackson.databind.AnnotationIntrospector _constructIntrospector()
-