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
,Serializable
public class XmlMapper extends com.fasterxml.jackson.databind.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
-
-
Field Summary
Fields Modifier and Type Field Description 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 Modifier Constructor Description XmlMapper()
XmlMapper(JacksonXmlModule module)
XmlMapper(XmlFactory xmlFactory)
XmlMapper(XmlFactory xmlFactory, JacksonXmlModule module)
protected
XmlMapper(XmlMapper src)
XmlMapper(XMLInputFactory inputF)
XmlMapper(XMLInputFactory inputF, XMLOutputFactory outF)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected com.fasterxml.jackson.core.PrettyPrinter
_defaultPrettyPrinter()
Deprecated.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(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 StaxXMLStreamReader
with data-binding by Jackson.<T> T
readValue(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 StaxXMLStreamReader
with data-binding by Jackson.<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 StaxXMLStreamReader
with data-binding by Jackson.XmlMapper
setDefaultUseWrapper(boolean state)
Since 2.7protected void
setXMLTextElementName(String name)
Method called byJacksonXmlModule
to pass configuration information toXmlFactory
, during registration; NOT exposed as public method since configuration should be done viaJacksonXmlModule
.com.fasterxml.jackson.core.Version
version()
void
writeValue(XMLStreamWriter w0, Object value)
Method for serializing given value using specificXMLStreamReader
: useful when building large XML files by binding individual items, one at a time.-
Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper
_checkInvalidCopy, _configAndWriteValue, _convert, _findRootDeserializer, _initForReading, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _unwrapAndDeserialize, _verifyNoTrailingTokens, _verifySchemaType, acceptJsonFormatVisitor, acceptJsonFormatVisitor, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, configOverride, configure, configure, configure, configure, configure, constructType, convertValue, convertValue, convertValue, createArrayNode, createDeserializationContext, createObjectNode, 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, getPropertyNamingStrategy, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, mixInCount, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, readerForUpdating, readerWithView, 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, setDefaultMergeable, setDefaultPrettyPrinter, setDefaultPropertyInclusion, setDefaultPropertyInclusion, setDefaultSetterInfo, setDefaultTyping, setDefaultVisibility, setFilterProvider, setFilters, setHandlerInstantiator, setInjectableValues, setLocale, setMixInAnnotations, setMixInResolver, setMixIns, setNodeFactory, setPropertyInclusion, setPropertyNamingStrategy, setSerializationInclusion, setSerializerFactory, setSerializerProvider, setSubtypeResolver, setTimeZone, setTypeFactory, setVisibility, setVisibility, setVisibilityChecker, 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
-
-
-
-
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(XMLInputFactory inputF, XMLOutputFactory outF)
- Since:
- 2.4
-
XmlMapper
public XmlMapper(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 classcom.fasterxml.jackson.databind.ObjectMapper
-
version
public com.fasterxml.jackson.core.Version version()
- Specified by:
version
in interfacecom.fasterxml.jackson.core.Versioned
- Overrides:
version
in classcom.fasterxml.jackson.databind.ObjectMapper
-
setXMLTextElementName
protected void setXMLTextElementName(String name)
Method called byJacksonXmlModule
to pass configuration information toXmlFactory
, during registration; NOT exposed as public method since configuration should be done viaJacksonXmlModule
.- Since:
- 2.1
-
setDefaultUseWrapper
public XmlMapper setDefaultUseWrapper(boolean state)
Since 2.7
-
getFactory
public XmlFactory getFactory()
- Overrides:
getFactory
in classcom.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(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 StaxXMLStreamReader
with data-binding by Jackson.- Throws:
IOException
- Since:
- 2.4
-
readValue
public <T> T readValue(XMLStreamReader r, com.fasterxml.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 StaxXMLStreamReader
with data-binding by Jackson.- Throws:
IOException
- Since:
- 2.4
-
readValue
public <T> T readValue(XMLStreamReader r, com.fasterxml.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 StaxXMLStreamReader
with data-binding by Jackson.- Throws:
IOException
- Since:
- 2.4
-
writeValue
public void writeValue(XMLStreamWriter w0, Object value) throws IOException
Method for serializing given value using specificXMLStreamReader
: useful when building large XML files by binding individual items, one at a time.- Throws:
IOException
- Since:
- 2.4
-
_defaultPrettyPrinter
@Deprecated protected com.fasterxml.jackson.core.PrettyPrinter _defaultPrettyPrinter()
Deprecated.
-
-