Media Authoring
with Java API

tv.amwa.maj.industry
Class TypeDefinitionWarehouse

java.lang.Object
  extended by tv.amwa.maj.industry.TypeDefinitionWarehouse

public final class TypeDefinitionWarehouse
extends Object

Stores and provides access to type definitions, allowing the range of supported types to be dynamically extended at runtime.

This class acts as a static cache of all type definitions known to a runtime on a specific Java virtual machine. An internal hashtable provides an efficient way of mapping from a type name or the type's identifying universal label to the types meta-class. This class is used to bootstrap the types known to a virtual machine on MAJ API initialization.

To add a user-defined extension type, use addTypesFromClass(Class).

In this implementation, you can also get a reference to a type definition using the static references within each class. For example, the following Java statement evaluates to true:

 TypeDefinitionFactory.forName("UInt8") == TypeDefinitionInteger.UInt8
 

Author:
Richard Cartwright
See Also:
TypeDefinition, AAFFactory.typeDefinitionForName(String), AAFFactory.typeDefinitionForIdentification(tv.amwa.maj.record.AUID)

Method Summary
static void addTypesFromClass(Class<?> typeClass)
          Looks through the given class for public static fields of type definitions and adds these to the known type definitions available from this factory.
static TypeDefinition forIdentification(AUID identification)
          Finds and returns the type definition for the given AUID identification.
static TypeDefinition forName(String typeName)
          Finds and returns the type definition for the given name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addTypesFromClass

public static final void addTypesFromClass(Class<?> typeClass)
                                    throws NullPointerException

Looks through the given class for public static fields of type definitions and adds these to the known type definitions available from this factory.

This method picks out static fields in the given class and adds them to the cache of known types in this class. Here is an example of the declaration of a UInt8 value:

   public final static TypeDefinitionInteger UInt8 = new TypeDefinitionInteger(
     new AUID(0x01010100, (short) 0x0000, (short) 0x0000,
              new byte[] { 0x06, 0x0e, 0x2b, 0x34, 0x01, 0x04, 0x01, 0x01 } ),
     "UInt8", (byte) 1, false);
 

Parameters:
typeClass - Class to check for static type definition instances.
Throws:
NullPointerException - The given class is null.

forName

public static final TypeDefinition forName(String typeName)
                                    throws NullPointerException

Finds and returns the type definition for the given name. Type definition names are the same as used in the AAF specification, for example:

If a corresponding type cannot be found, this method returns null.

Parameters:
typeName - Name of the type definition to check for.
Returns:
Type definition corresponding to the given name.
Throws:
NullPointerException - The given type name is null.

forIdentification

public static final TypeDefinition forIdentification(AUID identification)
                                              throws NullPointerException

Finds and returns the type definition for the given AUID identification. If a type definition matching the given identification cannot be found, null is returned.

Parameters:
identification - AUID to use to lookup a type definition.
Returns:
Type definition matching the identification.
Throws:
NullPointerException - The given type identifier is null.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.