magoffin.matt.ma2
Interface MediaResponse

All Known Implementing Classes:
BasicMediaResponse, WebMediaResponse

public interface MediaResponse

API to allow setting response values during a media request and returning the result of request processing.

This API represents a response to a specific media item. In some ways it is similar to the java ServletResponse API. When a user wants to view a particular media item, the application will create an instance of this class and populate the OutputStream instance on that class so that getOutputStream() returns the stream to which the result of the request procesing should be written to.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Method Summary
 java.io.OutputStream getOutputStream()
          Get the output stream.
 void setItem(MediaItem item)
          Set the media item used in the response.
 void setMediaLength(long length)
          Set the length of the media of the response.
 void setMimeType(java.lang.String mime)
          Set the MIME type of a response.
 void setModifiedDate(long date)
          Set the modification date of the response.
 

Method Detail

setMimeType

void setMimeType(java.lang.String mime)
Set the MIME type of a response.

The MIME type of the response might be different from the MIME type of the MediaItem in the request. For example a request for an MP3 resource might actually return a JPG image extracted from the metadata of that MP3 file.

Parameters:
mime - the MIME type of the response

setMediaLength

void setMediaLength(long length)
Set the length of the media of the response.

This should be the lenght, in bytes, if the data representing the result of the media request processing.

Parameters:
length - the length of the content

setModifiedDate

void setModifiedDate(long date)
Set the modification date of the response.

If possible, this method should be called and set with the last modification date of the result of processing this media request. This is to aid client caching, for clients that request media items with a "if modified since" directive, such as HTTP clients.

Parameters:
date - the modification date

setItem

void setItem(MediaItem item)
Set the media item used in the response.

The MediaRequest object only contains the ID of the MediaItem to process. This method should be called with the actual MediaItem for that ID.

Parameters:
item - the media item

getOutputStream

java.io.OutputStream getOutputStream()
Get the output stream.

This is the OutputStream that the result of processing the request should be written to. During request processing, the MediaHandler doing the processing should write the resulting media item data to this stream.

Returns:
output stream to write the result to