Class JacksonConverter

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

public class JacksonConverter extends org.restlet.engine.converter.ConverterHelper
Converter between the JSON, JSON Smile, CSV, XML, YAML and Representation classes based on Jackson.
Author:
Jerome Louvel, Thierry Boileau
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> JacksonRepresentation<T>
    create(org.restlet.data.MediaType mediaType, T source)
    Creates the marshaling JacksonRepresentation.
    protected <T> JacksonRepresentation<T>
    create(org.restlet.representation.Representation source, Class<T> objectClass)
    Creates the unmarshaling JacksonRepresentation.
    getObjectClasses(org.restlet.representation.Variant source)
     
    List<org.restlet.engine.resource.VariantInfo>
    getVariants(Class<?> source)
     
    protected boolean
    isCompatible(org.restlet.representation.Variant variant)
    Indicates if the given variant is compatible with the media types supported by this converter.
    float
    score(Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
     
    <T> float
    score(org.restlet.representation.Representation source, Class<T> target, org.restlet.resource.Resource resource)
     
    <T> T
    toObject(org.restlet.representation.Representation source, Class<T> target, org.restlet.resource.Resource resource)
     
    org.restlet.representation.Representation
    toRepresentation(Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
     
    <T> void
    updatePreferences(List<org.restlet.data.Preference<org.restlet.data.MediaType>> preferences, Class<T> entity)
     

    Methods inherited from class org.restlet.engine.converter.ConverterHelper

    addObjectClass, addVariant, addVariants, getVariants, updatePreferences

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JacksonConverter

      public JacksonConverter()
  • Method Details

    • create

      protected <T> JacksonRepresentation<T> create(org.restlet.data.MediaType mediaType, T source)
      Creates the marshaling JacksonRepresentation.
      Type Parameters:
      T - The expected class of the representation Java object.
      Parameters:
      mediaType - The target media type.
      source - The source object to marshal.
      Returns:
      The marshaling JacksonRepresentation.
    • create

      protected <T> JacksonRepresentation<T> create(org.restlet.representation.Representation source, Class<T> objectClass)
      Creates the unmarshaling JacksonRepresentation.
      Type Parameters:
      T - The expected class of the representation Java object.
      Parameters:
      source - The source representation to unmarshal.
      objectClass - The object class to instantiate.
      Returns:
      The unmarshaling JacksonRepresentation.
    • getObjectClasses

      public List<Class<?>> getObjectClasses(org.restlet.representation.Variant source)
      Specified by:
      getObjectClasses in class org.restlet.engine.converter.ConverterHelper
    • getVariants

      public List<org.restlet.engine.resource.VariantInfo> getVariants(Class<?> source)
      Specified by:
      getVariants in class org.restlet.engine.converter.ConverterHelper
    • isCompatible

      protected boolean isCompatible(org.restlet.representation.Variant variant)
      Indicates if the given variant is compatible with the media types supported by this converter.
      Parameters:
      variant - The variant.
      Returns:
      True if the given variant is compatible with the media types supported by this converter.
    • score

      public float score(Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
      Specified by:
      score in class org.restlet.engine.converter.ConverterHelper
    • score

      public <T> float score(org.restlet.representation.Representation source, Class<T> target, org.restlet.resource.Resource resource)
      Specified by:
      score in class org.restlet.engine.converter.ConverterHelper
    • toObject

      public <T> T toObject(org.restlet.representation.Representation source, Class<T> target, org.restlet.resource.Resource resource) throws IOException
      Specified by:
      toObject in class org.restlet.engine.converter.ConverterHelper
      Throws:
      IOException
    • toRepresentation

      public org.restlet.representation.Representation toRepresentation(Object source, org.restlet.representation.Variant target, org.restlet.resource.Resource resource)
      Specified by:
      toRepresentation in class org.restlet.engine.converter.ConverterHelper
    • updatePreferences

      public <T> void updatePreferences(List<org.restlet.data.Preference<org.restlet.data.MediaType>> preferences, Class<T> entity)
      Overrides:
      updatePreferences in class org.restlet.engine.converter.ConverterHelper