Class AnnotatedJsonMessageConverter<T>
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
com.emc.documentum.rest.wire.RestAbstractHttpMessageConverter<T>
com.emc.documentum.rest.wire.json.AnnotatedJsonMessageConverter<T>
- Type Parameters:
T- the model class
- All Implemented Interfaces:
org.springframework.http.converter.HttpMessageConverter<T>
An implementation of Spring message converter which reads and writes JSON messages for
the annotated models. The model class for the read and write must be annotated from
SerializableType or extends from a class with this annotation.-
Field Summary
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanSpecifies whether the model class type and the media type is compatible for read.protected booleancanRead(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for read.booleanSpecifies whether the model class type and the media type is compatible for write.protected booleancanWrite(org.springframework.http.MediaType mt) Specifies whether the media type is compatible for write.protected TreadInternal(Class<? extends T> clazz, org.springframework.http.HttpInputMessage inputMessage) Writer internal output http message.voidsetDefaultMediaType(String defaultMediaType) Sets the default media type.voidsetReadableMediaTypes(List<org.springframework.http.MediaType> readableMediaTypes) Set the list ofMediaTypereadable media types supported by this converter.voidsetReader(StreamingMessageReader reader) Specifies the message reader.voidsetUniversal(boolean universal) Specifies the message converter to support all writable media types when the managed media type is JSON.voidsetWriter(StreamingMessageWriter writer) Specifies the message writer.protected booleanCheck whether the class has the annotationSerializableTypeor extends from a class with the annotation.protected voidwriteInternal(T t, org.springframework.http.HttpOutputMessage message) Writer internal output http message.Methods inherited from class com.emc.documentum.rest.wire.RestAbstractHttpMessageConverter
addDefaultHeadersMethods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
getContentLength, getDefaultCharset, getDefaultContentType, 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
-
Constructor Details
-
AnnotatedJsonMessageConverter
public AnnotatedJsonMessageConverter()
-
-
Method Details
-
setDefaultMediaType
Sets the default media type. The default media type is set to the response of write when the original response content type is not meaningful for this message converter.- Parameters:
defaultMediaType- the default media type
-
setReadableMediaTypes
Set the list ofMediaTypereadable media types supported by this converter. The readable media types will override the default supported media types for deserialization.- Parameters:
readableMediaTypes- readable media types
-
setReader
Specifies the message reader.- Parameters:
reader- the message reader.- See Also:
-
setWriter
Specifies the message writer.- Parameters:
writer- the message writer.- See Also:
-
setUniversal
public void setUniversal(boolean universal) Specifies the message converter to support all writable media types when the managed media type is JSON.- Parameters:
universal-trueindicates to be universal;falsefor otherwise.
-
canRead
protected boolean canRead(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for read.- Overrides:
canReadin classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
mediaType- the requested media type- Returns:
- true if the converter can read this media type; false otherwise.
-
supports
Check whether the class has the annotationSerializableTypeor extends from a class with the annotation.- Specified by:
supportsin classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
clazz- the model class- Returns:
- true if it or its parent class has the annotation
SerializableType.
-
canWrite
protected boolean canWrite(org.springframework.http.MediaType mt) Specifies whether the media type is compatible for write.- Overrides:
canWritein classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
mt- the requested media type- Returns:
- true if the converter can write this media type; false otherwise.
-
canRead
Specifies whether the model class type and the media type is compatible for read.- Specified by:
canReadin interfaceorg.springframework.http.converter.HttpMessageConverter<T>- Overrides:
canReadin classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
clazz- the model classmediaType- the requested media type- Returns:
- true if the converter can read this media type; false otherwise.
-
canWrite
Specifies whether the model class type and the media type is compatible for write.- Specified by:
canWritein interfaceorg.springframework.http.converter.HttpMessageConverter<T>- Overrides:
canWritein classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
clazz- the model classmediaType- the requested media type- Returns:
- true if the converter can write this media type; false otherwise.
-
writeInternal
protected void writeInternal(T t, org.springframework.http.HttpOutputMessage message) throws IOException Writer internal output http message.- Specified by:
writeInternalin classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
t- the model instancemessage- the servlet http output message- Throws:
IOException- when there are errors in writing the message
-
readInternal
protected T readInternal(Class<? extends T> clazz, org.springframework.http.HttpInputMessage inputMessage) throws IOException Writer internal output http message.- Specified by:
readInternalin classorg.springframework.http.converter.AbstractHttpMessageConverter<T>- Parameters:
clazz- the model classinputMessage- the servlet http input message- Returns:
- the model instance
- Throws:
IOException- when there are errors in writing the message
-