Media Authoring
with Java API

tv.amwa.maj.meta
Class TypeDefinitionRecord

java.lang.Object
  extended by tv.amwa.maj.meta.MetaDefinition
      extended by tv.amwa.maj.meta.TypeDefinition
          extended by tv.amwa.maj.meta.TypeDefinitionRecord
All Implemented Interfaces:
Serializable, DefinitionType, MetaDefinition, TypeDefinition, TypeDefinitionRecord, XMLSerializable, MAJCommon

@AAFClass(uuid1=218169601,
          uuid2=525,
          uuid3=0,
          uuid4={6,14,43,52,2,6,1,1},
          definedName="TypeDefinitionRecord",
          description="The TypeDefinitionRecord class defines a property type that consists of an ordered set of fields, where each field has a name and type.")
public final class TypeDefinitionRecord
extends TypeDefinition
implements TypeDefinitionRecord, Serializable, XMLSerializable, MAJCommon

Implements the definition of a property type that consists of an ordered set of fields, where each field has a name and type.

THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.

Author:
Richard Cartwright
See Also:
Serialized Form

Nested Class Summary
static class TypeDefinitionRecord.RecordValue
           
static class TypeDefinitionRecord.XMLHandler
           
 
Field Summary
static TypeDefinitionRecord AUID
           
static TypeDefinitionRecord DateStruct
           
static TypeDefinitionRecord MobIDType
           
static TypeDefinitionRecord ProductVersion
           
static TypeDefinitionRecord Rational
           
static TypeDefinitionRecord RGBAComponent
           
static TypeDefinitionRecord TimeStamp
           
static TypeDefinitionRecord TimeStruct
           
static TypeDefinitionRecord VersionNumber
           
static TypeDefinitionRecord VersionType
           
 
Constructor Summary
TypeDefinitionRecord(AUID identification, String typeName, String[] names, Map<String,TypeDefinition> elements)
          Creates and initializes this record type definition, which defines a property type that consists of an ordered set of fields, where each field has a name and type.
TypeDefinitionRecord(AUID identification, String typeName, String[] names, TypeDefinition[] types)
          Version of the constructor that can be used in static initializers.
 
Method Summary
 void appendXMLChildren(Node parent)
          Append child elements to the given parent node to serialize the value of an object to an XML fragment.
 PropertyValue createValue(Object javaValue)
          Create a property value from the given Java object.
 PropertyValue createValueFromObject(Object initialData)
          Creates and returns a new record property value that is initialized using the given Java object.
 PropertyValue createValueFromValues(PropertyValue[] memberValues)
          Creates and returns a new record property value from the given array of property values, matching the elements of the given array to the fields of a new record value by index into the list of fields of this record type definition.
 boolean deepEquals(Object o)
          Check to see if this definition is equal to the given object by comparing each property.
 int getCount()
          Returns the number of fields stored in a record defined by this record type definition.
 String getMemberName(int index)
          Returns the name of the field of a record defined by this record type definition at the given index into the list of fields.
 String[] getMemberNames()
           
 TypeDefinition getMemberType(int index)
          Returns the type of the field of a record defined by this record type definition at the given index into the list of fields.
 List<TypeDefinition> getMemberTypes()
           
 Object getObject(PropertyValue recordProperty, Class<?> template)
          Returns the fields from the given record property value as the current value of a new Java object.
 TypeCategory getTypeCategory()
          Returns the type category to which this type definition belongs, which corresponds to its sub interface.
 PropertyValue getValue(PropertyValue recordProperty, int index)
          Returns the property value of one of the fields of the given record property value, where the value to return is determined by an index into the list of fields of this record type definition.
 PropertyValue getValue(PropertyValue recordProperty, String memberName)
          Returns the property value of one of the fields of the given record property value, where the value to return corresponds to the given field name.
 boolean resolveTheUnresolved(Map<AUID,MetaDefinition> localTypes)
          Called after the parsing of an element containing references.
 void setObject(PropertyValue recordProperty, Object data)
          Sets the value of the given record property value using the given Java object.
 void setPropertiesFromInterface(TypeDefinitionRecord castFrom)
           
 void setValue(PropertyValue recordProperty, int index, PropertyValue memberProperty)
          Sets the value of a field of the given record property value, determined by index into the list of fields of its record type definition.
 void setValue(PropertyValue recordProperty, String memberName, PropertyValue memberProperty)
          Sets the value of a field of the given record property value, determined by field name, to be the given field property value.
 
