@MediaClass(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.", symbol="TypeDefinitionRecord") public final class TypeDefinitionRecordImpl extends SingletonTypeDefinitionImpl implements TypeDefinitionRecord, Serializable, Cloneable
Implements the definition of a property type that consists of an ordered set of fields, where each field has a name and type.
| Modifier and Type | Class and Description |
|---|---|
static class |
TypeDefinitionRecordImpl.RecordValue |
SingletonTypeDefinitionImpl.SingletonMethodBagTypeDefinitionImpl.PropertyValueImplAAF_METADICT_NAMESPACE, AAF_METADICT_PREFIX, AAF_XML_NAMESPACE, AAF_XML_PREFIX, ApplicationPluginObjectID, ApplicationPluginsID, MAX_NUM_RGBA_COMPS, MemberOfID, ObjectClassID, ParentClassID, PropertiesID, XMLClassIDAsAttributeName| Constructor and Description |
|---|
TypeDefinitionRecordImpl(AUID identification,
String typeName,
String[] names,
Map<String,TypeDefinition> elements,
Class<?> specification)
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.
|
TypeDefinitionRecordImpl(AUID identification,
String typeName,
String[] names,
TypeDefinition[] types,
Class<?> specification)
Version of the constructor that can be used in static initializers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
appendMemberName(String memberName) |
void |
appendMemberName(TypeDefinition memberType) |
void |
appendMetadictXML(Node metadict,
String namespace,
String prefix)
Append an XML representation of this meta definition to the given XML node.
|
void |
clearMemberNames() |
void |
clearMemberTypes() |
TypeDefinitionRecord |
clone()
Create a cloned copy of this meta definition.
|
PropertyValue |
createFromBytes(ByteBuffer buffer)
Create a value of this type by reading the bytes in the given byte buffer.
|
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 |
createValueFromString(String content)
Create a record type value of this type from a string representation.
|
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.
|
int |
getCount()
Returns the number of fields stored in a record defined
by this record type definition.
|
Class<?> |
getImplementation()
Returns an implementation of the specified interface if available;
otherwise
null. |
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)
Returns the object representing the record value.
|
Class<?> |
getSpecification()
Returns the interface that specifies acceptable implementations
of record values of this type.
|
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.
|
static String[] |
initializeMemberNames() |
static List<TypeDefinition> |
initializeMemberTypes() |
long |
lengthAsBytes(PropertyValue value)
Returns the number of bytes that the given value of this type is serialized as a
sequence of bytes.
|
static void |
registerInterfaceMapping(Class<?> recordTypeInterface,
Class<?> recordTypeImplementation) |
void |
setObject(PropertyValue recordProperty,
Object data)
Sets the value of the given record property value using
the given Java object.
|
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.
|
List<PropertyValue> |
writeAsBytes(PropertyValue value,
ByteBuffer buffer)
Write the given property value of this type to the given byte stream.
|
List<PropertyValue> |
writeAsStructuredStorageBytes(PropertyValue value,
ByteBuffer buffer)
Write the given property value of this type to the given byte stream that is to be written to a
structured storage format file.
|
setPropertyValuegetNamespace, getPrefix, getPropertyValue, initalizeTypeNameMap, nameToAAFName, resolveReferencesaafNameToName, appendXMLChildren, deepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getComment, getDescription, getIdentification, getName, getSymbol, getWeakTargetReference, hashCode, initializeMetaDefinitionIdentification, initializeMetaDefinitionName, setAAFNamesInUse, setAliases, setDescription, setIdentification, setName, setNamespace, setPrefix, setSymbol, toStringgetPropertyValue, resolveReferences, setPropertyValuedeepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getDescription, getName, getNamespace, getPrefix, getSymbol, hashCode, setAAFNamesInUse, setDescription, setName, setNamespace, setPrefix, setSymbol, toStringgetWeakTargetReferencepublic TypeDefinitionRecordImpl(AUID identification, @AAFString String typeName, @AAFString String[] names, Map<String,TypeDefinition> elements, Class<?> specification) 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:
TypeDefinitionIntegerTypeDefinitionRecordTypeDefinitionEnumerationTypeDefinitionExtendibleEnumerationTypeDefinitionFixedArrayIf 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
Warehouse.lookForType(String) or
Warehouse.lookForType(tv.amwa.maj.record.AUID)
respectively.
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.specification - A Java interface specifying implementations of instances of this type.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 - Thress possible causes: One or more of the types contained in
the member type array is not a permissable type for a record; a
member type name is duplicated in the given array of member names; the given Java specification
is not an interface.public TypeDefinitionRecordImpl(AUID identification, @AAFString String typeName, @AAFString String[] names, TypeDefinition[] types, Class<?> specification) throws NullPointerException, IndexOutOfBoundsException, IllegalArgumentException
Version of the constructor that can be used in static initializers.
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.specification - A Java interface specifying implementations of instances of this type.NullPointerException - One or more of the arguments is null.IndexOutOfBoundsException - The arrays are of different lengths.IllegalArgumentException#TypeDefinitionRecord(tv.amwa.maj.record.AUID, String, String[], Map)public static final void registerInterfaceMapping(Class<?> recordTypeInterface, Class<?> recordTypeImplementation) throws NullPointerException, IllegalArgumentException
@MediaProperty(uuid1=50397699, uuid2=1536, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="MemberNames", typeName="UTF16StringArray", optional=false, uniqueIdentifier=false, pid=29, symbol="MemberNames") public final String[] getMemberNames()
public static final String[] initializeMemberNames()
@MediaPropertyClear(value="MemberNames") public void clearMemberNames()
@MediaListAppend(value="MemberNames") public void appendMemberName(String memberName)
@MediaProperty(uuid1=100729095, uuid2=4352, uuid3=0, uuid4={6,14,43,52,1,1,1,2}, definedName="MemberTypes", typeName="TypeDefinitionWeakReferenceVector", optional=false, uniqueIdentifier=false, pid=28, symbol="MemberTypes") public final List<TypeDefinition> getMemberTypes()
public static final List<TypeDefinition> initializeMemberTypes()
@MediaPropertyClear(value="MemberTypes") public void clearMemberTypes()
@MediaListAppend(value="MemberTypes") public void appendMemberName(TypeDefinition memberType)
public Class<?> getSpecification()
TypeDefinitionRecordReturns the interface that specifies acceptable implementations of record values of this type.
getSpecification in interface TypeDefinitionRecordTypeDefinitionRecord.getImplementation()public Class<?> getImplementation()
TypeDefinitionRecordReturns an implementation of the specified interface if available;
otherwise null.
getImplementation in interface TypeDefinitionRecordTypeDefinitionRecord.getSpecification()public final PropertyValue createValueFromObject(Object initialData) throws BadTypeException
TypeDefinitionRecordCreates 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) with a record
property created by this method may result in a different
Java object value.
createValueFromObject in interface TypeDefinitionRecordinitialData - Object to use to set the values of the a new
record property value. A null value is permitted.BadTypeException - The type of the object
cannot be converted to the interface specification
defined in this record type definition.Class.getFields(),
Class.getMethods(),
TypeDefinitionRecord.createValueFromValues(PropertyValue[])public final PropertyValue createValueFromValues(PropertyValue[] memberValues) throws NullPointerException, IllegalArgumentException, BadTypeException
TypeDefinitionRecordCreates 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.
createValueFromValues in interface TypeDefinitionRecordmemberValues - Array of property values to set for the
new record property value.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.public final int getCount()
TypeDefinitionRecordReturns the number of fields stored in a record defined by this record type definition.
getCount in interface TypeDefinitionRecordpublic final Object getObject(PropertyValue recordProperty) throws NullPointerException, BadTypeException, IllegalPropertyValueException
TypeDefinitionRecordReturns the object representing the record value. Note that the internal value
is permitted to be null.
This method is very similar to recordProperty.getValue()
except that it checks the type definition matches this one first.
getObject in interface TypeDefinitionRecordrecordProperty - Property value containing a record to extract
the field values from.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.TypeDefinitionRecord.createValueFromObject(Object),
TypeDefinitionRecord.setObject(PropertyValue, Object),
PropertyValue.getValue()public final String getMemberName(int index) throws IndexOutOfBoundsException
TypeDefinitionRecordReturns the name of the field of a record defined by this record type definition at the given index into the list of fields.
getMemberName in interface TypeDefinitionRecordindex - 0-based index into the record type definition's list of fields.IndexOutOfBoundsException - The index is outside the
acceptable range for the number of fields of this record type
definition.public final TypeDefinition getMemberType(int index) throws IndexOutOfBoundsException
TypeDefinitionRecordReturns the type of the field of a record defined by this record type definition at the given index into the list of fields.
getMemberType in interface TypeDefinitionRecordindex - 0-based index into the record type definition's fields.IndexOutOfBoundsException - The index is outside the acceptable
range for the list of fields of this record type definition.public final PropertyValue getValue(PropertyValue recordProperty, int index) throws NullPointerException, IllegalPropertyValueException, IndexOutOfBoundsException
TypeDefinitionRecordReturns 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.
getValue in interface TypeDefinitionRecordrecordProperty - 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.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.TypeDefinitionRecord.getValue(PropertyValue, String)public final PropertyValue getValue(PropertyValue recordProperty, String memberName) throws NullPointerException, IllegalPropertyValueException, IllegalArgumentException
TypeDefinitionRecordReturns 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.
getValue in interface TypeDefinitionRecordrecordProperty - Property value containing a record that is
to have a value returned.memberName - Name of the field value to retrieve.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.public final void setObject(PropertyValue recordProperty, Object data) throws NullPointerException, IllegalPropertyValueException, BadTypeException
TypeDefinitionRecordSets 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) with a record
property value created by this method may result in a different
object value.
setObject in interface TypeDefinitionRecordrecordProperty - 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.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.TypeDefinitionRecord.createValueFromObject(Object),
TypeDefinitionRecord.getObject(PropertyValue)public final void setValue(PropertyValue recordProperty, int index, PropertyValue memberProperty) throws NullPointerException, IllegalPropertyValueException, IndexOutOfBoundsException, BadTypeException
TypeDefinitionRecordSets 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.
setValue in interface TypeDefinitionRecordrecordProperty - 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.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.TypeDefinitionRecord.getValue(PropertyValue, int),
TypeDefinitionRecord.setValue(PropertyValue, String, PropertyValue)public final void setValue(PropertyValue recordProperty, String memberName, PropertyValue memberProperty) throws NullPointerException, IllegalPropertyValueException, IllegalArgumentException, BadTypeException
TypeDefinitionRecordSets 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.
setValue in interface TypeDefinitionRecordrecordProperty - 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.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.TypeDefinitionRecord.getValue(PropertyValue, String),
TypeDefinitionRecord.setValue(PropertyValue, int, PropertyValue)public final PropertyValue createValue(Object javaValue) throws ClassCastException
TypeDefinitionImplCreate 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.
createValue in interface TypeDefinitioncreateValue in class TypeDefinitionImpljavaValue - Java object to use to create a property value of this type.ClassCastException - The given object cannot be cast to a property value with
this type definition.public final PropertyValue createValueFromString(String content) throws ClassCastException
Create a record type value of this type from a string representation.
This method expects
the Java implementing class of the record type to implement a static method parseFactory(String)
that can create an instance of the represented type from a string. This value is then passed into
createValueFromObject(Object).
content - String representation of the record value.ClassCastException - It was not possible to parse the string a create a value of this record type.createValue(Object),
createValueFromObject(Object)public final TypeCategory getTypeCategory()
TypeDefinitionReturns the type category to which this type definition belongs, which
corresponds to its sub interface. For example, TypeCategory.Int
is returned for a TypeDefinitionInteger.
getTypeCategory in interface TypeDefinitiongetTypeCategory in class TypeDefinitionImplTypeCategorypublic PropertyValue createFromBytes(ByteBuffer buffer) throws NullPointerException, EndOfDataException
TypeDefinitionCreate a value of this type by reading the bytes in the given byte buffer. The buffer is assumed to have exactly the number of bytes that represent the value. For example, the length of a string value will be determined by the length (remaining bytes) in the buffer and not by reading a length value from the buffer.
This method is able to read values written by the
TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer) method.
createFromBytes in interface TypeDefinitioncreateFromBytes in class TypeDefinitionImplbuffer - Buffer to create a value from.NullPointerException - Cannot read values from a null buffer.EndOfDataException - Insufficient bytes remaining in the given buffer to create
a value of this type.TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer),
TypeDefinition.lengthAsBytes(PropertyValue)public long lengthAsBytes(PropertyValue value) throws NullPointerException, IllegalPropertyValueException
TypeDefinitionReturns the number of bytes that the given value of this type is serialized as a sequence of bytes.
The number returned by this method is the same as the number of bytes written
to a byte buffer by the TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer) method.
lengthAsBytes in interface TypeDefinitionlengthAsBytes in class TypeDefinitionImplvalue - Value to find the length of when serialized to bytes.NullPointerException - Cannot compute the serialized length of a null value.IllegalPropertyValueException - The given property value is not of this type.TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer),
TypeDefinition.createFromBytes(ByteBuffer)public List<PropertyValue> writeAsBytes(PropertyValue value, ByteBuffer buffer) throws NullPointerException, IllegalPropertyValueException, InsufficientSpaceException
TypeDefinitionWrite the given property value of this type to the given byte stream. This version is most appropriate for writing KLV streams (MXF files).
The format used to serialize the value with be compatible with the
TypeDefinition.createFromBytes(ByteBuffer) method. The number of bytes written to
the byte buffer will be the same as returned by TypeDefinition.lengthAsBytes(PropertyValue).
writeAsBytes in interface TypeDefinitionwriteAsBytes in class TypeDefinitionImplvalue - Value to write to the given buffer.buffer - Buffer to write the value to.NullPointerException - Cannot write from a null property value and/or
to a null value.IllegalPropertyValueException - The given property value is not of this type.InsufficientSpaceException - Insufficient space to write the given value into the
given buffer.TypeDefinition.writeAsStructuredStorageBytes(PropertyValue, ByteBuffer),
TypeDefinition.createFromBytes(ByteBuffer),
TypeDefinition.lengthAsBytes(PropertyValue)public List<PropertyValue> writeAsStructuredStorageBytes(PropertyValue value, ByteBuffer buffer) throws NullPointerException, IllegalPropertyValueException, InsufficientSpaceException
TypeDefinitionWrite the given property value of this type to the given byte stream that is to be written to a structured storage format file.
The number of bytes written to
the byte buffer will be the same as returned by TypeDefinition.lengthAsBytes(PropertyValue).
writeAsStructuredStorageBytes in interface TypeDefinitionwriteAsStructuredStorageBytes in class TypeDefinitionImplvalue - Value to write to the given buffer.buffer - Buffer to write the value to.NullPointerException - Cannot write from a null property value and/or
to a null value.IllegalPropertyValueException - The given property value is not of this type.InsufficientSpaceException - Insufficient space to write the given value into the
given buffer.TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer),
TypeDefinition.lengthAsBytes(PropertyValue)public void appendMetadictXML(Node metadict, String namespace, String prefix)
MetaDefinitionAppend an XML representation of this meta definition to the given XML node.
appendMetadictXML in interface MetaDefinitionappendMetadictXML in class MetaDefinitionImplmetadict - Meta dictionary node to append a description of this node to.CommonConstants.AAF_METADICT_NAMESPACEpublic TypeDefinitionRecord clone()
MetaDefinitionCreate a cloned copy of this meta definition.
clone in interface MetaDefinitionclone in interface TypeDefinitionclone in interface TypeDefinitionRecordclone in class TypeDefinitionImpl(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.