Package org.spincast.plugins.jacksonxml
Class SpincastXmlManager
java.lang.Object
org.spincast.plugins.jacksonxml.SpincastXmlManager
- All Implemented Interfaces:
XmlManager
Spincast Jackson XML manager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static interface -
Constructor Summary
ConstructorsConstructorDescriptionSpincastXmlManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider, JsonManager jsonManager, Set<XmlMixinInfo> xmlMixinInfos, com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter xmlPrettyPrinter) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddJsonArrayMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Specifies the root element name when serializing a JsonArrayprotected voidaddJsonObjectMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Specifies the root element name when serializing a JsonObjectprotected voidaddSpincastMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) protected voidconfigureEmptyBeans(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) protected voidconfigureMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) protected voidconfigureXmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Configuration of the XmlMapper.protected com.fasterxml.jackson.dataformat.xml.XmlMapperCreates the XmlMapperprotected JsonArraydeserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context) protected JsonArraydeserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, boolean firstElementSkipped) protected JsonObjectdeserializeJsonObject(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, Map.Entry<String, Object> firstProperty) protected ObjectdeserializeObjectOrArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context) Deserializes a XML to anJsonObject.<T> TDeserializes a XML to the given Class.<T> TfromXmlInputStream(InputStream inputStream, Class<T> clazz) Deserializes a XML inputstream to the given Type.fromXmlToJsonArray(String xml) Deserializes a XML to anJsonArray.<T> TfromXmlToType(String xml, Type type) Deserializes a XML to the given Type.protected StringThe name of the attribute set on a XML element to indicate it comes from a JsonArray.protected com.google.inject.InjectorgetGuice()protected com.fasterxml.jackson.databind.JsonDeserializer<JsonArray>protected com.fasterxml.jackson.databind.JsonSerializer<JsonArray>protected JsonManagerprotected com.fasterxml.jackson.databind.JsonDeserializer<JsonObject>protected com.fasterxml.jackson.databind.JsonSerializer<JsonObject>protected com.fasterxml.jackson.dataformat.xml.XmlMapperprotected com.fasterxml.jackson.dataformat.xml.XmlMapperprotected Set<XmlMixinInfo>protected com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinterprotected voidinjectDependencies(Object obj) Once the deserialization of an Object is done, we inject dependencies using Guice.protected voidregisterCustomModules(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper) protected voidregisterJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper) Register our custom (de)serializers for JsonObjectConverts an object to XML.Converts an object to XML.
-
Constructor Details
-
SpincastXmlManager
@Inject public SpincastXmlManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider, JsonManager jsonManager, @Nullable Set<XmlMixinInfo> xmlMixinInfos, com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter xmlPrettyPrinter)
-
-
Method Details
-
getGuice
protected com.google.inject.Injector getGuice() -
getJsonManager
-
getXmlMixinInfos
-
getXmlPrettyPrinter
protected com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter getXmlPrettyPrinter() -
getXmlMapper
protected com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapper() -
createXmlMapper
protected com.fasterxml.jackson.dataformat.xml.XmlMapper createXmlMapper()Creates the XmlMapper -
configureXmlMapper
protected void configureXmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Configuration of the XmlMapper. -
configureEmptyBeans
protected void configureEmptyBeans(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) -
configureMixins
protected void configureMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) -
addSpincastMixins
protected void addSpincastMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) -
addJsonObjectMixin
protected void addJsonObjectMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Specifies the root element name when serializing a JsonObject -
addJsonArrayMixin
protected void addJsonArrayMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) Specifies the root element name when serializing a JsonArray -
getXmlMapperPretty
protected com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapperPretty() -
getArrayAttributeName
The name of the attribute set on a XML element to indicate it comes from a JsonArray. This allows us to deserialize the XML back to the correct structure. -
getJsonObjectSerializer
-
getJsonArraySerializer
-
getJsonObjectDeserializer
-
getJsonArrayDeserializer
-
deserializeObjectOrArray
protected Object deserializeObjectOrArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context) -
deserializeJsonArray
protected JsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context) -
deserializeJsonArray
protected JsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, boolean firstElementSkipped) -
deserializeJsonObject
protected JsonObject deserializeJsonObject(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, Map.Entry<String, Object> firstProperty) -
registerCustomModules
protected void registerCustomModules(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper) -
registerJsonObjectModule
protected void registerJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper) Register our custom (de)serializers for JsonObject -
toXml
Description copied from interface:XmlManagerConverts an object to XML. If the object to convert is aJsonObject, its elements of type "JsonArray" will have a "isArray='true'" attribute added. This way, the XML can be deserialized back to aJsonObjectcorrectly.- Specified by:
toXmlin interfaceXmlManager
-
toXml
Description copied from interface:XmlManagerConverts an object to XML.- Specified by:
toXmlin interfaceXmlManagerpretty- Iftrue, the generated XML will be formatted.
-
fromXml
Description copied from interface:XmlManagerDeserializes a XML to anJsonObject. This will correctly manage the XML generated by toXml(), arrays included.- Specified by:
fromXmlin interfaceXmlManager
-
fromXmlToJsonArray
Description copied from interface:XmlManagerDeserializes a XML to anJsonArray. This will correctly manage the XML generated by toXml(), arrays included.- Specified by:
fromXmlToJsonArrayin interfaceXmlManager
-
fromXml
Description copied from interface:XmlManagerDeserializes a XML to the given Class. Be aware that if you use a default Type like Map<String, Object>, the arrays will probably won't be deserialized correctly. Use the version returning aJsonObjectto get the arrays to work out of the box!- Specified by:
fromXmlin interfaceXmlManager
-
injectDependencies
Once the deserialization of an Object is done, we inject dependencies using Guice. -
fromXmlToType
Description copied from interface:XmlManagerDeserializes a XML to the given Type. Be aware that if you use a default Type like Map<String, Object>, the arrays will probably won't be deserialized correctly. Use the version returning aJsonObjectto get the arrays to work out of the box!- Specified by:
fromXmlToTypein interfaceXmlManager
-
fromXmlInputStream
Description copied from interface:XmlManagerDeserializes a XML inputstream to the given Type. Be aware that if you use a default Type like Map<String, Object>, the arrays will probably won't be deserialized correctly. Use the version returning aJsonObjectto get the arrays to work out of the box!- Specified by:
fromXmlInputStreamin interfaceXmlManager
-