Methods inherited from class tv.amwa.maj.meta.TypeDefinition
setPropertiesFromInterface
 
Methods inherited from class tv.amwa.maj.meta.MetaDefinition
castFromInterface, equals, getAUID, getDescription, getIdentification, getName, hashCode, setDescription, setName, setPropertiesFromInterface, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface tv.amwa.maj.iface.MetaDefinition
getAUID, getDescription, getName, setDescription, setName
 
Methods inherited from interface tv.amwa.maj.meta.MAJCommon
equals, hashCode, toString
 

Field Detail

Rational

public static final TypeDefinitionRecord Rational

AUID

public static final TypeDefinitionRecord AUID

MobIDType

public static final TypeDefinitionRecord MobIDType

ProductVersion

public static final TypeDefinitionRecord ProductVersion

VersionType

public static final TypeDefinitionRecord VersionType

VersionNumber

public static final TypeDefinitionRecord VersionNumber

RGBAComponent

public static final TypeDefinitionRecord RGBAComponent

DateStruct

public static final TypeDefinitionRecord DateStruct

TimeStruct

public static final TypeDefinitionRecord TimeStruct

TimeStamp

public static final TypeDefinitionRecord TimeStamp
Constructor Detail

TypeDefinitionRecord

public TypeDefinitionRecord(AUID identification,
                            @AAFString
                            String typeName,
                            @AAFString
                            String[] names,
                            Map<String,TypeDefinition> elements)
                     throws NullPointerException,
                            IllegalArgumentException

Creates and initializes this record type definition, which defines a property type that consists of an ordered set of fields, where each field has a name and type.

It is only possible to use the following types as members of a record:

If a type definition of a kind other than one listed above is used, an IllegalArgumentException will be thrown.

Record type definitions provide a documented mechanism for extended the AAF meta model. However, care must be taken as any user-defined record types may not be interoperable with other systems if the record is not registered. The official registry of type definitions is available from SMPTE at SMPTE Metadata Registries And Related Items. The full range of data types documented in the AAF 1.1 object specification can be accessed by name and identification using either AAFFactory.typeDefinitionForName(String) or AAFFactory.typeDefinitionForIdentification(tv.amwa.maj.record.AUID) respectively.

Parameters:
identification - AUID to be used to identify this type.
typeName - Friendly name for the record type definition.
names - Names of the element of the record in the order of the records.
elements - Elements of the records represented as a map from name to type.
Throws:
NullPointerException - One or more of the identification, names or elements arguments is null, or one or more of the elements of the given arrays is null.
IllegalArgumentException - One or more of the types contained in the member type array is not a permissable type for a record. Alternatively, a member type name is duplicated in the given array of member names.

TypeDefinitionRecord

public TypeDefinitionRecord(AUID identification,
                            @AAFString
                            String typeName,
                            @AAFString
                            String[] names,
                            TypeDefinition[] types)
                     throws NullPointerException,
                            IndexOutOfBoundsException

Version of the constructor that can be used in static initializers.

Parameters:
identification - AUID to be used to identify this type.
typeName - Friendly name for the record type definition.
names - Names of the element of the record in the order of the records.
types - Elements of the records represented as a map from name to type mapped to the names by array index.
Throws:
NullPointerException - One or more of the arguments is null.
IndexOutOfBoundsException - The arrays are of different lengths.
See Also:
TypeDefinitionRecord(tv.amwa.maj.record.AUID, String, String[], Map)
Method Detail

setPropertiesFromInterface

public final void setPropertiesFromInterface(TypeDefinitionRecord castFrom)
See Also:
MetaDefinition.setPropertiesFromInterface(tv.amwa.maj.iface.MetaDefinition)

getMemberNames

@AAFProperty(uuid1=50397699,
             uuid2=1536,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="MemberNames",
             typeName="StringArray",
             optional=false,
             uniqueIdentifier=false,
             pid=29)
public final String[] getMemberNames()

