T
- the converted object typepublic class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMessageConverter<T>
HttpMessageConverter
that can read and write Source
objects.logger
Constructor and Description |
---|
SourceHttpMessageConverter()
|
Modifier and Type | Method and Description |
---|---|
protected Long |
getContentLength(T t,
MediaType contentType)
Returns the content length for the given type.
|
boolean |
isProcessExternalEntities()
Return whether XML external entities are allowed.
|
boolean |
isSupportDtd()
Return whether DTD parsing is supported.
|
protected T |
readInternal(Class<? extends T> clazz,
HttpInputMessage inputMessage)
Abstract template method that reads the actual object.
|
void |
setProcessExternalEntities(boolean processExternalEntities)
Indicate whether external XML entities are processed when converting to a Source.
|
void |
setSupportDtd(boolean supportDtd)
Indicate whether DTD parsing should be supported.
|
boolean |
supports(Class<?> clazz)
Indicates whether the given class is supported by this converter.
|
protected void |
writeInternal(T t,
HttpOutputMessage outputMessage)
Abstract template method that writes the actual body.
|
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSupportedMediaTypes
public void setSupportDtd(boolean supportDtd)
Default is false
meaning that DTD is disabled.
public boolean isSupportDtd()
public void setProcessExternalEntities(boolean processExternalEntities)
Default is false
, meaning that external entities are not resolved.
Note: setting this option to true
also
automatically sets setSupportDtd(boolean)
to true
.
public boolean isProcessExternalEntities()
public boolean supports(Class<?> clazz)
AbstractHttpMessageConverter
supports
in class AbstractHttpMessageConverter<T extends Source>
clazz
- the class to test for supporttrue
if supported; false
otherwiseprotected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException
AbstractHttpMessageConverter
AbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage)
.readInternal
in class AbstractHttpMessageConverter<T extends Source>
clazz
- the type of object to returninputMessage
- the HTTP input message to read fromIOException
- in case of I/O errorsHttpMessageNotReadableException
- in case of conversion errors@Nullable protected Long getContentLength(T t, @Nullable MediaType contentType)
AbstractHttpMessageConverter
By default, this returns null
, meaning that the content length is unknown.
Can be overridden in subclasses.
getContentLength
in class AbstractHttpMessageConverter<T extends Source>
t
- the type to return the content length fornull
if not knownprotected void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException
AbstractHttpMessageConverter
AbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage)
.writeInternal
in class AbstractHttpMessageConverter<T extends Source>
t
- the object to write to the output messageoutputMessage
- the HTTP output message to write toIOException
- in case of I/O errorsHttpMessageNotWritableException
- in case of conversion errors