|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object tv.amwa.maj.meta.MetaDefinition tv.amwa.maj.meta.TypeDefinition tv.amwa.maj.meta.TypeDefinitionRecord
@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
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.
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 |
---|
public static final TypeDefinitionRecord Rational
public static final TypeDefinitionRecord AUID
public static final TypeDefinitionRecord MobIDType
public static final TypeDefinitionRecord ProductVersion
public static final TypeDefinitionRecord VersionType
public static final TypeDefinitionRecord VersionNumber
public static final TypeDefinitionRecord RGBAComponent
public static final TypeDefinitionRecord DateStruct
public static final TypeDefinitionRecord TimeStruct
public static final TypeDefinitionRecord TimeStamp
Constructor Detail |
---|
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:
TypeDefinitionInteger
TypeDefinitionRecord
TypeDefinitionEnumeration
TypeDefinitionExtendibleEnumeration
TypeDefinitionFixedArray
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.
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.
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.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.
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.
NullPointerException
- One or more of the arguments is null.
IndexOutOfBoundsException
- The arrays are of different lengths.TypeDefinitionRecord(tv.amwa.maj.record.AUID, String, String[], Map)
Method Detail |
---|
public final void setPropertiesFromInterface(TypeDefinitionRecord castFrom)
MetaDefinition.setPropertiesFromInterface(tv.amwa.maj.iface.MetaDefinition)
@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()
@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()
public final PropertyValue createValueFromObject(Object initialData) throws NullPointerException, IllegalPropertyValueException, BadTypeException
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.
createValueFromObject
in interface TypeDefinitionRecord
initialData
- Object to use to set the values of the a new
record property value.
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.Class.getFields()
,
Class.getMethods()
,
TypeDefinitionRecord.createValueFromValues(PropertyValue[])
public final PropertyValue createValueFromValues(PropertyValue[] memberValues) throws NullPointerException, IllegalArgumentException, BadTypeException
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.
createValueFromValues
in interface TypeDefinitionRecord
memberValues
- 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()
TypeDefinitionRecord
Returns the number of fields stored in a record defined by this record type definition.
getCount
in interface TypeDefinitionRecord
public final Object getObject(PropertyValue recordProperty, Class<?> template) throws NullPointerException, BadTypeException, IllegalPropertyValueException
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
.
getObject
in interface TypeDefinitionRecord
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.
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)
public final String getMemberName(int index) throws IndexOutOfBoundsException
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.
getMemberName
in interface TypeDefinitionRecord
index
- 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
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.
getMemberType
in interface TypeDefinitionRecord
index
- 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
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.
getValue
in interface TypeDefinitionRecord
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.
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
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.
getValue
in interface TypeDefinitionRecord
recordProperty
- 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
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.
setObject
in interface TypeDefinitionRecord
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.
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, Class)
public final void setValue(PropertyValue recordProperty, int index, PropertyValue memberProperty) throws NullPointerException, IllegalPropertyValueException, IndexOutOfBoundsException, BadTypeException
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.
setValue
in interface TypeDefinitionRecord
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.
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
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.
setValue
in interface TypeDefinitionRecord
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.
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
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.
createValue
in interface TypeDefinition
createValue
in class TypeDefinition
javaValue
- 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 TypeCategory getTypeCategory()
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
.
getTypeCategory
in interface TypeDefinition
getTypeCategory
in class TypeDefinition
TypeCategory
public final boolean deepEquals(Object o)
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.
deepEquals
in class MetaDefinition
o
- Object to compare to this definition.
public final void appendXMLChildren(Node parent)
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.
appendXMLChildren
in interface XMLSerializable
appendXMLChildren
in class MetaDefinition
parent
- XML parent element to append child nodes to.public final boolean resolveTheUnresolved(Map<AUID,MetaDefinition> localTypes)
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.
localTypes
- Unregistered type definitions to resolve references against.
|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |