magoffin.matt.ma2
Interface MediaRequest

All Known Implementing Classes:
BasicMediaRequest

public interface MediaRequest

API for media requests.

This API represents a request for a specific media item. In some ways it is similar to the java ServletRequest API. When a user wants to view a particular media item, the application will create an instance of this class and populate it with values so that getMediaItemId(), getQuality(), and getSize() are set according to what the user requested. It might also populate a list of MediaEffect objects that the user requested to be applied to the media item.

The implementation of this API should be coded to return a unique key from the getCacheKey() method, based on the properties set in the object (i.e. the size, quality, etc.). This is so the application can cache the results of processing this request so that future requests for the same item with the same properties do not need to be re-processed.

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

Field Summary
static java.lang.String OUTPUT_FILE_KEY
          The parameter key for a File object the OutputStream in MediaResponse is pointed at.
static java.lang.String USER_AGENT_KEY
          The user agent making this request.
 
Method Summary
 java.lang.String getCacheKey()
          Get a key that can uniquely define this media request, for purposes of using as a key for caching.
 java.util.List<MediaEffect> getEffects()
          Get a List of effects to apply to the request.
 java.lang.Long getMediaItemId()
          Get the ID of the media item desired.
 java.util.Map<java.lang.String,java.lang.Object> getParameters()
          Get a Map of optional additional parameters.
 MediaQuality getQuality()
          Get the desired quality constant.
 MediaSize getSize()
          Get the desired size constant.
 boolean isOriginal()
          Return true if the original media item file is desired.
 

Field Detail

OUTPUT_FILE_KEY

static final java.lang.String OUTPUT_FILE_KEY
The parameter key for a File object the OutputStream in MediaResponse is pointed at. Some MediaHandler implementations (eg JMagick) can use this during processing.

See Also:
Constant Field Values

USER_AGENT_KEY

static final java.lang.String USER_AGENT_KEY
The user agent making this request. This can be useful for certain MediaHandler implementations that might want to return one content type for specific clients and another for other clients (eg. JPEG2000 for web browsers that support it and JPEG for others).

See Also:
Constant Field Values
Method Detail

getMediaItemId

java.lang.Long getMediaItemId()
Get the ID of the media item desired.

Returns:
the media item ID

isOriginal

boolean isOriginal()
Return true if the original media item file is desired.

Returns:
boolean

getSize

MediaSize getSize()
Get the desired size constant.

Returns:
the desired size

getQuality

MediaQuality getQuality()
Get the desired quality constant.

Returns:
the desired quality

getParameters

java.util.Map<java.lang.String,java.lang.Object> getParameters()
Get a Map of optional additional parameters.

During request handling, MediaHandler implementations are allowed to add parameters to this map.

Returns:
parameters

getEffects

java.util.List<MediaEffect> getEffects()
Get a List of effects to apply to the request.

The effects should be applied in the order of the list. The MediaHandler servicing the request should be allowed to make changes to this List as it sees fit.

Returns:
effects list

getCacheKey

java.lang.String getCacheKey()
Get a key that can uniquely define this media request, for purposes of using as a key for caching.

Returns:
unique cache key