Class ElementMapper
- java.lang.Object
-
- org.gcube.informationsystem.serialization.ElementMapper
-
public abstract class ElementMapper extends Object
- Author:
- Luca Frosini (ISTI - CNR)
-
-
Constructor Summary
Constructors Constructor Description ElementMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static org.gcube.com.fasterxml.jackson.databind.node.ArrayNodeanalizeTypes(org.gcube.com.fasterxml.jackson.databind.node.ArrayNode arrayNode)protected static org.gcube.com.fasterxml.jackson.databind.JsonNodeanalizeTypes(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode objectNode)protected static StringBuffergetError(String unknownType)static org.gcube.com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()static <El extends Element>
Stringmarshal(El object)Return the String serialization of a given objectstatic <El extends Element>
Stringmarshal(El[] array)Return the String serialization of a given arraystatic <T extends OutputStream,El extends Element>
Tmarshal(El object, T stream)Write the serialization of a given resource to a givenOutputStream.static <El extends Element>
Stringmarshal(List<El> list)Return the String serialization of a given liststatic <El extends Element>
voidregisterSubtype(Class<El> clz)protected static org.gcube.com.fasterxml.jackson.databind.node.ObjectNodesetTypeToBestAvailable(org.gcube.com.fasterxml.jackson.databind.node.ObjectNode objectNode)static <El extends Element>
Elunmarshal(Class<El> clz, InputStream stream)Creates a resource of given class from its serialization in a givenInputStream.static <El extends Element>
Elunmarshal(Class<El> clz, Reader reader)Creates a resource of given class from its serialization in a givenReader.static <El extends Element>
Elunmarshal(Class<El> clz, String string)Creates a resource of given class from its serialization in a given Stringstatic <El extends Element>
List<El>unmarshalList(Class<El> clz, String string)static <El extends Element>
List<El>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,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 givenOutputStream.- Parameters:
object- the resourcestream- the stream in input- Throws:
IOExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionorg.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 givenWriter.- Parameters:
object- the resourcewriter- the writer in input- Throws:
IOExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionorg.gcube.com.fasterxml.jackson.core.JsonGenerationException
-
marshal
public static <El extends Element> String 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 Element> String 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 Element> String 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
-
getError
protected static StringBuffer getError(String unknownType)
-
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 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 <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 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 <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 resourcestring-- Returns:
- the resource
- Throws:
org.gcube.com.fasterxml.jackson.core.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
unmarshalList
public static <El extends Element> List<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.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
unmarshalList
public static <El extends Element> List<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.JsonParseExceptionorg.gcube.com.fasterxml.jackson.databind.JsonMappingExceptionIOException
-
-