getMemberTypes

@AAFProperty(uuid1=100729095,
             uuid2=4352,
             uuid3=0,
             uuid4={6,14,43,52,1,1,1,2},
             definedName="MemberTypes",
             typeName="WeakReferenceVector of TypeDefinition",
             optional=false,
             uniqueIdentifier=false,
             pid=28)
public final List<TypeDefinition> getMemberTypes()

createValueFromObject

public final PropertyValue createValueFromObject(Object initialData)
                                          throws NullPointerException,
                                                 IllegalPropertyValueException,
                                                 BadTypeException
Description copied from interface: TypeDefinitionRecord

Creates and returns a new record property value that is initialized using the given Java object. The Java reflection API is used to discover if the fields of the record, matched by name, are readable from the given object, either as public fields or as public get... methods. The type of each field in the Java object must be compatible with the type definition defined for that field in this record type definition.

Note that the object may define more fields than the number of elements of the record. If this is the case, the record property value will contain less information than the given object instance. Be aware that a future call to TypeDefinitionRecord.getObject(PropertyValue, Class) with a record property created by this method may result in a different Java object value.

Specified by:
createValueFromObject in interface TypeDefinitionRecord
Parameters:
initialData - Object to use to set the values of the a new record property value.
Returns:
Newly created record property value, created using the the current value of the given object.
Throws:
NullPointerException - The given initial data object is null.
IllegalPropertyValueException - The given object does not provide all the required values to create a new record property value.
BadTypeException - The type of one or more of the object fields cannot be converted to the type of the matching field as defined in this record type definition.
See Also:
Class.getFields(), Class.getMethods(), TypeDefinitionRecord.createValueFromValues(PropertyValue[])

createValueFromValues

public final PropertyValue createValueFromValues(PropertyValue[] memberValues)
                                          throws NullPointerException,
                                                 IllegalArgumentException,
                                                 BadTypeException
Description copied from interface: TypeDefinitionRecord

Creates and returns a new record property value from the given array of property values, matching the elements of the given array to the fields of a new record value by index into the list of fields of this record type definition.

Specified by:
createValueFromValues in interface TypeDefinitionRecord
Parameters:
memberValues - Array of property values to set for the new record property value.
Returns:
Newly created record property value from the given array of property values.
Throws:
NullPointerException - The given array of field values is null or one or more of the elements of the array is null.
IllegalArgumentException - The given array is of a different size from that defined by the record type definition and returned by TypeDefinitionRecord.getCount().
BadTypeException - One or more of the given property values is of a type that does not match the one defined for the field at the equivalent index in the list of fields of this record type definition.

getCount

public final int getCount()
Description copied from interface: TypeDefinitionRecord

Returns the number of fields stored in a record defined by this record type definition.

Specified by:
getCount in interface TypeDefinitionRecord
Returns:
Number of fields stored in a record defined by this record type definition.

getObject

public final Object getObject(PropertyValue recordProperty,
                              Class<?> template)
                       throws NullPointerException,
                              BadTypeException,
                              IllegalPropertyValueException
Description copied from interface: TypeDefinitionRecord

Returns the fields from the given record property value as the current value of a new Java object. A class must be provided that is the template for the new object and this class must have public fields or set... methods matching the fields of this record type definition.

If the given class does not define a public field that matches one of the fields, the method still completes successfully. Be aware that in this case, the Java object contains less information than the record property value and subsequent use of the return value in a call to TypeDefinitionRecord.setObject(PropertyValue, Object) will cause an IllegalPropertyValueException.

Specified by:
getObject in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record to extract the field values from.
template - Class template to use to instantiate a Java object from the field values of the given record property value.
Returns:
New Java object with its values set by the fields of the given record property value.
Throws:
NullPointerException - One or both of the arguments is/are null.
BadTypeException - The types of the field properties of the record type definition cannot be converted to the types of the fields of an instance of the given class.
IllegalPropertyValueException - The given property value is not defined by a compatible record type definition.
See Also:
TypeDefinitionRecord.createValueFromObject(Object), TypeDefinitionRecord.setObject(PropertyValue, Object)

getMemberName

public final String getMemberName(int index)
                           throws IndexOutOfBoundsException
