Package org.restlet.ext.gson
Class GsonConverter
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.converter.ConverterHelper
-
- org.restlet.ext.gson.GsonConverter
-
public class GsonConverter extends org.restlet.engine.converter.ConverterHelper
Converter between the JSON and Representation classe based on Gson library.- Author:
- Neal Mi
-
-
Constructor Summary
Constructors Constructor Description GsonConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <T> GsonRepresentation<T>
create(org.restlet.representation.Representation source, java.lang.Class<T> objectClass)
Creates the unmarshalingGsonRepresentation
.protected <T> GsonRepresentation<T>
create(T source)
Creates the marshalingGsonRepresentation
.java.util.List<java.lang.Class<?>>
getObjectClasses(org.restlet.representation.Variant source)
java.util.List<org.restlet.engine.resource.VariantInfo>
getVariants(java.lang.Class<?> source)
float
score(java.lang.Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
<T> float
score(org.restlet.representation.Representation source, java.lang.Class<T> target, org.restlet.resource.Resource resource)
<T> T
toObject(org.restlet.representation.Representation source, java.lang.Class<T> target, org.restlet.resource.Resource resource)
org.restlet.representation.Representation
toRepresentation(java.lang.Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
<T> void
updatePreferences(java.util.List<org.restlet.data.Preference<org.restlet.data.MediaType>> preferences, java.lang.Class<T> entity)
-
-
-
Method Detail
-
create
protected <T> GsonRepresentation<T> create(org.restlet.representation.Representation source, java.lang.Class<T> objectClass)
Creates the unmarshalingGsonRepresentation
.- Type Parameters:
T
-- Parameters:
source
- The source representation to unmarshal.objectClass
- The object class to instantiate.- Returns:
- The unmarshaling
GsonRepresentation
.
-
create
protected <T> GsonRepresentation<T> create(T source)
Creates the marshalingGsonRepresentation
.- Type Parameters:
T
-- Parameters:
source
- The source object to marshal.- Returns:
- The marshaling
GsonRepresentation
.
-
getObjectClasses
public java.util.List<java.lang.Class<?>> getObjectClasses(org.restlet.representation.Variant source)
- Specified by:
getObjectClasses
in classorg.restlet.engine.converter.ConverterHelper
-
getVariants
public java.util.List<org.restlet.engine.resource.VariantInfo> getVariants(java.lang.Class<?> source)
- Specified by:
getVariants
in classorg.restlet.engine.converter.ConverterHelper
-
score
public float score(java.lang.Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
- Specified by:
score
in classorg.restlet.engine.converter.ConverterHelper
-
score
public <T> float score(org.restlet.representation.Representation source, java.lang.Class<T> target, org.restlet.resource.Resource resource)
- Specified by:
score
in classorg.restlet.engine.converter.ConverterHelper
-
toObject
public <T> T toObject(org.restlet.representation.Representation source, java.lang.Class<T> target, org.restlet.resource.Resource resource) throws java.io.IOException
- Specified by:
toObject
in classorg.restlet.engine.converter.ConverterHelper
- Throws:
java.io.IOException
-
toRepresentation
public org.restlet.representation.Representation toRepresentation(java.lang.Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource) throws java.io.IOException
- Specified by:
toRepresentation
in classorg.restlet.engine.converter.ConverterHelper
- Throws:
java.io.IOException
-
updatePreferences
public <T> void updatePreferences(java.util.List<org.restlet.data.Preference<org.restlet.data.MediaType>> preferences, java.lang.Class<T> entity)
- Overrides:
updatePreferences
in classorg.restlet.engine.converter.ConverterHelper
-
-