org.jasig.portal
Class MediaManager

java.lang.Object
  extended by org.jasig.portal.MediaManager

public class MediaManager
extends Object

A tool for managing various media properties. Given a request object, MediaManager determines a client browser type (media). MediaManager also provides information on the mime type that generated response should carry.

Version:
$Revision: 19776 $
Author:
Peter Kharchenko

Field Summary
static String HTMLPublicId
           
static String HTMLSystemId
           
protected  org.jasig.portal.MediaManager.OrderedProps mediaProps
           
protected  org.jasig.portal.MediaManager.OrderedProps mimeProps
           
static String NULL_USER_AGENT
          A user agent string to use when the user-agent header value itself is null.
protected  org.jasig.portal.MediaManager.OrderedProps serializerProps
           
static String UNKNOWN
           
static String WMLPublicId
           
static String WMLSystemId
           
static String XHTMLPublicId
           
static String XHTMLSystemId
           
 
Method Summary
 String getDefaultMedia()
          Return a default media type.
 String getMedia(BrowserInfo bi)
          Determines a media name from the browser info object.
 String getMedia(HttpServletRequest req)
          Determines a media name from the request object.
static MediaManager getMediaManager()
          7/25/05 - UP-1181 - change MediaManager into a singleton Returns the default MediaManager singleton
static MediaManager getMediaManager(boolean omitDocType)
           
 String getReturnMimeType(HttpServletRequest req)
          Determines a mime name from the request object.
 String getReturnMimeType(String mediaType)
          Determines a mime name from a media type name.
 BaseMarkupSerializer getSerializer(HttpServletRequest req, OutputStream out)
          Automatically determines the media type from the request object,
 BaseMarkupSerializer getSerializer(HttpServletRequest req, Writer out)
          Automatically determines the media type from the request object,
 BaseMarkupSerializer getSerializer(String mediaType, OutputStream out)
          Another version of getSerializer() with OutputStream as one of the parameters.
 BaseMarkupSerializer getSerializer(String mediaType, Writer out)
          Determines and configures a serialzier that is proper for the specified media type.
 BaseMarkupSerializer getSerializerByName(String serializerName, OutputStream out)
          Gets a serializer by name which writes to the provided OutputStream
 BaseMarkupSerializer getSerializerByName(String serializerName, Writer out)
          Gets a serializer by name which writes to the provided Writer
 void setMediaProps(String uri)
          Initializes media properties table.
 void setMimeProps(String uri)
          Initializes mime properties table.
 void setSerializerProps(String uri)
          Initializes serializer properties table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mediaProps

protected org.jasig.portal.MediaManager.OrderedProps mediaProps

mimeProps

protected org.jasig.portal.MediaManager.OrderedProps mimeProps

serializerProps

protected org.jasig.portal.MediaManager.OrderedProps serializerProps

NULL_USER_AGENT

public static final String NULL_USER_AGENT
A user agent string to use when the user-agent header value itself is null.

See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
See Also:
Constant Field Values

HTMLPublicId

public static String HTMLPublicId

HTMLSystemId

public static String HTMLSystemId

XHTMLPublicId

public static String XHTMLPublicId

XHTMLSystemId

public static String XHTMLSystemId

WMLPublicId

public static String WMLPublicId

WMLSystemId

public static String WMLSystemId
Method Detail

getMediaManager

public static MediaManager getMediaManager()
7/25/05 - UP-1181 - change MediaManager into a singleton Returns the default MediaManager singleton


getMediaManager

public static MediaManager getMediaManager(boolean omitDocType)

setMediaProps

public void setMediaProps(String uri)
Initializes media properties table.

Parameters:
uri - location of the media properties file, complete with the filename

setMimeProps

public void setMimeProps(String uri)
Initializes mime properties table.

Parameters:
uri - location of the mime properties file, complete with the filename

setSerializerProps

public void setSerializerProps(String uri)
Initializes serializer properties table.

Parameters:
uri - location of the serializer properties file, complete with the filename

getMedia

public String getMedia(HttpServletRequest req)
Determines a media name from the request object.

Parameters:
req - the request object
Returns:
media name

getMedia

public String getMedia(BrowserInfo bi)
Determines a media name from the browser info object.

Parameters:
bi - the browser info
Returns:
media name

getDefaultMedia

public String getDefaultMedia()
Return a default media type. The default media type is the first media listed in the media.properties file

Returns:
default media name

getReturnMimeType

public String getReturnMimeType(HttpServletRequest req)
Determines a mime name from the request object.

Parameters:
req - the request object
Returns:
mime type string

getReturnMimeType

public String getReturnMimeType(String mediaType)
Determines a mime name from a media type name.

Parameters:
mediaType - the media type name
Returns:
mime type string

getSerializer

public BaseMarkupSerializer getSerializer(String mediaType,
                                          Writer out)
Determines and configures a serialzier that is proper for the specified media type. "serializer.properties" file contains mapping of media names to serializer names. Prior to using a serializer returned by this function, make sure to set it up by calling asContentHandler(), asDocumentHandler() or asDOMSerializer().

Parameters:
mediaType - media name
out - output writer
Returns:
the serializer

getSerializerByName

public BaseMarkupSerializer getSerializerByName(String serializerName,
                                                OutputStream out)
                                         throws UnsupportedEncodingException
Gets a serializer by name which writes to the provided OutputStream

Parameters:
serializerName -
out -
Returns:
the serializer
Throws:
UnsupportedEncodingException

getSerializerByName

public BaseMarkupSerializer getSerializerByName(String serializerName,
                                                Writer out)
Gets a serializer by name which writes to the provided Writer

Parameters:
serializerName -
out -
Returns:
the serializer

getSerializer

public BaseMarkupSerializer getSerializer(String mediaType,
                                          OutputStream out)
                                   throws UnsupportedEncodingException
Another version of getSerializer() with OutputStream as one of the parameters.

Parameters:
mediaType - media type string
out - output stream
Returns:
the markup serializer
Throws:
UnsupportedEncodingException

getSerializer

public BaseMarkupSerializer getSerializer(HttpServletRequest req,
                                          Writer out)
Automatically determines the media type from the request object,

Parameters:
req - the request object
out - the output writer object
Returns:
the markup serializer

getSerializer

public BaseMarkupSerializer getSerializer(HttpServletRequest req,
                                          OutputStream out)
                                   throws UnsupportedEncodingException
Automatically determines the media type from the request object,

Parameters:
req - the request object
out - the output stream object
Returns:
the markup serializer
Throws:
UnsupportedEncodingException


Copyright © 2010 Jasig. All Rights Reserved.