magoffin.matt.ma2.image.iio
Class JpegMediaHandler

java.lang.Object
  extended by magoffin.matt.ma2.support.AbstractMediaHandler
      extended by magoffin.matt.ma2.image.BaseImageMediaHandler
          extended by magoffin.matt.ma2.image.awt.BaseAwtImageMediaHandler
              extended by magoffin.matt.ma2.image.iio.BaseImageIOMediaHandler
                  extended by magoffin.matt.ma2.image.iio.JpegMediaHandler
All Implemented Interfaces:
MediaHandler, MediaHandlerDelegate
Direct Known Subclasses:
PngMediaHandler

public class JpegMediaHandler
extends BaseImageIOMediaHandler
implements MediaHandlerDelegate

JPEG media handler using ImageIO.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
matt.magoffin

Field Summary
static java.lang.String FORMAT_NAME_IIO_JPEG_1_0
          The ImageIO JPEG format name constant.
 
Fields inherited from class magoffin.matt.ma2.image.BaseImageMediaHandler
DEFAULT_ORIENTATION_180_VALUE, DEFAULT_ORIENTATION_90_CLOCKWISE_VALUE, DEFAULT_ORIENTATION_90_COUNTER_CLOCKWISE_VALUE, DEFAULT_ORIENTATION_METADATA_KEY, ROTATE_180, ROTATE_90_CCW, ROTATE_90_CW
 
Fields inherited from class magoffin.matt.ma2.support.AbstractMediaHandler
log, METADATA_PARAMETER_KEY
 
Constructor Summary
  JpegMediaHandler()
          Default constructor.
protected JpegMediaHandler(java.lang.String mimeType)
          Construct with a different MIME type.
 
Method Summary
 MediaItem createNewMediaItem(java.io.File inputFile)
          Create a new instance of MediaItem from a File.
 java.lang.String getDelegateFileExtension(org.springframework.core.io.Resource mediaResource, java.lang.String mimeType, MediaItem item, MediaRequest request)
          Get the preferred file extension for this handler.
 void handleDelegateMediaRequest(org.springframework.core.io.Resource mediaResource, java.lang.String mimeType, MediaItem item, MediaRequest request, MediaResponse response)
          Handle a delegate media request.
 void handleMediaRequest(MediaItem item, MediaRequest request, MediaResponse response)
          Handle a media request by processing the specified media item and writing the result to MediaResponse.getOutputStream().
 
Methods inherited from class magoffin.matt.ma2.image.iio.BaseImageIOMediaHandler
defaultHandleDelegateRequest, defaultHandleRequest, getBufferedImage, getImageMediaHelper, setImageMediaHelper, setupBaseItemProperties
 
Methods inherited from class magoffin.matt.ma2.image.awt.BaseAwtImageMediaHandler
getAwtMediaEffectMap, getEffect, setAwtMediaEffectMap
 
Methods inherited from class magoffin.matt.ma2.image.BaseImageMediaHandler
getOrientation180Value, getOrientation90ClockwiseValue, getOrientation90CounterClockwiseValue, getOrientationMetadataKey, handleMetadata, needToRotate, setOrientation180Value, setOrientation90ClockwiseValue, setOrientation90CounterClockwiseValue, setOrientationMetadataKey
 
Methods inherited from class magoffin.matt.ma2.support.AbstractMediaHandler
applyEffects, createMetadataList, defaultHandleRequestOriginal, getDomainObjectFactory, getFileExtension, getMediaBiz, getMediaMetadataInstance, getMime, getNoWatermarkSizes, getPreferredFileExtension, getRequestEffects, getSmetaPropertyMap, getUserBiz, needToAlter, setDomainObjectFactory, setMediaBiz, setMime, setNoWatermarkSizes, setPreferredFileExtension, setSmetaPropertyMap, setUserBiz
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_NAME_IIO_JPEG_1_0

public static final java.lang.String FORMAT_NAME_IIO_JPEG_1_0
The ImageIO JPEG format name constant.

See Also:
Constant Field Values
Constructor Detail

JpegMediaHandler

public JpegMediaHandler()
Default constructor.


JpegMediaHandler

protected JpegMediaHandler(java.lang.String mimeType)
Construct with a different MIME type.

Parameters:
mimeType - the MIME type
Method Detail

createNewMediaItem

public MediaItem createNewMediaItem(java.io.File inputFile)
Description copied from interface: MediaHandler
Create a new instance of MediaItem from a File.

This method will be called when a new media item is to be added into Matte. This method should populate as much information as it can extract from the file into a MediaItem instance, including populating any Metadata it can extract from the file.

This method does not need to persist the MediaItem instance, just populate it and return it.

Specified by:
createNewMediaItem in interface MediaHandler
Parameters:
inputFile - the file to create the media item from
Returns:
an instance of MediaItem

handleDelegateMediaRequest

public void handleDelegateMediaRequest(org.springframework.core.io.Resource mediaResource,
                                       java.lang.String mimeType,
                                       MediaItem item,
                                       MediaRequest request,
                                       MediaResponse response)
Description copied from interface: MediaHandlerDelegate
Handle a delegate media request.

The mediaResource is not the original MediaItem resource, rather it is the media resource extracted from the MediaItem, e.g. the metadata resource.

Specified by:
handleDelegateMediaRequest in interface MediaHandlerDelegate
Parameters:
mediaResource - the media data to process
mimeType - the MIME type of the media data in mediaResource
item - the MediaItem being processed
request - the request
response - the response

getDelegateFileExtension

public java.lang.String getDelegateFileExtension(org.springframework.core.io.Resource mediaResource,
                                                 java.lang.String mimeType,
                                                 MediaItem item,
                                                 MediaRequest request)
Description copied from interface: MediaHandlerDelegate
Get the preferred file extension for this handler.

The mediaResource is not the original MediaItem resource, rather it is the media resource extracted from the MediaItem, e.g. the metadata resource.

Some handlers might return a different file extension for a given request then the default file extension for their type (for example a PNG image handler that returns JPEG images when resizing the images.

Specified by:
getDelegateFileExtension in interface MediaHandlerDelegate
Parameters:
mediaResource - the media data to process
mimeType - the MIME type of the media data in mediaResource
item - the MediaItem being processed
request - the request
Returns:
a file extension, without the period

handleMediaRequest

public void handleMediaRequest(MediaItem item,
                               MediaRequest request,
                               MediaResponse response)
Description copied from interface: MediaHandler
Handle a media request by processing the specified media item and writing the result to MediaResponse.getOutputStream().

Specified by:
handleMediaRequest in interface MediaHandler
Parameters:
item - the media item to process
request - the request
response - the response