org.restlet.ext.jackson
Class JacksonConverter

java.lang.Object
  extended by org.restlet.engine.Helper
      extended by org.restlet.engine.converter.ConverterHelper
          extended by org.restlet.ext.jackson.JacksonConverter

public class JacksonConverter
extends ConverterHelper

Converter between the JSON and Representation classes based on Jackson.

Author:
Jerome Louvel

Constructor Summary
JacksonConverter()
           
 
Method Summary
protected
<T> JacksonRepresentation<T>
create(MediaType mediaType, T source)
          Creates the marshaling JacksonRepresentation.
protected
<T> JacksonRepresentation<T>
create(Representation source, java.lang.Class<T> objectClass)
          Creates the unmarshaling JacksonRepresentation.
protected  org.codehaus.jackson.map.ObjectMapper createObjectMapper()
          Creates a Jackson object mapper based on a media type.
 java.util.List<java.lang.Class<?>> getObjectClasses(Variant source)
           
 org.codehaus.jackson.map.ObjectMapper getObjectMapper()
          Returns the modifiable Jackson object mapper.
 java.util.List<VariantInfo> getVariants(java.lang.Class<?> source)
           
 float score(java.lang.Object source, Variant target, UniformResource resource)
           
<T> float
score(Representation source, java.lang.Class<T> target, UniformResource resource)
           
 void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
          Sets the Jackson object mapper.
<T> T
toObject(Representation source, java.lang.Class<T> target, UniformResource resource)
           
 Representation toRepresentation(java.lang.Object source, Variant target, UniformResource resource)
           
<T> void
updatePreferences(java.util.List<Preference<MediaType>> preferences, java.lang.Class<T> entity)
           
 
Methods inherited from class org.restlet.engine.converter.ConverterHelper
addObjectClass, addVariant, updatePreferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JacksonConverter

public JacksonConverter()
Method Detail

create

protected <T> JacksonRepresentation<T> create(MediaType mediaType,
                                              T source)
Creates the marshaling JacksonRepresentation.

Type Parameters:
T -
Parameters:
mediaType - The target media type.
source - The source object to marshal.
Returns:
The marshaling JacksonRepresentation.

create

protected <T> JacksonRepresentation<T> create(Representation source,
                                              java.lang.Class<T> objectClass)
Creates the unmarshaling JacksonRepresentation.

Type Parameters:
T -
Parameters:
source - The source representation to unmarshal.
objectClass - The object class to instantiate.
Returns:
The unmarshaling JacksonRepresentation.

createObjectMapper

protected org.codehaus.jackson.map.ObjectMapper createObjectMapper()
Creates a Jackson object mapper based on a media type. By default, it calls ObjectMapper.ObjectMapper(JsonFactory).

Returns:
The Jackson object mapper.

getObjectClasses

public java.util.List<java.lang.Class<?>> getObjectClasses(Variant source)
Specified by:
getObjectClasses in class ConverterHelper

getObjectMapper

public org.codehaus.jackson.map.ObjectMapper getObjectMapper()
Returns the modifiable Jackson object mapper. Useful to customize mappings.

Returns:
The modifiable Jackson object mapper.

getVariants

public java.util.List<VariantInfo> getVariants(java.lang.Class<?> source)
Specified by:
getVariants in class ConverterHelper

score

public float score(java.lang.Object source,
                   Variant target,
                   UniformResource resource)
Specified by:
score in class ConverterHelper

score

public <T> float score(Representation source,
                       java.lang.Class<T> target,
                       UniformResource resource)
Specified by:
score in class ConverterHelper

setObjectMapper

public void setObjectMapper(org.codehaus.jackson.map.ObjectMapper objectMapper)
Sets the Jackson object mapper.

Parameters:
objectMapper - The Jackson object mapper.

toObject

public <T> T toObject(Representation source,
                      java.lang.Class<T> target,
                      UniformResource resource)
           throws java.io.IOException
Specified by:
toObject in class ConverterHelper
Throws:
java.io.IOException

toRepresentation

public Representation toRepresentation(java.lang.Object source,
                                       Variant target,
                                       UniformResource resource)
Specified by:
toRepresentation in class ConverterHelper

updatePreferences

public <T> void updatePreferences(java.util.List<Preference<MediaType>> preferences,
                                  java.lang.Class<T> entity)
Overrides:
updatePreferences in class ConverterHelper


Copyright © 2005-2012 Restlet S.A.S..