javax.emb
Class MediaSegment

java.lang.Object
  extended byjavax.emb.MediaSegment

public final class MediaSegment
extends java.lang.Object

This class models a portion of a (usually non-embedded) medium that is optionally followed by a reference to an external media file represented by a media location URL.

Splitting up media content into media segments is useful if references contained have to be updated, for example because one of the children has moved. In order to handle such a situation it is necessary to disassemble the media, update the reference, and reassemble it afterwards. MediaFormat instances provide the operations necessary, and the MediaSegment class describes the data container for a single segment.

The value null is a valid value for the childLocation property and indicates that the segment content is not followed by any reference, for example because the end of media is reached. The content of media segments is restricted to a theoretical maximum size of 2GB due to the Java restriction of byte array size. However this should not impose a restriction in practice as non-embedded media tends to be fairly small in size, and embedded media doesn't require segmentation at all.

Media segments also implement Serializable in order to allow instances to be exchanged over remote boundaries.


Constructor Summary
MediaSegment()
          Default constructor for media segments.
 
Method Summary
 java.net.URL getChildLocation()
          Returns the media location of a media resource referenced by the receiver.
 byte[] getContent()
          Returns the content of the media segment as a byte array.
 void setChildLocation(java.net.URL childLocation)
          Sets the media location of a media resource referenced by the receiver.
 void setContent(byte[] content)
          Sets the content of the media segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaSegment

public MediaSegment()
Default constructor for media segments. The content field is initialized to an empty byte array, and the child location field is initialized to null.

Method Detail

getContent

public byte[] getContent()
Returns the content of the media segment as a byte array.

Returns:
the segment content.

getChildLocation

public java.net.URL getChildLocation()
Returns the media location of a media resource referenced by the receiver.

Returns:
the child location.

setContent

public void setContent(byte[] content)
Sets the content of the media segment.

Parameters:
content - the segment content.
Throws:
java.lang.NullPointerException - if the value passed is null.

setChildLocation

public void setChildLocation(java.net.URL childLocation)
Sets the media location of a media resource referenced by the receiver. Passing the value null is allowed.

Parameters:
childLocation - the child location.