public class SpincastXmlManager extends Object implements XmlManager
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
SpincastXmlManager.JsonArrayMixIn |
protected static interface |
SpincastXmlManager.JsonObjectMixIn |
| Constructor and Description |
|---|
SpincastXmlManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider,
JsonManager jsonManager,
Set<XmlMixinInfo> xmlMixinInfos,
com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter xmlPrettyPrinter) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addJsonArrayMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
Specifies the root element name when serializing
a JsonArray
|
protected void |
addJsonObjectMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
Specifies the root element name when serializing
a JsonObject
|
protected void |
addSpincastMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) |
protected void |
configureEmptyBeans(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) |
protected void |
configureMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper) |
protected void |
configureXmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
Configuration of the XmlMapper.
|
protected com.fasterxml.jackson.dataformat.xml.XmlMapper |
createXmlMapper()
Creates the XmlMapper
|
protected JsonArray |
deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context) |
protected JsonArray |
deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context,
boolean firstElementSkipped) |
protected JsonObject |
deserializeJsonObject(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context,
Map.Entry<String,Object> firstProperty) |
protected Object |
deserializeObjectOrArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context) |
JsonObject |
fromXml(String xml)
Deserializes a XML to an
JsonObject. |
<T> T |
fromXml(String xml,
Class<T> clazz)
Deserializes a XML to the given Class.
|
<T> T |
fromXmlInputStream(InputStream inputStream,
Class<T> clazz)
Deserializes a XML inputstream to the given Type.
|
JsonArray |
fromXmlToJsonArray(String xml)
Deserializes a XML to an
JsonArray. |
<T> T |
fromXmlToType(String xml,
Type type)
Deserializes a XML to the given Type.
|
protected String |
getArrayAttributeName()
The name of the attribute set on a XML element to indicate it
comes from a JsonArray.
|
protected com.google.inject.Injector |
getGuice() |
protected com.fasterxml.jackson.databind.JsonDeserializer<JsonArray> |
getJsonArrayDeserializer() |
protected com.fasterxml.jackson.databind.JsonSerializer<JsonArray> |
getJsonArraySerializer() |
protected JsonManager |
getJsonManager() |
protected com.fasterxml.jackson.databind.JsonDeserializer<JsonObject> |
getJsonObjectDeserializer() |
protected com.fasterxml.jackson.databind.JsonSerializer<JsonObject> |
getJsonObjectSerializer() |
protected com.fasterxml.jackson.dataformat.xml.XmlMapper |
getXmlMapper() |
protected com.fasterxml.jackson.dataformat.xml.XmlMapper |
getXmlMapperPretty() |
protected Set<XmlMixinInfo> |
getXmlMixinInfos() |
protected com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter |
getXmlPrettyPrinter() |
protected void |
injectDependencies(Object obj)
Once the deserialization of an Object is done,
we inject dependencies using Guice.
|
protected void |
registerCustomModules(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper) |
protected void |
registerJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper)
Register our custom (de)serializers for JsonObject
|
String |
toXml(Object obj)
Converts an object to XML.
|
String |
toXml(Object obj,
boolean pretty)
Converts an object to XML.
|
@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)
protected com.google.inject.Injector getGuice()
protected JsonManager getJsonManager()
protected Set<XmlMixinInfo> getXmlMixinInfos()
protected com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter getXmlPrettyPrinter()
protected com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapper()
protected com.fasterxml.jackson.dataformat.xml.XmlMapper createXmlMapper()
protected void configureXmlMapper(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected void configureEmptyBeans(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected void configureMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected void addSpincastMixins(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected void addJsonObjectMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected void addJsonArrayMixin(com.fasterxml.jackson.dataformat.xml.XmlMapper xmlMapper)
protected com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapperPretty()
protected String getArrayAttributeName()
protected com.fasterxml.jackson.databind.JsonSerializer<JsonObject> getJsonObjectSerializer()
protected com.fasterxml.jackson.databind.JsonSerializer<JsonArray> getJsonArraySerializer()
protected com.fasterxml.jackson.databind.JsonDeserializer<JsonObject> getJsonObjectDeserializer()
protected com.fasterxml.jackson.databind.JsonDeserializer<JsonArray> getJsonArrayDeserializer()
protected Object deserializeObjectOrArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context)
protected JsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context)
protected JsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, boolean firstElementSkipped)
protected JsonObject deserializeJsonObject(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser, com.fasterxml.jackson.databind.DeserializationContext context, Map.Entry<String,Object> firstProperty)
protected void registerCustomModules(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper)
protected void registerJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper)
public String toXml(Object obj)
XmlManagerJsonObject, its elements
of type "JsonArray" will have a "isArray='true'" attribute
added. This way, the XML can be deserialized back to a
JsonObject correctly.toXml in interface XmlManagerpublic String toXml(Object obj, boolean pretty)
XmlManagertoXml in interface XmlManagerpretty - If true, the generated XML will
be formatted.public JsonObject fromXml(String xml)
XmlManagerJsonObject. This
will correctly manage the XML generated by
toXml(), arrays included.fromXml in interface XmlManagerpublic JsonArray fromXmlToJsonArray(String xml)
XmlManagerJsonArray. This
will correctly manage the XML generated by
toXml(), arrays included.fromXmlToJsonArray in interface XmlManagerpublic <T> T fromXml(String xml, Class<T> clazz)
XmlManagerJsonObject to get the
arrays to work out of the box!fromXml in interface XmlManagerprotected void injectDependencies(Object obj)
public <T> T fromXmlToType(String xml, Type type)
XmlManagerJsonObject to get the
arrays to work out of the box!fromXmlToType in interface XmlManagerpublic <T> T fromXmlInputStream(InputStream inputStream, Class<T> clazz)
XmlManagerJsonObject to get the
arrays to work out of the box!fromXmlInputStream in interface XmlManagerCopyright © 2018. All rights reserved.