Class JenaModelHttpMessageConverter

java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
org.dice_research.rdf.spring_jena.JenaModelHttpMessageConverter
All Implemented Interfaces:
org.springframework.http.converter.HttpMessageConverter<org.apache.jena.rdf.model.Model>

public class JenaModelHttpMessageConverter extends org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
A message converter instance that implements the serialization and deserialization of Model instances.
Author:
Michael Röder (michael.roeder@uni-paderborn.de)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.jena.riot.Lang
    The default Lang used for (de-)serialization.
    protected org.springframework.http.MediaType
    The media type of the defaultLang.
    private static final org.slf4j.Logger
     
    static final org.apache.jena.riot.Lang[]
     
    protected Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang>
    Mapping of media types to Lang instances.

    Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    JenaModelHttpMessageConverter(org.apache.jena.riot.Lang defaultLang, Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang> type2Lang)
    Constructor.
    JenaModelHttpMessageConverter(org.apache.jena.riot.Lang defaultLang, org.springframework.http.MediaType defaultMediaType, Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang> type2Lang)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(org.apache.jena.riot.Lang... langs)
    Factory method that generates a converter that supports all of the given Lang instances and uses the first of them as default.
    create(org.apache.jena.riot.Lang defaultLang, String regexPattern, org.apache.jena.riot.Lang... langs)
    Factory method that generates a converter that supports all of the given Lang instances and media types which abide to the given regular expression.
    create(org.apache.jena.riot.Lang defaultLang, org.apache.jena.riot.Lang... langs)
    Factory method that generates a converter that supports all of the given Lang instances and uses the given single Lang instance as default.
    createForApplicationMediaTypes(org.apache.jena.riot.Lang defaultLang)
    Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "application/".
    createForTextMediaTypes(org.apache.jena.riot.Lang defaultLang)
    Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "text/".
    createForUserDefinedMediaTypes(org.apache.jena.riot.Lang defaultLang)
    Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "x/".
    protected org.springframework.http.MediaType
    getDefaultContentType(org.apache.jena.rdf.model.Model t)
     
    protected org.apache.jena.rdf.model.Model
    readInternal(Class<? extends org.apache.jena.rdf.model.Model> clazz, org.springframework.http.HttpInputMessage inputMessage)
     
    protected boolean
    supports(Class<?> clazz)
     
    protected void
    writeInternal(org.apache.jena.rdf.model.Model model, org.springframework.http.HttpOutputMessage outputMessage)
     

    Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

    addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supportsRepeatableWrites, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

    getSupportedMediaTypes
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • SUPPORTED_LANGS

      public static final org.apache.jena.riot.Lang[] SUPPORTED_LANGS
    • defaultLang

      protected org.apache.jena.riot.Lang defaultLang
      The default Lang used for (de-)serialization.
    • defaultMediaType

      protected org.springframework.http.MediaType defaultMediaType
      The media type of the defaultLang.
    • type2Lang

      protected Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang> type2Lang
      Mapping of media types to Lang instances.
  • Constructor Details

    • JenaModelHttpMessageConverter

      public JenaModelHttpMessageConverter(org.apache.jena.riot.Lang defaultLang, Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang> type2Lang)
      Constructor.
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      type2Lang - Mapping of media types to Lang instances.
    • JenaModelHttpMessageConverter

      public JenaModelHttpMessageConverter(org.apache.jena.riot.Lang defaultLang, org.springframework.http.MediaType defaultMediaType, Map<org.springframework.http.MediaType,org.apache.jena.riot.Lang> type2Lang)
      Constructor.
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      defaultMediaType - The media type of the defaultLang.
      type2Lang - Mapping of media types to Lang instances.
  • Method Details

    • getDefaultContentType

      protected org.springframework.http.MediaType getDefaultContentType(org.apache.jena.rdf.model.Model t) throws IOException
      Overrides:
      getDefaultContentType in class org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
      Throws:
      IOException
    • supports

      protected boolean supports(Class<?> clazz)
      Specified by:
      supports in class org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
    • readInternal

      protected org.apache.jena.rdf.model.Model readInternal(Class<? extends org.apache.jena.rdf.model.Model> clazz, org.springframework.http.HttpInputMessage inputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotReadableException
      Specified by:
      readInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotReadableException
    • writeInternal

      protected void writeInternal(org.apache.jena.rdf.model.Model model, org.springframework.http.HttpOutputMessage outputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotWritableException
      Specified by:
      writeInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>
      Throws:
      IOException
      org.springframework.http.converter.HttpMessageNotWritableException
    • create

      public static JenaModelHttpMessageConverter create(org.apache.jena.riot.Lang... langs)
      Factory method that generates a converter that supports all of the given Lang instances and uses the first of them as default.
      Parameters:
      langs - The Lang instances that are supported by the created converter
      Returns:
      A new converter for the given Lang instances
    • create

      public static JenaModelHttpMessageConverter create(org.apache.jena.riot.Lang defaultLang, org.apache.jena.riot.Lang... langs)
      Factory method that generates a converter that supports all of the given Lang instances and uses the given single Lang instance as default.
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      langs - The Lang instances that are supported by the created converter
      Returns:
      A new converter for the given Lang instances
    • create

      public static JenaModelHttpMessageConverter create(org.apache.jena.riot.Lang defaultLang, String regexPattern, org.apache.jena.riot.Lang... langs)
      Factory method that generates a converter that supports all of the given Lang instances and media types which abide to the given regular expression.
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      regexPattern - a regular expression that can be used to filter the media types of the Lang instances
      langs - The Lang instances that are supported by the created converter
      Returns:
      A new converter for the given Lang instances
    • createForApplicationMediaTypes

      public static JenaModelHttpMessageConverter createForApplicationMediaTypes(org.apache.jena.riot.Lang defaultLang)
      Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "application/". The given Lang instance will be used as default. At the time of writing, this could be one of the following:
      • application/ld+json
      • application/n-quads
      • application/n-triples
      • application/rdf+json
      • application/rdf+protobuf
      • application/rdf+thrift
      • application/rdf+xml
      • application/trig
      • application/trix+xml
      • application/trix
      • application/turtle
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      Returns:
      A new converter for all SUPPORTED_LANGS that have a mediatype starting with "application/".
    • createForTextMediaTypes

      public static JenaModelHttpMessageConverter createForTextMediaTypes(org.apache.jena.riot.Lang defaultLang)
      Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "text/". The given Lang instance will be used as default. At the time of writing, this could be one of the following:
      • text/n-quads
      • text/plain
      • text/trig
      • text/turtle
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      Returns:
      A new converter for all SUPPORTED_LANGS that have a mediatype starting with "text/".
    • createForUserDefinedMediaTypes

      public static JenaModelHttpMessageConverter createForUserDefinedMediaTypes(org.apache.jena.riot.Lang defaultLang)
      Factory method that generates a converter that supports all SUPPORTED_LANGS that have a mediatype starting with "x/". The given Lang instance will be used as default. At the time of writing, this could be one of the following:
      • x/ld-json-10
      • x/ld-json-11
      Parameters:
      defaultLang - The default Lang used for (de-)serialization.
      Returns:
      A new converter for all SUPPORTED_LANGS that have a mediatype starting with "text/".