javax.media
Class Format

java.lang.Object
  |
  +--javax.media.Format
Direct Known Subclasses:
AudioFormat, ContentDescriptor, VideoFormat

public class Format
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

The Format class abstracts the exact media format in the Java Media framework. It carries no encoding-specific parameters or timing information global to the presentation.

Comparing different formats

Not all attributes in a Format object needs to be specified. This allows a Format object to specify a format that have undefined attributes.

Two methods are provided to compare different Formats. The equals method returns true if two format objects are the same: of the same type and all their attributes are the same. The matches method relaxes the comparison. It compares only the attributes that are specified.

Since:
JMF 2.0
See Also:
Serialized Form

Field Summary
static java.lang.Class byteArray
           
protected  java.lang.Class clz
           
protected  java.lang.Class dataType
           
protected  java.lang.String encoding
           
static int FALSE
           
static java.lang.Class formatArray
           
static java.lang.Class intArray
           
static int NOT_SPECIFIED
           
static java.lang.Class shortArray
           
static int TRUE
           
 
Constructor Summary
Format(java.lang.String encoding)
           
Format(java.lang.String encoding, java.lang.Class dataType)
           
 
Method Summary
 java.lang.Object clone()
          Return a clone of this format.
protected  void copy(Format f)
          Copy the attributes from this object
 boolean equals(java.lang.Object format)
           
 java.lang.Class getDataType()
          Returns the type of the data that this format requires.
 java.lang.String getEncoding()
          Return the uniquely-qualified encoding name of the format.
 Format intersects(Format format)
          Find the common attributes of two matching formats.
 boolean matches(Format format)
          Test to see if the given format matches this format.
 java.lang.String toString()
          Returns a string which describes the format parameters.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NOT_SPECIFIED

public static final int NOT_SPECIFIED

TRUE

public static final int TRUE

FALSE

public static final int FALSE

encoding

protected java.lang.String encoding

intArray

public static final java.lang.Class intArray

shortArray

public static final java.lang.Class shortArray

byteArray

public static final java.lang.Class byteArray

formatArray

public static final java.lang.Class formatArray

dataType

protected java.lang.Class dataType

clz

protected java.lang.Class clz
Constructor Detail

Format

public Format(java.lang.String encoding)
Parameters:
encoding - the encoding of this format.

Format

public Format(java.lang.String encoding,
              java.lang.Class dataType)
Parameters:
encoding - the encoding of this format.
dataType - the type of the data object. e.g. for byte array, use "Format.byteArray"
Method Detail

getEncoding

public java.lang.String getEncoding()
Return the uniquely-qualified encoding name of the format. In Sun's implementation of JMF, the strings follow the QuickTime codec strings.
Returns:
The encoding of the format.

getDataType

public java.lang.Class getDataType()
Returns the type of the data that this format requires. For byte array, it returns "byte[].class"

equals

public boolean equals(java.lang.Object format)
Returns:
true if the given format is the same as this one.
Overrides:
equals in class java.lang.Object

matches

public boolean matches(Format format)
Test to see if the given format matches this format. Matches compares attributes that are defined and ignore attributes that are unspecified. Two formats do not have to be of the same class to be considered a match. Say "A" are "B" are the two classes. If "A" derives "B" or "B" derives "A", then a match is possible (after comparing individual attributes. Otherwise, matches fails. This is to prevent matching VideoFormat and AudioFormat, for example.
Returns:
true if the given format matches this one.

intersects

public Format intersects(Format format)
Find the common attributes of two matching formats. If the given format does not match this one, the result is undefined. Otherwise, it returns a format object with its attributes set to the common attributes of the two.
Returns:
a format object with its attributes set to the common attributes of the two.
See Also:
matches(javax.media.Format)

clone

public java.lang.Object clone()
Return a clone of this format.
Overrides:
clone in class java.lang.Object

copy

protected void copy(Format f)
Copy the attributes from this object

toString

public java.lang.String toString()
Returns a string which describes the format parameters. For example: "PCM, 44.1 KHz, Stereo, Signed".
Returns:
a string which describes the format parameters.
Overrides:
toString in class java.lang.Object