magoffin.matt.ma2.support
Class BasicMediaResponse

java.lang.Object
  extended by magoffin.matt.ma2.support.BasicMediaResponse
All Implemented Interfaces:
MediaResponse

public class BasicMediaResponse
extends java.lang.Object
implements MediaResponse

Basic implementation of MediaResponse.

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

Constructor Summary
BasicMediaResponse()
          Default constructor.
BasicMediaResponse(java.io.OutputStream outputStream)
          Construct with some parameters.
 
Method Summary
 MediaItem getItem()
           
 long getLength()
           
 java.lang.String getMime()
           
 long getModifiedDate()
           
 java.io.OutputStream getOutputStream()
          Get the output stream.
 void setItem(MediaItem item)
          Set the media item used in the response.
 void setLength(long length)
           
 void setMediaLength(long length)
          Set the length of the media of the response.
 void setMime(java.lang.String mime)
           
 void setMimeType(java.lang.String mime)
          Set the MIME type of a response.
 void setModifiedDate(long date)
          Set the modification date of the response.
 void setOutputStream(java.io.OutputStream outputStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicMediaResponse

public BasicMediaResponse()
Default constructor.


BasicMediaResponse

public BasicMediaResponse(java.io.OutputStream outputStream)
Construct with some parameters.

Parameters:
outputStream - the output stream
Method Detail

setMimeType

public void setMimeType(java.lang.String mime)
Description copied from interface: MediaResponse
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.

Specified by:
setMimeType in interface MediaResponse
Parameters:
mime - the MIME type of the response

setMediaLength

public void setMediaLength(long length)
Description copied from interface: MediaResponse
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.

Specified by:
setMediaLength in interface MediaResponse
Parameters:
length - the length of the content

setModifiedDate

public void setModifiedDate(long date)
Description copied from interface: MediaResponse
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.

Specified by:
setModifiedDate in interface MediaResponse
Parameters:
date - the modification date

setItem

public void setItem(MediaItem item)
Description copied from interface: MediaResponse
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.

Specified by:
setItem in interface MediaResponse
Parameters:
item - the media item

getOutputStream

public java.io.OutputStream getOutputStream()
Description copied from interface: MediaResponse
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.

Specified by:
getOutputStream in interface MediaResponse
Returns:
output stream to write the result to

getLength

public long getLength()
Returns:
Returns the length.

setLength

public void setLength(long length)
Parameters:
length - The length to set.

getMime

public java.lang.String getMime()
Returns:
Returns the mime.

setMime

public void setMime(java.lang.String mime)
Parameters:
mime - The mime to set.

getItem

public MediaItem getItem()
Returns:
Returns the item.

getModifiedDate

public long getModifiedDate()
Returns:
Returns the modifiedDate.

setOutputStream

public void setOutputStream(java.io.OutputStream outputStream)
Parameters:
outputStream - The outputStream to set.