Package org.gcube.documentstore.records
Class DSMapper
- java.lang.Object
-
- org.gcube.documentstore.records.DSMapper
-
public class DSMapper extends Object
- Author:
- Luca Frosini (ISTI - CNR)
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.gcube.com.fasterxml.jackson.databind.ObjectMappermapper
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.gcube.com.fasterxml.jackson.databind.JsonNodeasJsonNode(String jsonString)static org.gcube.com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()static <R extends Record>
Stringmarshal(List<R> list)Return the String serialization of a given liststatic <R extends Record>
Stringmarshal(R record)Return the String serialization of a given Recordstatic <R extends Record>
Stringmarshal(R[] array)Return the String serialization of a given arraystatic <T extends OutputStream,R extends Record>
Tmarshal(R record, T stream)Write the serialization of a given Record to a givenOutputStream.static <R extends Record>
voidregisterSubtypes(Class<R>... classes)static <R extends Record>
Runmarshal(Class<R> clz, InputStream stream)Creates a resource of given class from its serialization in a givenInputStream.static <R extends Record>
Runmarshal(Class<R> clz, Reader reader)Creates a resource of given class from its serialization in a givenReader.static <R extends Record>
Runmarshal(Class<R> clz, String string)Creates a record of given class from its serialization in a given Stringstatic <R extends Record>
List<R>unmarshalList(Class<R> clz, String string)static <R extends Record>
List<R>unmarshalList(String string)
-
-
-
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 givenOutputStream.- Parameters:
record- the Recordstream- the stream in input- Returns:
- the OutputStream
- Throws:
IOExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionorg.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 givenWriter.- Parameters:
record- the Recordwriter- the writer in input- Returns:
- the Writer
- Throws:
IOExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionorg.gcube.com.fasterxml.jackson.core.JsonGenerationException
-
marshal
public static <R extends Record> String 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 Record> String 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 Record> String 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 givenReader.- Parameters:
clz- the class of the resourcereader- the reader- Returns:
- the resource
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
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 givenInputStream.- Parameters:
clz- the class of the resourcestream- the stream- Returns:
- the resource
- Throws:
IOExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionorg.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 recordstring-- Returns:
- the record
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
unmarshalList
public static <R extends Record> List<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.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
unmarshalList
public static <R extends Record> List<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.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
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.JsonProcessingExceptionIOException
-
-