Package org.gcube.documentstore.records
Class DSMapper
java.lang.Object
org.gcube.documentstore.records.DSMapper
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapper -
Method Summary
Modifier and TypeMethodDescriptionstatic org.gcube.com.fasterxml.jackson.databind.JsonNodeasJsonNode(String jsonString) static org.gcube.com.fasterxml.jackson.databind.ObjectMapperReturn the String serialization of a given listmarshal(R record) Return the String serialization of a given Recordmarshal(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>
RCreates a resource of given class from its serialization in a givenReader.static <R extends Record>
RCreates a record of given class from its serialization in a given StringunmarshalList(Class<R> clz, String string) unmarshalList(String string)
-
Field Details
-
mapper
protected static final org.gcube.com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Details
-
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
-
registerSubtypes
-
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
-