Package com.fasterxml.jackson.dataformat.xml

## 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:
  `com.fasterxml.jackson.core.Versioned`, `java.io.Serializable`

    public class XmlMapper
    extends com.fasterxml.jackson.databind.ObjectMapper

Customized `ObjectMapper` that will read and write XML instead of JSON, using XML-backed `JsonFactory` 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
`static class` `XmlMapper.Builder` Builder implementation for constructing `XmlMapper` instances.

### Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.ObjectMapper

`com.fasterxml.jackson.databind.ObjectMapper.DefaultTypeResolverBuilder, com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping`

### Field Summary

Fields
`protected JacksonXmlModule` `_xmlModule`
`protected static JacksonXmlModule` `DEFAULT_XML_MODULE`
`protected static DefaultXmlPrettyPrinter` `DEFAULT_XML_PRETTY_PRINTER`

### Fields inherited from class com.fasterxml.jackson.databind.ObjectMapper

`_configOverrides, _deserializationConfig, _deserializationContext, _injectableValues, _jsonFactory, _mixIns, _registeredModuleTypes, _rootDeserializers, _serializationConfig, _serializerFactory, _serializerProvider, _subtypeResolver, _typeFactory, DEFAULT_ANNOTATION_INTROSPECTOR, DEFAULT_BASE`

### Constructor Summary

