javax.emb
Class GenericMediaFormat

java.lang.Object
  extended byjavax.emb.GenericMediaFormat
All Implemented Interfaces:
MediaFormat (src) , java.io.Serializable

public class GenericMediaFormat
extends java.lang.Object
implements MediaFormat (src)

This class offers a generic implementation of the MediaFormat (src) interface for use with all kinds of embedded media formats. Note that this class should not be used to represent non-embedded media formats, as it does not handle parent/child relationships. By registering instances of this class with the MediaFormatRegistry (src) described in the followup section, various media formats can be supported in case no format specific support is available.

The public constant DEFAULT_PROXY contains an image that can be used as a default proxy for all kinds of media formats or in case the generation of a proxy fails for whatever reason.

See Also:
Serialized Form

Field Summary
static Media (src) DEFAULT_PROXY
           
 
Constructor Summary
GenericMediaFormat()
           
 
Method Summary
 byte[] assembleContent(java.net.URL mediaLocation, MediaSegment (src) [] mediaSegments)
          Returns the content of the given media segment array's first element, or an empty byte array if no element is passed.
 MediaSegment (src) [] disassembleContent(java.net.URL mediaLocation, byte[] mediaContent)
          Disassembles the given media content.
 MediaHeader (src) extractHeader(java.io.InputStream mediaContent)
          Returns an instance of class GenericMediaHeader, as this class cannot make any assumptions about header fields.
 Media (src) extractProxy(java.io.InputStream mediaContent)
          Returns a default image that is suitable to represent all kinds of content.
 java.lang.String getDefaultMimeType()
          Returns Media.MIME_TYPE_UNKNOWN, as this class cannot make any assumptions about mime types.
 boolean isEmbedded()
          Returns true, as this class assumes media to be embedded.
 boolean isStreamingDesirable()
          Returns false, as this class cannot make any assumptions about media to be streamable or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROXY

public static final Media (src)  DEFAULT_PROXY
Constructor Detail

GenericMediaFormat

public GenericMediaFormat()
Method Detail

assembleContent

public byte[] assembleContent(java.net.URL mediaLocation,
                              MediaSegment (src) [] mediaSegments)
                       throws MediaException (src) 
Returns the content of the given media segment array's first element, or an empty byte array if no element is passed.

Specified by:
assembleContent in interface MediaFormat (src)
Parameters:
mediaLocation - the intended location of the media to be assembled.
mediaSegments - the segments that are to be assembled.
Returns:
the assembled content.
Throws:
FormatSyntaxException (src) - if the given media segment array contains more than one element, or if an element is passed that contains a child link that is not null.
java.lang.NullPointerException - if the given segment array is null.
ContentTooLargeException (src) - if the assembled content is larger than the maximum Java array size of 2 GB.
MediaException (src)

disassembleContent

public MediaSegment (src) [] disassembleContent(java.net.URL mediaLocation,
                                         byte[] mediaContent)
                                  throws MediaException (src) 
Disassembles the given media content. As embedded media doesn – t contain any links and therefore consists of a single media segment, this generic implementation returns a one-element array of media segments, with a segment element composed of null as child location and the given media content as content.

Specified by:
disassembleContent in interface MediaFormat (src)
Parameters:
mediaLocation - the location of the media to be disassembled.
mediaContent - the content to be disassembled.
Returns:
the segments.
Throws:
java.lang.NullPointerException - if the content passed is null.
MediaException (src)

extractHeader

public MediaHeader (src)  extractHeader(java.io.InputStream mediaContent)
                          throws MediaException (src) 
Returns an instance of class GenericMediaHeader, as this class cannot make any assumptions about header fields.

Specified by:
extractHeader in interface MediaFormat (src)
Parameters:
mediaContent - the media content to extract the header from.
Returns:
the media header.
Throws:
java.lang.NullPointerException - if the value passed is null.
MediaException (src)

extractProxy

public Media (src)  extractProxy(java.io.InputStream mediaContent)
                   throws MediaException (src) 
Returns a default image that is suitable to represent all kinds of content.

Specified by:
extractProxy in interface MediaFormat (src)
Parameters:
mediaContent - the media content.
Returns:
the proxy.
Throws:
MediaException (src) - if proxy can't be generated.

getDefaultMimeType

public java.lang.String getDefaultMimeType()
Returns Media.MIME_TYPE_UNKNOWN, as this class cannot make any assumptions about mime types.

Specified by:
getDefaultMimeType in interface MediaFormat (src)
Returns:
Media.MIME_TYPE_UNKNOWN.

isEmbedded

public boolean isEmbedded()
Returns true, as this class assumes media to be embedded.

Specified by:
isEmbedded in interface MediaFormat (src)
Returns:
true.

isStreamingDesirable

public boolean isStreamingDesirable()
Returns false, as this class cannot make any assumptions about media to be streamable or not.

Specified by:
isStreamingDesirable in interface MediaFormat (src)
Returns:
false.