Package com.emc.documentum.rest.wire.xml
Class AnnotatedXmlMessageConverter<T>
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
com.emc.documentum.rest.wire.RestAbstractHttpMessageConverter<T>
com.emc.documentum.rest.wire.xml.AnnotatedXmlMessageConverter<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 XML 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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Specifies whether the model class type and the media type is compatible for read.protected boolean
canRead
(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for read.boolean
Specifies whether the model class type and the media type is compatible for write.protected boolean
canWrite
(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for write.protected T
readInternal
(Class<? extends T> clazz, org.springframework.http.HttpInputMessage inputMessage) Writer internal output http message.void
setDefaultMediaType
(String defaultMediaType) Sets the default media type.void
setReadableMediaTypes
(List<org.springframework.http.MediaType> readableMediaTypes) Set the list ofMediaType
readable media types supported by this converter.void
setReader
(StreamingMessageReader reader) Specifies the message reader.void
setUniversal
(boolean universal) Specifies the message converter to support all writable media types when the managed media type is XML.void
setWriter
(StreamingMessageWriter writer) Specifies the message writer.protected boolean
Check whether the class has the annotationSerializableType
or extends from a class with the annotation.protected void
writeInternal
(T t, org.springframework.http.HttpOutputMessage outputMessage) Writer internal output http message.Methods inherited from class com.emc.documentum.rest.wire.RestAbstractHttpMessageConverter
addDefaultHeaders
Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, 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
-
Constructor Details
-
AnnotatedXmlMessageConverter
public AnnotatedXmlMessageConverter()
-
-
Method Details
-
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 XML.- Parameters:
universal
-true
indicates to be universal;false
for otherwise.
-
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 ofMediaType
readable media types supported by this converter. The readable media types will override the default supported media types for deserialization.- Parameters:
readableMediaTypes
- readable media types
-
supports
Check whether the class has the annotationSerializableType
or extends from a class with the annotation.- Specified by:
supports
in classorg.springframework.http.converter.AbstractHttpMessageConverter<T>
- Parameters:
clazz
- the model class- Returns:
- true if it or its parent class has the annotation
SerializableType
.
-
canRead
protected boolean canRead(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for read.- Overrides:
canRead
in classorg.springframework.http.converter.AbstractHttpMessageConverter<T>
- Parameters:
mediaType
- the requested media type- Returns:
- true if the converter can read this media type; false otherwise.
-
canRead
Specifies whether the model class type and the media type is compatible for read.- Specified by:
canRead
in interfaceorg.springframework.http.converter.HttpMessageConverter<T>
- Overrides:
canRead
in 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
protected boolean canWrite(org.springframework.http.MediaType mediaType) Specifies whether the media type is compatible for write.- Overrides:
canWrite
in classorg.springframework.http.converter.AbstractHttpMessageConverter<T>
- Parameters:
mediaType
- the requested media type- Returns:
- true if the converter can write this media type; false otherwise.
-
canWrite
Specifies whether the model class type and the media type is compatible for write.- Specified by:
canWrite
in interfaceorg.springframework.http.converter.HttpMessageConverter<T>
- Overrides:
canWrite
in 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.
-
readInternal
protected T readInternal(Class<? extends T> clazz, org.springframework.http.HttpInputMessage inputMessage) throws IOException Writer internal output http message.- Specified by:
readInternal
in 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 reading the message
-
writeInternal
protected void writeInternal(T t, org.springframework.http.HttpOutputMessage outputMessage) throws IOException Writer internal output http message.- Specified by:
writeInternal
in classorg.springframework.http.converter.AbstractHttpMessageConverter<T>
- Parameters:
t
- the model instanceoutputMessage
- the servlet http output message- Throws:
IOException
- when there are errors in reading the message
-