Constructors
`` `XmlMapper()`
`` `XmlMapper​(JacksonXmlModule module)`
`` `XmlMapper​(XmlFactory xmlFactory)`
`` `XmlMapper​(XmlFactory xmlFactory, JacksonXmlModule module)`
`protected` `XmlMapper​(XmlMapper src)`
`` `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
`protected com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder<?>` `_constructDefaultTypeResolverBuilder​(com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping applicability, com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator ptv)`
`static XmlMapper.Builder` `builder()`
`static XmlMapper.Builder` `builder​(XmlFactory streamFactory)`
`com.fasterxml.jackson.databind.ObjectMapper` `configure​(FromXmlParser.Feature f, boolean state)`
`com.fasterxml.jackson.databind.ObjectMapper` `configure​(ToXmlGenerator.Feature f, boolean state)`
`XmlMapper` `copy()`
`com.fasterxml.jackson.databind.ObjectMapper` `disable​(FromXmlParser.Feature f)`
`com.fasterxml.jackson.databind.ObjectMapper` `disable​(ToXmlGenerator.Feature f)`
`com.fasterxml.jackson.databind.ObjectMapper` `enable​(FromXmlParser.Feature f)`
`com.fasterxml.jackson.databind.ObjectMapper` `enable​(ToXmlGenerator.Feature f)`
`XmlFactory` `getFactory()`
`<T> T` `readValue​(javax.xml.stream.XMLStreamReader r, com.fasterxml.jackson.core.type.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 Stax `XMLStreamReader` with data-binding by Jackson.
`<T> T` `readValue​(javax.xml.stream.XMLStreamReader r, com.fasterxml.jackson.databind.JavaType valueType)` Method for reading a single XML value from given XML-specific input source; useful for incremental data-binding, combining traversal using basic Stax `XMLStreamReader` 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 Stax `XMLStreamReader` with data-binding by Jackson.
`XmlMapper` `setDefaultUseWrapper​(boolean state)` Deprecated. Since 2.10 use `XmlMapper.Builder.defaultUseWrapper(boolean)` instead
`protected void` `setXMLTextElementName​(java.lang.String name)` Deprecated. Since 2.10 use `XmlMapper.Builder.nameForTextElement(String)` instead
`com.fasterxml.jackson.core.Version` `version()`
`void` `writeValue​(javax.xml.stream.XMLStreamWriter w0, java.lang.Object value)` Method for serializing given value using specific `XMLStreamReader`: 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

`_assertNotNull, _checkInvalidCopy, _configAndWriteValue, _convert, _findRootDeserializer, _initForReading, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _unwrapAndDeserialize, _verifyNoTrailingTokens, _verifySchemaType, acceptJsonFormatVisitor, acceptJsonFormatVisitor, activateDefaultTyping, activateDefaultTyping, activateDefaultTyping, activateDefaultTypingAsProperty, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, configOverride, configure, configure, configure, configure, configure, constructType, convertValue, convertValue, convertValue, createArrayNode, createDeserializationContext, createObjectNode, deactivateDefaultTyping, defaultClassIntrospector, 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, getJsonFactory, 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, 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, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setConfig, setConfig, setDateFormat, 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, 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 java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### DEFAULT_XML_MODULE

    protected static final JacksonXmlModule DEFAULT_XML_MODULE

#### DEFAULT_XML_PRETTY_PRINTER

    protected static final DefaultXmlPrettyPrinter DEFAULT_XML_PRETTY_PRINTER

#### _xmlModule

    protected final JacksonXmlModule _xmlModule

### 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)

#### XmlMapper

    protected XmlMapper​(XmlMapper src)

Since:
  2.8.9

### Method Detail

#### copy

    public XmlMapper copy()

Overrides:
  `copy` in class `com.fasterxml.jackson.databind.ObjectMapper`

#### 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 com.fasterxml.jackson.core.Version version()

Specified by:
  `version` in interface `com.fasterxml.jackson.core.Versioned`
Overrides:
  `version` in class `com.fasterxml.jackson.databind.ObjectMapper`

#### _constructDefaultTypeResolverBuilder

    protected com.fasterxml.jackson.databind.jsontype.TypeResolverBuilder<?> _constructDefaultTypeResolverBuilder​(com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping applicability,
                                                                                                                  com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator ptv)

Overrides:
  `_constructDefaultTypeResolverBuilder` in class `com.fasterxml.jackson.databind.ObjectMapper`

#### setXMLTextElementName

    @Deprecated
    protected void setXMLTextElementName​(java.lang.String name)

Deprecated.
Since 2.10 use `XmlMapper.Builder.nameForTextElement(String)` instead
Method called by `JacksonXmlModule` to pass configuration information to `XmlFactory`, during registration; NOT exposed as public method since configuration should be done via `JacksonXmlModule`.

Since:
  2.1

#### setDefaultUseWrapper

    @Deprecated
    public XmlMapper setDefaultUseWrapper​(boolean state)

Deprecated.
Since 2.10 use `XmlMapper.Builder.defaultUseWrapper(boolean)` instead
Since 2.7

#### getFactory

    public XmlFactory getFactory()

Overrides:
  `getFactory` in class `com.fasterxml.jackson.databind.ObjectMapper`

#### configure

    public com.fasterxml.jackson.databind.ObjectMapper configure​(ToXmlGenerator.Feature f,
                                                                 boolean state)

#### configure

    public com.fasterxml.jackson.databind.ObjectMapper configure​(FromXmlParser.Feature f,
                                                                 boolean state)

#### enable

    public com.fasterxml.jackson.databind.ObjectMapper enable​(ToXmlGenerator.Feature f)

#### enable

    public com.fasterxml.jackson.databind.ObjectMapper enable​(FromXmlParser.Feature f)

#### disable

    public com.fasterxml.jackson.databind.ObjectMapper disable​(ToXmlGenerator.Feature f)

#### disable

    public com.fasterxml.jackson.databind.ObjectMapper disable​(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 Stax `XMLStreamReader` with data-binding by Jackson.

Throws:
  `java.io.IOException`
Since:
  2.4

#### readValue

    public <T> T readValue​(javax.xml.stream.XMLStreamReader r,
                           com.fasterxml.jackson.core.type.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 Stax `XMLStreamReader` with data-binding by Jackson.

Throws:
  `java.io.IOException`
Since:
  2.4

#### readValue

    public <T> T readValue​(javax.xml.stream.XMLStreamReader r,
                           com.fasterxml.jackson.databind.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 Stax `XMLStreamReader` 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 specific `XMLStreamReader`: useful when building large XML files by binding individual items, one at a time.

Throws:
  `java.io.IOException`
Since:
  2.4