Class DSMapper


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

      • mapper

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

      • getObjectMapper

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

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

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

        public static <R extends RecordString marshal​(R record)
                                                 throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException
        Return the String serialization of a given Record
        Parameters:
        record - the resource
        Returns:
        the String serialization of a given Record
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonProcessingException
      • marshal

        public static <R extends RecordString marshal​(List<R> 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 <R extends RecordString marshal​(R[] 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
      • unmarshal

        public static <R extends Record> R unmarshal​(Class<R> 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 <R extends Record> R unmarshal​(Class<R> 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 <R extends Record> R unmarshal​(Class<R> clz,
                                                     String string)
                                              throws org.gcube.com.fasterxml.jackson.core.JsonParseException,
                                                     org.gcube.com.fasterxml.jackson.databind.JsonMappingException,
                                                     IOException
        Creates a record of given class from its serialization in a given String
        Parameters:
        clz - the class of the record
        string -
        Returns:
        the record
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonParseException
        org.gcube.com.fasterxml.jackson.databind.JsonMappingException
        IOException
      • unmarshalList

        public static <R extends RecordList<R> unmarshalList​(Class<R> 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 <R extends RecordList<R> 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
      • registerSubtypes

        public static <R extends Record> void registerSubtypes​(Class<R>... classes)
      • asJsonNode

        public static org.gcube.com.fasterxml.jackson.databind.JsonNode asJsonNode​(String jsonString)
                                                                            throws org.gcube.com.fasterxml.jackson.core.JsonProcessingException,
                                                                                   IOException
        Throws:
        org.gcube.com.fasterxml.jackson.core.JsonProcessingException
        IOException