All Downloads are FREE. Search and download functionalities are using the official Maven repository.

public.javadoc.org.spincast.plugins.jacksonxml.SpincastXmlManager.html Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version






SpincastXmlManager (org.spincast:spincast-framework 1.0.0 API)












org.spincast.plugins.jacksonxml

Class SpincastXmlManager

  • All Implemented Interfaces:
    XmlManager


    public class SpincastXmlManager
    extends Object
    implements XmlManager
    Spincast Jackson XML manager
    • Constructor Detail

      • 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 Detail

      • getGuice

        protected com.google.inject.Injector getGuice()
      • getJsonManager

        protected JsonManager getJsonManager()
      • 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

        protected String 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

        protected com.fasterxml.jackson.databind.JsonSerializer<JsonObject> getJsonObjectSerializer()
      • getJsonArraySerializer

        protected com.fasterxml.jackson.databind.JsonSerializer<JsonArray> getJsonArraySerializer()
      • getJsonObjectDeserializer

        protected com.fasterxml.jackson.databind.JsonDeserializer<JsonObject> getJsonObjectDeserializer()
      • getJsonArrayDeserializer

        protected com.fasterxml.jackson.databind.JsonDeserializer<JsonArray> 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

        public String toXml(Object obj)
        Description copied from interface: XmlManager
        Converts an object to XML. If the object to convert is a JsonObject, its elements of type "JsonArray" will have a "isArray='true'" attribute added. This way, the XML can be deserialized back to a JsonObject correctly.
        Specified by:
        toXml in interface XmlManager
      • toXml

        public String toXml(Object obj,
                            boolean pretty)
        Description copied from interface: XmlManager
        Converts an object to XML.
        Specified by:
        toXml in interface XmlManager
        pretty - If true, the generated XML will be formatted.
      • fromXml

        public JsonObject fromXml(String xml)
        Description copied from interface: XmlManager
        Deserializes a XML to an JsonObject. This will correctly manage the XML generated by toXml(), arrays included.
        Specified by:
        fromXml in interface XmlManager
      • fromXmlToJsonArray

        public JsonArray fromXmlToJsonArray(String xml)
        Description copied from interface: XmlManager
        Deserializes a XML to an JsonArray. This will correctly manage the XML generated by toXml(), arrays included.
        Specified by:
        fromXmlToJsonArray in interface XmlManager
      • fromXml

        public <T> T fromXml(String xml,
                             Class<T> clazz)
        Description copied from interface: XmlManager
        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 JsonObject to get the arrays to work out of the box!
        Specified by:
        fromXml in interface XmlManager
      • 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: XmlManager
        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 JsonObject to get the arrays to work out of the box!
        Specified by:
        fromXmlToType in interface XmlManager
      • fromXmlInputStream

        public <T> T fromXmlInputStream(InputStream inputStream,
                                        Class<T> clazz)
        Description copied from interface: XmlManager
        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 JsonObject to get the arrays to work out of the box!
        Specified by:
        fromXmlInputStream in interface XmlManager

Copyright © 2019. All rights reserved.





© 2015 - 2024 Weber Informatics LLC | Privacy Policy