Description copied from interface: TypeDefinitionRecord

Returns the name of the field of a record defined by this record type definition at the given index into the list of fields.

Specified by:
getMemberName in interface TypeDefinitionRecord
Parameters:
index - 0-based index into the record type definition's list of fields.
Returns:
Field name at the given index.
Throws:
IndexOutOfBoundsException - The index is outside the acceptable range for the number of fields of this record type definition.

getMemberType

public final TypeDefinition getMemberType(int index)
                                   throws IndexOutOfBoundsException
Description copied from interface: TypeDefinitionRecord

Returns the type of the field of a record defined by this record type definition at the given index into the list of fields.

Specified by:
getMemberType in interface TypeDefinitionRecord
Parameters:
index - 0-based index into the record type definition's fields.
Returns:
Field type at the given index.
Throws:
IndexOutOfBoundsException - The index is outside the acceptable range for the list of fields of this record type definition.

getValue

public final PropertyValue getValue(PropertyValue recordProperty,
                                    int index)
                             throws NullPointerException,
                                    IllegalPropertyValueException,
                                    IndexOutOfBoundsException
Description copied from interface: TypeDefinitionRecord

Returns the property value of one of the fields of the given record property value, where the value to return is determined by an index into the list of fields of this record type definition.

Specified by:
getValue in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record that is to have a value returned.
index - 0-based index into the array of fields of this record type definition that is used to determine the field of the given record property value to return.
Returns:
Member of the given record property value selected using the given index.
Throws:
NullPointerException - The given record property value is null.
IllegalPropertyValueException - The type of the given property value does not match this record type definition.
IndexOutOfBoundsException - The given index is not within the acceptable range for this record type definition.
See Also:
TypeDefinitionRecord.getValue(PropertyValue, String)

getValue

public final PropertyValue getValue(PropertyValue recordProperty,
                                    String memberName)
                             throws NullPointerException,
                                    IllegalPropertyValueException,
                                    IllegalArgumentException
Description copied from interface: TypeDefinitionRecord

Returns the property value of one of the fields of the given record property value, where the value to return corresponds to the given field name.

Specified by:
getValue in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record that is to have a value returned.
memberName - Name of the field value to retrieve.
Returns:
Property value containing the requested field value.
Throws:
NullPointerException - One or both of the arguments is/are null.
IllegalPropertyValueException - The type of the given property value does not match this record type definition.
IllegalArgumentException - The given field name does not identify a field of this record type definition.

setObject

public final void setObject(PropertyValue recordProperty,
                            Object data)
                     throws NullPointerException,
                            IllegalPropertyValueException,
                            BadTypeException
Description copied from interface: TypeDefinitionRecord

Sets the value of the given record property value using the given Java object. The Java reflection API is used to discover if the fields of the record are readable from the given object, either as public fields or public get... methods. The types of the fields of the given object must be compatible with the type definitions of the matching fields in this record type definition.

Note that the object may define more fields than the number of elements of the record. If this is the case, the record property value will contain less information than the given object. Be aware that a subsequent call to TypeDefinitionRecord.getObject(PropertyValue, Class) with a record property value created by this method may result in a different object value.

Specified by:
setObject in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record that is to have its values set.
data - A Java object that is used to set the fields of the given record property value.
Throws:
NullPointerException - One or both of the arguments is/are null.
IllegalPropertyValueException - The given object does not provide values for one or more of the record's values, or the given property value is not defined by a compatible record type definition.
BadTypeException - One or more of the field types of the given object do not match or cannot be converted to the type of their equivalent property in this record type definition.
See Also:
TypeDefinitionRecord.createValueFromObject(Object), TypeDefinitionRecord.getObject(PropertyValue, Class)

setValue

public final void setValue(PropertyValue recordProperty,
                           int index,
                           PropertyValue memberProperty)
                    throws NullPointerException,
                           IllegalPropertyValueException,
                           IndexOutOfBoundsException,
                           BadTypeException
Description copied from interface: TypeDefinitionRecord

Sets the value of a field of the given record property value, determined by index into the list of fields of its record type definition. The field property must be of a type that is compatible with the type at the given index, as returned by TypeDefinitionRecord.getMemberType(int) for the same index.

