javax.emb
Class MediaFormatRegistry

java.lang.Object
  extended byjavax.emb.MediaFormatRegistry

public final class MediaFormatRegistry
extends java.lang.Object

This singleton class manages the different header types and allows the generic selection of a format bean suitable for a given media. The selection criterion is the file extension associated with the media, and a media format can be registered multiple times if many file extensions are typically associated with it.

The class has a private default constructor to prevent direct construction of instances in applications. Instead, the SINGLETON constant provides the one and only instance of this class. Implementations are free to initialize the registry with mappings of their choice. However, the design allows applications to plug in additional mappings.


Field Summary
static MediaFormatRegistry (src) SINGLETON
           
 
Method Summary
 void bind(java.lang.String fileExtension, MediaFormat (src)  mediaFormat)
          This operation associates the given file extension with the given media format instance.
 java.util.Iterator getFileExtensions()
          This operation returns the file extensions for which bindings exist in the registry.
 MediaFormat (src) lookup(java.lang.String fileExtension)
          Returns the media format instance registered under the given file extension.
 void rebind(java.lang.String fileExtension, MediaFormat (src)  mediaFormat)
          This operation associates the given file extension with the given media format instance.
 void unbind(java.lang.String fileExtension)
          This method removes the mapping defined by the given file extension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SINGLETON

public static final MediaFormatRegistry (src)  SINGLETON
Method Detail

bind

public void bind(java.lang.String fileExtension,
                 MediaFormat (src)  mediaFormat)
          throws FormatAlreadyBoundException (src) 
This operation associates the given file extension with the given media format instance.

Parameters:
fileExtension - a file extension identifying the format. Note that such extensions should not start with a leading dot.
mediaFormat - the media format instance to be registered.
Throws:
javax.embFormatAlreadyBoundException - if a mapping already exists for the given file extension.
java.lang.NullPointerException - if one of the values passed is null.
FormatAlreadyBoundException (src)

getFileExtensions

public java.util.Iterator getFileExtensions()
This operation returns the file extensions for which bindings exist in the registry.

Returns:
the file extensions.

lookup

public MediaFormat (src)  lookup(java.lang.String fileExtension)
                   throws FormatNotFoundException (src) 
Returns the media format instance registered under the given file extension.

Parameters:
fileExtension - a file extension identifying the format. Note that such extensions should not start with a leading dot.
Throws:
java.lang.NullPointerException - if the value passed is null.
FormatNotFoundException (src)

rebind

public void rebind(java.lang.String fileExtension,
                   MediaFormat (src)  mediaFormat)
This operation associates the given file extension with the given media format instance. If a mapping already exists for the given file extension, it is replaced by the new one.

Parameters:
fileExtension - a file extension identifying the format. Note that such extensions should not start with a leading dot.
mediaFormat - the media format instance to be registered.
Throws:
java.lang.NullPointerException - if one of the values passed is null.

unbind

public void unbind(java.lang.String fileExtension)
            throws FormatNotFoundException (src) 
This method removes the mapping defined by the given file extension.

Parameters:
fileExtension - a file extension identifying the format. Note that such extensions should not start with a leading dot.
Throws:
FormatNotFoundException (src) - if there is no mapping for the given file extension.
java.lang.NullPointerException - if the value passed is null.