HttpMessageConverter that can read and write
BufferedImages.
By default, this converter can read all media types that are supported
by the registered image readers,
and writes using the media type of the first available
registered image writer.
The latter can be overridden by setting the
defaultContentType property.
If the cacheDir property is set, this converter
will cache image data.
The process(ImageReadParam) and process(ImageWriteParam)
template methods allow subclasses to override Image I/O parameters.
| Modifier and Type | Field and Description |
|---|---|
| private File | |
| private MediaType | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canRead(Class<?>
the class to test for readability clazz, MediaType the media type to read (can be mediaType)null if not specified);
typically the value of a Content-Type header.Implements org. |
| public boolean | canWrite(Class<?>
the class to test for writability clazz, MediaType the media type to write (can be mediaType)null if not specified);
typically the value of an Accept header.Implements org. |
| private ImageInputStream | |
| private ImageOutputStream | |
| private MediaType | |
| public MediaType | |
| public List | getSupportedMediaTypes()
Implements org. |
| private boolean | |
| private boolean | |
| protected void | process(ImageReadParam irp)
Template method that allows for manipulating the |
| protected void | process(ImageWriteParam iwp)
Template method that allows for manipulating the |
| public BufferedImage | read(Class<? extends BufferedImage>
the type of object to return. This type must have previously been passed to the
clazz, HttpInputMessage canRead method of this interface, which must have returned true.the HTTP input message to read from inputMessage)Implements org. |
| public void | |
| public void | setDefaultContentType(MediaType defaultContentType)
Sets the default |
| public void | write(final BufferedImage
the object to write to the output message. The type of this object must have previously been
passed to the image, final MediaType canWrite method of this interface, which must have returned true.the content type to use when writing. May be contentType, final HttpOutputMessage null to indicate that the
default content type of the converter must be used. If not null, this media type must have
previously been passed to the canWrite method of this interface, which must have
returned true.the message to write to outputMessage)Implements org. |
| private void |
| cacheDir | back to summary |
|---|---|
| private File cacheDir
| |
| defaultContentType | back to summary |
|---|---|
| private MediaType defaultContentType
| |
| readableMediaTypes | back to summary |
|---|---|
| private final List<MediaType> readableMediaTypes | |
| BufferedImageHttpMessageConverter | back to summary |
|---|---|
| public BufferedImageHttpMessageConverter() | |
| canRead | back to summary |
|---|---|
| public boolean canRead(Class<?> clazz, MediaType mediaType) Implements org. Doc from org. Indicates whether the given class can be read by this converter. | |
| canWrite | back to summary |
|---|---|
| public boolean canWrite(Class<?> clazz, MediaType mediaType) Implements org. Doc from org. Indicates whether the given class can be written by this converter. | |
| createImageInputStream | back to summary |
|---|---|
| private ImageInputStream createImageInputStream(InputStream is) throws IOException | |
| createImageOutputStream | back to summary |
|---|---|
| private ImageOutputStream createImageOutputStream(OutputStream os) throws IOException | |
| getContentType | back to summary |
|---|---|
| private MediaType getContentType(MediaType contentType) | |
| getDefaultContentType | back to summary |
|---|---|
| public MediaType getDefaultContentType() Returns the default
| |
| getSupportedMediaTypes | back to summary |
|---|---|
| public List Implements org. Doc from org. Return the list of media types supported by this converter. The list may
not apply to every possible target element type and calls to this method
should typically be guarded via | |
| isReadable | back to summary |
|---|---|
| private boolean isReadable(MediaType mediaType) | |
| isWritable | back to summary |
|---|---|
| private boolean isWritable(MediaType mediaType) | |
| process | back to summary |
|---|---|
| protected void process(ImageReadParam irp) Template method that allows for manipulating the The default implementation is empty. | |
| process | back to summary |
|---|---|
| protected void process(ImageWriteParam iwp) Template method that allows for manipulating the The default implementation is empty. | |
| read | back to summary |
|---|---|
| public BufferedImage read(Class<? extends BufferedImage> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException Implements org. Doc from org. Read an object of the given type from the given input message, and returns it.
| |
| setCacheDir | back to summary |
|---|---|
| public void setCacheDir(File cacheDir) Sets the cache directory. If this property is set to an existing directory, this converter will cache image data. | |
| setDefaultContentType | back to summary |
|---|---|
| public void setDefaultContentType(MediaType defaultContentType) Sets the default
| |
| write | back to summary |
|---|---|
| public void write(final BufferedImage image, final MediaType contentType, final HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException Implements org. Doc from org. Write a given object to the given output message.
| |
| writeInternal | back to summary |
|---|---|
| private void writeInternal(BufferedImage image, MediaType contentType, OutputStream body) throws IOException, HttpMessageNotWritableException | |