Specified by:
setValue in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record that is to have one of its fields set.
index - 0-based index into the record type definition defining the given record property value. This determines the name and required type of the record field.
memberProperty - Value to set as a field of the given record property value.
Throws:
NullPointerException - One or both of the property arguments is/are null.
IllegalPropertyValueException - The type of the given property definition does not match this record type definition.
IndexOutOfBoundsException - The given index is outside the range of the list of fields of this record type definition.
BadTypeException - The type of the given field property value does not match that defined at the given index in the record type definition.
See Also:
TypeDefinitionRecord.getValue(PropertyValue, int), TypeDefinitionRecord.setValue(PropertyValue, String, PropertyValue)

setValue

public final void setValue(PropertyValue recordProperty,
                           String memberName,
                           PropertyValue memberProperty)
                    throws NullPointerException,
                           IllegalPropertyValueException,
                           IllegalArgumentException,
                           BadTypeException
Description copied from interface: TypeDefinitionRecord

Sets the value of a field of the given record property value, determined by field name, to be the given field property value. The field property must be of a type that is compatible with the type of the field specified in the list of fields of this property.

Specified by:
setValue in interface TypeDefinitionRecord
Parameters:
recordProperty - Property value containing a record that is to have one of its fields set.
memberName - Name of the field to set the value for within the given record property value.
memberProperty - Value to set the field to.
Throws:
NullPointerException - One or more or the arguments is/are null and all are required.
IllegalPropertyValueException - The type of the given record property definition does not match this record type definition.
IllegalArgumentException - The field name is not known as a field of this record type definition.
BadTypeException - The type of the given field property value does not match that defined for the field with given name in this record type definition.
See Also:
TypeDefinitionRecord.getValue(PropertyValue, String), TypeDefinitionRecord.setValue(PropertyValue, int, PropertyValue)

createValue

public final PropertyValue createValue(Object javaValue)
                                throws ClassCastException
Description copied from class: TypeDefinition

Create a property value from the given Java object. If the type of the object is not compatible with this type definition, a ClassCastException is thrown.

Specified by:
createValue in interface TypeDefinition
Specified by:
createValue in class TypeDefinition
Parameters:
javaValue - Java object to use to create a property value of this type.
Returns:
Property value representing the given value.
Throws:
ClassCastException - The given object cannot be cast to a property value with this type definition.

getTypeCategory

public final TypeCategory getTypeCategory()
Description copied from interface: TypeDefinition

Returns the type category to which this type definition belongs, which corresponds to its sub interface. For example, TypeCategory.Int is returned for a TypeDefinitionInteger.

Specified by:
getTypeCategory in interface TypeDefinition
Specified by:
getTypeCategory in class TypeDefinition
Returns:
Type category to which the type definition belongs.
See Also:
TypeCategory

deepEquals

public final boolean deepEquals(Object o)
Description copied from class: MetaDefinition

Check to see if this definition is equal to the given object by comparing each property. The MetaDefinition.equals(Object) method only checks that the identies of two definitions are equal, relying on the unqiueness ensured by identity registration. This method is provided for debugging and validation purposes.

Overrides:
deepEquals in class MetaDefinition
Parameters:
o - Object to compare to this definition.
Returns:
Is the given object a meta definiition with all of its properties equal to this meta definition?

appendXMLChildren

public final void appendXMLChildren(Node parent)
Description copied from interface: XMLSerializable

Append child elements to the given parent node to serialize the value of an object to an XML fragment. Methods of the XMLBuilder class are provided to help with this process.

Specified by:
appendXMLChildren in interface XMLSerializable
Overrides:
appendXMLChildren in class MetaDefinition
Parameters:
parent - XML parent element to append child nodes to.

resolveTheUnresolved

public final boolean resolveTheUnresolved(Map<AUID,MetaDefinition> localTypes)
Description copied from class: MetaDefinition

Called after the parsing of an element containing references. The references will be resolved against the glocal TypeDefinitionWarehouse first and then against the given map of unregistered type definitions.

Parameters:
localTypes - Unregistered type definitions to resolve references against.
Returns:
Have all the unresolved type references now been resolved?

Media Authoring
with Java API

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