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
FieldsModifier and TypeFieldDescriptionprotected org.apache.jena.riot.LangThe defaultLangused for (de-)serialization.protected org.springframework.http.MediaTypeThe media type of thedefaultLang.private static final org.slf4j.Loggerstatic final org.apache.jena.riot.Lang[]protected Map<org.springframework.http.MediaType, org.apache.jena.riot.Lang> Mapping of media types toLanginstances.Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionJenaModelHttpMessageConverter(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 TypeMethodDescriptioncreate(org.apache.jena.riot.Lang... langs) Factory method that generates a converter that supports all of the givenLanginstances 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 givenLanginstances 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 givenLanginstances and uses the given singleLanginstance as default.createForApplicationMediaTypes(org.apache.jena.riot.Lang defaultLang) Factory method that generates a converter that supports allSUPPORTED_LANGSthat have a mediatype starting with"application/".createForTextMediaTypes(org.apache.jena.riot.Lang defaultLang) Factory method that generates a converter that supports allSUPPORTED_LANGSthat have a mediatype starting with"text/".createForUserDefinedMediaTypes(org.apache.jena.riot.Lang defaultLang) Factory method that generates a converter that supports allSUPPORTED_LANGSthat have a mediatype starting with"x/".protected org.springframework.http.MediaTypegetDefaultContentType(org.apache.jena.rdf.model.Model t) protected org.apache.jena.rdf.model.ModelreadInternal(Class<? extends org.apache.jena.rdf.model.Model> clazz, org.springframework.http.HttpInputMessage inputMessage) protected booleanprotected voidwriteInternal(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, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 defaultLangThe defaultLangused for (de-)serialization. -
defaultMediaType
protected org.springframework.http.MediaType defaultMediaTypeThe media type of thedefaultLang. -
type2Lang
Mapping of media types toLanginstances.
-
-
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 defaultLangused for (de-)serialization.type2Lang- Mapping of media types toLanginstances.
-
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 defaultLangused for (de-)serialization.defaultMediaType- The media type of thedefaultLang.type2Lang- Mapping of media types toLanginstances.
-
-
Method Details
-
getDefaultContentType
protected org.springframework.http.MediaType getDefaultContentType(org.apache.jena.rdf.model.Model t) throws IOException - Overrides:
getDefaultContentTypein classorg.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>- Throws:
IOException
-
supports
- Specified by:
supportsin classorg.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:
readInternalin classorg.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>- Throws:
IOExceptionorg.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:
writeInternalin classorg.springframework.http.converter.AbstractHttpMessageConverter<org.apache.jena.rdf.model.Model>- Throws:
IOExceptionorg.springframework.http.converter.HttpMessageNotWritableException
-
create
Factory method that generates a converter that supports all of the givenLanginstances and uses the first of them as default.- Parameters:
langs- TheLanginstances that are supported by the created converter- Returns:
- A new converter for the given
Langinstances
-
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 givenLanginstances and uses the given singleLanginstance as default.- Parameters:
defaultLang- The defaultLangused for (de-)serialization.langs- TheLanginstances that are supported by the created converter- Returns:
- A new converter for the given
Langinstances
-
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 givenLanginstances and media types which abide to the given regular expression.- Parameters:
defaultLang- The defaultLangused for (de-)serialization.regexPattern- a regular expression that can be used to filter the media types of theLanginstanceslangs- TheLanginstances that are supported by the created converter- Returns:
- A new converter for the given
Langinstances
-
createForApplicationMediaTypes
public static JenaModelHttpMessageConverter createForApplicationMediaTypes(org.apache.jena.riot.Lang defaultLang) Factory method that generates a converter that supports allSUPPORTED_LANGSthat have a mediatype starting with"application/". The givenLanginstance 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 defaultLangused for (de-)serialization.- Returns:
- A new converter for all
SUPPORTED_LANGSthat 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 allSUPPORTED_LANGSthat have a mediatype starting with"text/". The givenLanginstance 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 defaultLangused for (de-)serialization.- Returns:
- A new converter for all
SUPPORTED_LANGSthat 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 allSUPPORTED_LANGSthat have a mediatype starting with"x/". The givenLanginstance 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 defaultLangused for (de-)serialization.- Returns:
- A new converter for all
SUPPORTED_LANGSthat have a mediatype starting with"text/".
-