Class XmlMapper
- java.lang.Object
-
- com.fasterxml.jackson.core.TreeCodec
-
- com.fasterxml.jackson.core.ObjectCodec
-
- com.fasterxml.jackson.databind.ObjectMapper
-
- com.fasterxml.jackson.dataformat.xml.XmlMapper
-
- All Implemented Interfaces:
Versioned
,java.io.Serializable
public class XmlMapper extends ObjectMapper
CustomizedObjectMapper
that will read and write XML instead of JSON, using XML-backedJsonFactory
implementation (XmlFactory
).Mapper itself overrides some aspects of functionality to try to handle data binding aspects as similar to JAXB as possible.
Note that most of configuration should be done by pre-constructing
JacksonXmlModule
explicitly, instead of relying on default settings.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
XmlMapper.Builder
Builder implementation for constructingXmlMapper
instances.-
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.ObjectMapper
ObjectMapper.DefaultTypeResolverBuilder, ObjectMapper.DefaultTyping
-
-
Constructor Summary
Constructors Constructor Description XmlMapper()
XmlMapper(JacksonXmlModule module)
XmlMapper(XmlFactory xmlFactory)
XmlMapper(XmlFactory xmlFactory, JacksonXmlModule module)
XmlMapper(javax.xml.stream.XMLInputFactory inputF)
XmlMapper(javax.xml.stream.XMLInputFactory inputF, javax.xml.stream.XMLOutputFactory outF)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static XmlMapper.Builder
builder()
static XmlMapper.Builder
builder(XmlFactory streamFactory)
ObjectMapper
configure(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f, boolean state)
ObjectMapper
configure(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f, boolean state)
XmlMapper
copy()
Method for creating a newObjectMapper
instance that has same initial configuration as this instance.ObjectMapper
disable(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f)
ObjectMapper
disable(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f)
ObjectMapper
enable(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f)
ObjectMapper
enable(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f)
XmlFactory
getFactory()
Accessor for finding underlying data format factory (JsonFactory
) codec will use for data binding.<T> T
readValue(javax.xml.stream.XMLStreamReader r, TypeReference<T> valueTypeRef)
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.<T> T
readValue(javax.xml.stream.XMLStreamReader r, JavaType valueType)
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.<T> T
readValue(javax.xml.stream.XMLStreamReader r, java.lang.Class<T> valueType)
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.XmlMapper
setDefaultUseWrapper(boolean state)
Deprecated.Since 2.10 useXmlMapper.Builder.defaultUseWrapper(boolean)
insteadVersion
version()
Method that will return version information stored in and read from jar that contains this class.void
writeValue(javax.xml.stream.XMLStreamWriter w0, java.lang.Object value)
Method for serializing given value using specificXMLStreamReader
: useful when building large XML files by binding individual items, one at a time.static XmlMapper.Builder
xmlBuilder()
-
Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper
acceptJsonFormatVisitor, acceptJsonFormatVisitor, activateDefaultTyping, activateDefaultTyping, activateDefaultTyping, activateDefaultTypingAsProperty, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, coercionConfigDefaults, coercionConfigFor, coercionConfigFor, configOverride, configure, configure, configure, configure, configure, constructType, constructType, convertValue, convertValue, convertValue, createArrayNode, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deactivateDefaultTyping, disable, disable, disable, disable, disable, disable, disable, disableDefaultTyping, enable, enable, enable, enable, enable, enable, enable, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTypingAsProperty, findAndRegisterModules, findMixInClassFor, findModules, findModules, generateJsonSchema, getDateFormat, getDeserializationConfig, getDeserializationContext, getInjectableValues, getNodeFactory, getPolymorphicTypeValidator, getPropertyNamingStrategy, getRegisteredModuleIds, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, mixInCount, nullNode, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, readerForArrayOf, readerForListOf, readerForMapOf, readerForUpdating, readerWithView, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValues, readValues, readValues, readValues, registerModule, registerModules, registerModules, registerSubtypes, registerSubtypes, registerSubtypes, setAccessorNaming, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setConfig, setConfig, setConstructorDetector, setDateFormat, setDefaultAttributes, setDefaultLeniency, setDefaultMergeable, setDefaultPrettyPrinter, setDefaultPropertyInclusion, setDefaultPropertyInclusion, setDefaultSetterInfo, setDefaultTyping, setDefaultVisibility, setFilterProvider, setFilters, setHandlerInstantiator, setInjectableValues, setLocale, setMixInAnnotations, setMixInResolver, setMixIns, setNodeFactory, setPolymorphicTypeValidator, setPropertyInclusion, setPropertyNamingStrategy, setSerializationInclusion, setSerializerFactory, setSerializerProvider, setSubtypeResolver, setTimeZone, setTypeFactory, setVisibility, setVisibility, setVisibilityChecker, tokenStreamFactory, treeAsTokens, treeToValue, treeToValue, updateValue, valueToTree, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithType, writerWithType, writerWithType, writerWithView, writeTree, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsString
-
Methods inherited from class com.fasterxml.jackson.core.ObjectCodec
getJsonFactory
-
-
-
-
Constructor Detail
-
XmlMapper
public XmlMapper()
-
XmlMapper
public XmlMapper(javax.xml.stream.XMLInputFactory inputF, javax.xml.stream.XMLOutputFactory outF)
- Since:
- 2.4
-
XmlMapper
public XmlMapper(javax.xml.stream.XMLInputFactory inputF)
- Since:
- 2.4
-
XmlMapper
public XmlMapper(XmlFactory xmlFactory)
-
XmlMapper
public XmlMapper(JacksonXmlModule module)
-
XmlMapper
public XmlMapper(XmlFactory xmlFactory, JacksonXmlModule module)
-
-
Method Detail
-
copy
public XmlMapper copy()
Description copied from class:ObjectMapper
Method for creating a newObjectMapper
instance that has same initial configuration as this instance. Note that this also requires making a copy of the underlyingJsonFactory
instance.Method is typically used when multiple, differently configured mappers are needed. Although configuration is shared, cached serializers and deserializers are NOT shared, which means that the new instance may be re-configured before use; meaning that it behaves the same way as if an instance was constructed from scratch.
- Overrides:
copy
in classObjectMapper
-
xmlBuilder
public static XmlMapper.Builder xmlBuilder()
- Since:
- 2.10
-
builder
public static XmlMapper.Builder builder()
- Since:
- 2.10
-
builder
public static XmlMapper.Builder builder(XmlFactory streamFactory)
- Since:
- 2.10
-
version
public Version version()
Description copied from class:ObjectMapper
Method that will return version information stored in and read from jar that contains this class.- Specified by:
version
in interfaceVersioned
- Overrides:
version
in classObjectMapper
- Returns:
- Version of the component
-
setDefaultUseWrapper
@Deprecated public XmlMapper setDefaultUseWrapper(boolean state)
Deprecated.Since 2.10 useXmlMapper.Builder.defaultUseWrapper(boolean)
insteadSince 2.7
-
getFactory
public XmlFactory getFactory()
Description copied from class:ObjectCodec
Accessor for finding underlying data format factory (JsonFactory
) codec will use for data binding.- Overrides:
getFactory
in classObjectMapper
- Returns:
- Underlying
JsonFactory
instance
-
configure
public ObjectMapper configure(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f, boolean state)
-
configure
public ObjectMapper configure(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f, boolean state)
-
enable
public ObjectMapper enable(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f)
-
enable
public ObjectMapper enable(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f)
-
disable
public ObjectMapper disable(com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature f)
-
disable
public ObjectMapper disable(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature f)
-
readValue
public <T> T readValue(javax.xml.stream.XMLStreamReader r, java.lang.Class<T> valueType) throws java.io.IOException
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.- Throws:
java.io.IOException
- Since:
- 2.4
-
readValue
public <T> T readValue(javax.xml.stream.XMLStreamReader r, TypeReference<T> valueTypeRef) throws java.io.IOException
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.- Throws:
java.io.IOException
- Since:
- 2.4
-
readValue
public <T> T readValue(javax.xml.stream.XMLStreamReader r, JavaType valueType) throws java.io.IOException
Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic StaxXMLStreamReader
with data-binding by Jackson.- Throws:
java.io.IOException
- Since:
- 2.4
-
writeValue
public void writeValue(javax.xml.stream.XMLStreamWriter w0, java.lang.Object value) throws java.io.IOException
Method for serializing given value using specificXMLStreamReader
: useful when building large XML files by binding individual items, one at a time.- Throws:
java.io.IOException
- Since:
- 2.4
-
-