public.javadoc.org.spincast.plugins.jacksonxml.SpincastXmlManager.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
The newest version!
SpincastXmlManager (org.spincast:spincast-framework 0.9.28 API)
org.spincast.plugins.jacksonxml
Class SpincastXmlManager
- java.lang.Object
-
- org.spincast.plugins.jacksonxml.SpincastXmlManager
-
- All Implemented Interfaces:
- IXmlManager
public class SpincastXmlManager
extends Object
implements IXmlManager
Spincast Jackson XML manager
-
-
Constructor Summary
Constructors
Constructor and Description
SpincastXmlManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider,
IJsonManager jsonManager,
Set<IXmlMixinInfo> xmlMixinInfos,
com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter xmlPrettyPrinter)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
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 IJsonArray
deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context)
protected IJsonArray
deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context,
boolean firstElementSkipped)
protected IJsonObject
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)
IJsonObject
fromXml(String xml)
Deserializes a XML to an IJsonObject.
<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.
IJsonArray
fromXmlToJsonArray(String xml)
Deserializes a XML to an IJsonArray.
<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 IJsonArray.
protected com.google.inject.Injector
getGuice()
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonArray>
getJsonArrayDeserializer()
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonArray>
getJsonArraySerializer()
protected IJsonManager
getJsonManager()
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonObject>
getJsonObjectDeserializer()
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonObject>
getJsonObjectSerializer()
protected com.fasterxml.jackson.dataformat.xml.XmlMapper
getXmlMapper()
protected com.fasterxml.jackson.dataformat.xml.XmlMapper
getXmlMapperPretty()
protected Set<IXmlMixinInfo>
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
registerIJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper)
Register our custom (de)serializers for IJsonObject
String
toXml(Object obj)
Converts an object to XML.
String
toXml(Object obj,
boolean pretty)
Converts an object to XML.
-
-
Constructor Detail
-
SpincastXmlManager
@Inject
public SpincastXmlManager(com.google.inject.Provider<com.google.inject.Injector> guiceProvider,
IJsonManager jsonManager,
@Nullable
Set<IXmlMixinInfo> xmlMixinInfos,
com.fasterxml.jackson.dataformat.xml.XmlPrettyPrinter xmlPrettyPrinter)
-
Method Detail
-
getGuice
protected com.google.inject.Injector getGuice()
-
getJsonManager
protected IJsonManager getJsonManager()
-
getXmlMixinInfos
protected Set<IXmlMixinInfo> 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)
-
getXmlMapperPretty
protected com.fasterxml.jackson.dataformat.xml.XmlMapper getXmlMapperPretty()
-
getArrayAttributeName
protected String getArrayAttributeName()
The name of the attribute set on a XML element to indicate it
comes from a IJsonArray. This allows us to deserialize the XML
back to the correct structure.
-
getJsonObjectSerializer
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonObject> getJsonObjectSerializer()
-
getJsonArraySerializer
protected com.fasterxml.jackson.databind.JsonSerializer<IJsonArray> getJsonArraySerializer()
-
getJsonObjectDeserializer
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonObject> getJsonObjectDeserializer()
-
getJsonArrayDeserializer
protected com.fasterxml.jackson.databind.JsonDeserializer<IJsonArray> getJsonArrayDeserializer()
-
deserializeObjectOrArray
protected Object deserializeObjectOrArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context)
-
deserializeJsonArray
protected IJsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context)
-
deserializeJsonArray
protected IJsonArray deserializeJsonArray(com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser xmlParser,
com.fasterxml.jackson.databind.DeserializationContext context,
boolean firstElementSkipped)
-
deserializeJsonObject
protected IJsonObject 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)
-
registerIJsonObjectModule
protected void registerIJsonObjectModule(com.fasterxml.jackson.dataformat.xml.XmlMapper objectMapper)
Register our custom (de)serializers for IJsonObject
-
toXml
public String toXml(Object obj)
Description copied from interface: IXmlManager
Converts an object to XML.
If the object to convert is a IJsonObject, its elements
of type "IJsonArray" will have a "isArray='true'" attribute
added. This way, the XML can be deserialized back to a
IJsonObject correctly.
- Specified by:
toXml in interface IXmlManager
-
toXml
public String toXml(Object obj,
boolean pretty)
Description copied from interface: IXmlManager
Converts an object to XML.
- Specified by:
toXml in interface IXmlManager
pretty - If true, the generated XML will
be formatted.
-
fromXml
public IJsonObject fromXml(String xml)
Description copied from interface: IXmlManager
Deserializes a XML to an IJsonObject. This
will correctly manage the XML generated by
toXml(), arrays included.
- Specified by:
fromXml in interface IXmlManager
-
fromXmlToJsonArray
public IJsonArray fromXmlToJsonArray(String xml)
Description copied from interface: IXmlManager
Deserializes a XML to an IJsonArray. This
will correctly manage the XML generated by
toXml(), arrays included.
- Specified by:
fromXmlToJsonArray in interface IXmlManager
-
fromXml
public <T> T fromXml(String xml,
Class<T> clazz)
Description copied from interface: IXmlManager
Deserializes 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 a IJsonObject to get the
arrays to work out of the box!
- Specified by:
fromXml in interface IXmlManager
-
injectDependencies
protected void injectDependencies(Object obj)
Once the deserialization of an Object is done,
we inject dependencies using Guice.
-
fromXmlToType
public <T> T fromXmlToType(String xml,
Type type)
Description copied from interface: IXmlManager
Deserializes 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 a IJsonObject to get the
arrays to work out of the box!
- Specified by:
fromXmlToType in interface IXmlManager
-
fromXmlInputStream
public <T> T fromXmlInputStream(InputStream inputStream,
Class<T> clazz)
Description copied from interface: IXmlManager
Deserializes 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 a IJsonObject to get the
arrays to work out of the box!
- Specified by:
fromXmlInputStream in interface IXmlManager
Copyright © 2016. All rights reserved.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy