java.lang.Object
tools.jackson.databind.ObjectMapper
tools.jackson.dataformat.xml.XmlMapper
All Implemented Interfaces:
Serializable, tools.jackson.core.TreeCodec, tools.jackson.core.Versioned

public class XmlMapper extends tools.jackson.databind.ObjectMapper
Customized ObjectMapper that will read and write XML instead of JSON, using XML-backed TokenStreamFactory implementation (XmlFactory), operation on STAX XMLStreamReaders and XMLStreamWriters.

Mapper itself overrides some aspects of functionality to try to handle data binding aspects as similar to JAXB as possible.

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Builder implementation for constructing XmlMapper instances.
    protected static class 
    Saved configuration entity to use with builder for XmlMapper instances.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final DefaultXmlPrettyPrinter
     

    Fields inherited from class tools.jackson.databind.ObjectMapper

    _deserializationConfig, _deserializationContexts, _injectableValues, _rootDeserializers, _savedBuilderState, _serializationConfig, _serializationContexts, _streamFactory, _typeFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    XmlMapper(XmlFactory xmlFactory)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    builder(XmlFactory streamFactory)
     
    The builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.
    Overloaded variant that allows constructing ToXmlGenerator for given Stax XMLStreamWriter.
    Overloaded variant that allows constructing FromXmlParser for given Stax XMLStreamReader.
    protected Object
     
    <T> T
    readValue(XMLStreamReader r, 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.
    <T> T
    readValue(XMLStreamReader r, tools.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(XMLStreamReader r, tools.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.
     
    static XmlMapper
    Accessor method for getting globally shared "default" XmlMapper instance: one that has default configuration, no (custom) modules registered, no config overrides.
     
    tools.jackson.core.Version
     
    protected Object
     
    void
    Method for serializing given value using specific XMLStreamReader: useful when building large XML files by binding individual items, one at a time.
     

    Methods inherited from class tools.jackson.databind.ObjectMapper

    _assertNotNull, _configAndWriteValue, _convert, _deserializationContext, _deserializationContext, _deserializationContext, _findRootDeserializer, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializationContext, _serializationContext, _verifyNoTrailingTokens, _verifySchemaType, _writeCloseableValue, acceptJsonFormatVisitor, acceptJsonFormatVisitor, acceptJsonFormatVisitor, booleanNode, clearCaches, constructType, constructType, convertValue, convertValue, convertValue, createArrayNode, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createNonBlockingByteBufferParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deserializationConfig, getInjectableValues, getNodeFactory, getTypeFactory, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, nullNode, 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, 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, readValue, readValue, readValue, readValue, readValues, readValues, readValues, registeredModules, serializationConfig, stringNode, treeAsTokens, treeToValue, treeToValue, treeToValue, updateValue, valueToTree, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithView, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsString, writeValueIntoBuffer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • xmlBuilder

      public static XmlMapper.Builder xmlBuilder()
    • builder

      public static XmlMapper.Builder builder()
    • builder

      public static XmlMapper.Builder builder(XmlFactory streamFactory)
    • builderWithJackson2Defaults

      public static XmlMapper.Builder builderWithJackson2Defaults()
      The builder returned uses default settings more closely matching the default configs used in Jackson 2.x versions.

      This method is still a work in progress and may not yet fully replicate the default settings of Jackson 2.x.

    • rebuild

      public XmlMapper.Builder rebuild()
      Overrides:
      rebuild in class tools.jackson.databind.ObjectMapper
    • writeReplace

      protected Object writeReplace()
      Overrides:
      writeReplace in class tools.jackson.databind.ObjectMapper
    • readResolve

      protected Object readResolve()
      Overrides:
      readResolve in class tools.jackson.databind.ObjectMapper
    • shared

      public static XmlMapper shared()
      Accessor method for getting globally shared "default" XmlMapper instance: one that has default configuration, no (custom) modules registered, no config overrides. Usable mostly when dealing "untyped" or Tree-style content reading and writing.
    • version

      public tools.jackson.core.Version version()
      Specified by:
      version in interface tools.jackson.core.Versioned
      Overrides:
      version in class tools.jackson.databind.ObjectMapper
    • tokenStreamFactory

      public XmlFactory tokenStreamFactory()
      Overrides:
      tokenStreamFactory in class tools.jackson.databind.ObjectMapper
    • createParser

      public FromXmlParser createParser(XMLStreamReader r) throws IOException
      Overloaded variant that allows constructing FromXmlParser for given Stax XMLStreamReader.
      Throws:
      IOException
    • createGenerator

      public ToXmlGenerator createGenerator(XMLStreamWriter w) throws IOException
      Overloaded variant that allows constructing ToXmlGenerator for given Stax XMLStreamWriter.
      Throws:
      IOException
    • readValue

      public <T> T readValue(XMLStreamReader r, Class<T> valueType) throws 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:
      IOException
    • readValue

      public <T> T readValue(XMLStreamReader r, tools.jackson.core.type.TypeReference<T> valueTypeRef) throws 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:
      IOException
    • readValue

      public <T> T readValue(XMLStreamReader r, tools.jackson.databind.JavaType valueType) throws 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:
      IOException
    • writeValue

      public void writeValue(XMLStreamWriter w, Object value) throws IOException
      Method for serializing given value using specific XMLStreamReader: useful when building large XML files by binding individual items, one at a time.
      Throws:
      IOException