Class ElementMapper


  • public abstract class ElementMapper
    extends Object
    Author:
    Luca Frosini (ISTI - CNR)
    • Field Detail

      • mapper

        protected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapper mapper
    • Constructor Detail

      • ElementMapper

        public ElementMapper()
    • Method Detail

      • getObjectMapper

        public static org.gcube.com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        Returns:
        the ObjectMapper
      • registerSubtype

        public static <El extends Element> void registerSubtype​(Class<El> clz)
      • marshal

        public static <T extends OutputStream,​El extends Element> T marshal​(El object,
                                                                                  T stream)
                                                                           throws org.gcube.com.fasterxml.jackson.core.JsonGenerationException,
                                                                                  org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                                                  IOException
        Write the serialization of a given resource to a given OutputStream .
        Parameters:
        object - the resource
        stream - the stream in input
        Throws:
        IOException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        org.gcube.com.fasterxml.jackson.core.JsonGenerationException
      • marshal

        public static <T extends Writer,​El extends Element> T marshal​(El object,
                                                                            T writer)
                                                                     throws org.gcube.com.fasterxml.jackson.core.JsonGenerationException,
                                                                            org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                                            IOException
        Write the serialization of a given resource to a given Writer .
        Parameters:
        object - the resource
        writer - the writer in input
        Throws:
        IOException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        org.gcube.com.fasterxml.jackson.core.JsonGenerationException
      • marshal

        public static <El extends ElementString marshal​(El object)
                                                   throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
        Return the String serialization of a given object
        Parameters:
        object - the object to marshal
        Returns:
        the String serialization of a given resource
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      • marshal

        public static <El extends ElementString marshal​(List<El> list)
                                                   throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
        Return the String serialization of a given list
        Parameters:
        list - the list to marshal
        Returns:
        the String serialization of a given list
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      • marshal

        public static <El extends ElementString marshal​(El[] array)
                                                   throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
        Return the String serialization of a given array
        Parameters:
        array - the array to marshal
        Returns:
        the String serialization of a given array
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      • setTypeToBestAvailable

        protected static org.gcube.com.fasterxml.jackson.databind.node.ObjectNode setTypeToBestAvailable​(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode objectNode)
      • analizeTypes

        protected static org.gcube.com.fasterxml.jackson.databind.JsonNode analizeTypes​(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode objectNode)
      • analizeTypes

        protected static org.gcube.com.fasterxml.jackson.databind.node.ArrayNode analizeTypes​(org.gcube.com.fasterxml.jackson.databind.node.ArrayNode arrayNode)
      • unmarshal

        public static <El extends Element> El unmarshal​(Class<El> clz,
                                                        Reader reader)
                                                 throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                        org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                        IOException
        Creates a resource of given class from its serialization in a given Reader.
        Parameters:
        clz - the class of the resource
        reader - the reader
        Returns:
        the resource
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonParseException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        IOException
      • unmarshal

        public static <El extends Element> El unmarshal​(Class<El> clz,
                                                        InputStream stream)
                                                 throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                        org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                        IOException
        Creates a resource of given class from its serialization in a given InputStream.
        Parameters:
        clz - the class of the resource
        stream - the stream
        Returns:
        the resource
        Throws:
        IOException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        org.gcube.com.fasterxml.jackson.core.JsonParseException
      • unmarshal

        public static <El extends Element> El unmarshal​(Class<El> clz,
                                                        String string)
                                                 throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                        org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                        IOException
        Creates a resource of given class from its serialization in a given String
        Parameters:
        clz - the class of the resource
        string -
        Returns:
        the resource
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonParseException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        IOException
      • unmarshalList

        public static <El extends ElementList<El> unmarshalList​(Class<El> clz,
                                                                  String string)
                                                           throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                                  org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                                  IOException
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonParseException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        IOException
      • unmarshalList

        public static <El extends ElementList<El> unmarshalList​(String string)
                                                           throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                                  org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                                  IOException
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonParseException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        IOException