|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TypeDefinitionRecord
Specifies the definition of a property type that consists of an ordered set of fields, where each field has a name and type.
A number of built-in record type definitions are supported in the MAJ API by interfaces specified in the record package. Record type definitions provide a mechanism for extending the range of data types supported in AAF. In the MAJ API, any interface that has a set and get method for each of the fields of a record can be used to represent a value of that type.
As an example, consider a person record type consisting of a first name, surname and age, the following record fields would be defined:
Using a call to createValueFromObject(Object)
, a record property value of person
type can be created from any class that implements the following Java interface:
public interface Person { public String getFirstName(); public void setFirstName(String firstName); public String getSurname(); public void setSurname(); public @UInt16 short getAge(); public void setAge(@UInt16 short age); }
Also, any class that implements the above interface can be instantiated with values
from a record property value by calling getObject(PropertyValue, Class)
.
makeTypeDefinitionRecord()
,
TypeCategory.Record
Method Summary | |
---|---|
PropertyValue |
createValueFromObject(Object initialData)
Creates and returns a new record property value that is initialized using the given Java object. |
PropertyValue |
createValueFromValues(PropertyValue[] fieldValues)
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. |
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. |
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. |
Object |
getObject(PropertyValue recordProperty,
Class<?> template)
Returns the fields from the given record property value as the current value of a new Java object. |
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 fieldName)
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. |
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 fieldProperty)
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 fieldName,
PropertyValue fieldProperty)
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 interface tv.amwa.maj.iface.TypeDefinition |
---|
createValue, getTypeCategory |
Methods inherited from interface tv.amwa.maj.iface.MetaDefinition |
---|
getAUID, getDescription, getName, setDescription, setName |
Method Detail |
---|
TypeDefinition getMemberType(@UInt32 int index) throws IndexOutOfBoundsException
Returns the type of the field of a record defined by this record type definition at the given index into the list of fields.
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.@AAFString String getMemberName(@UInt32 int index) throws IndexOutOfBoundsException
Returns the name of the field of a record defined by this record type definition at the given index into the list of fields.
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.PropertyValue createValueFromValues(PropertyValue[] fieldValues) throws NullPointerException, IllegalArgumentException, BadTypeException
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.
fieldValues
- 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 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.PropertyValue createValueFromObject(Object initialData) throws NullPointerException, IllegalPropertyValueException, BadTypeException
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 getObject(PropertyValue, Class)
with a record
property created by this method may result in a different
Java object value.
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()
,
createValueFromValues(PropertyValue[])
PropertyValue getValue(PropertyValue recordProperty, @UInt32 int index) throws NullPointerException, IllegalPropertyValueException, IndexOutOfBoundsException
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.
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.getValue(PropertyValue, String)
PropertyValue getValue(PropertyValue recordProperty, String fieldName) throws NullPointerException, IllegalPropertyValueException, IllegalArgumentException
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.
recordProperty
- Property value containing a record that is
to have a value returned.fieldName
- 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.Object getObject(PropertyValue recordProperty, Class<?> template) throws NullPointerException, BadTypeException, IllegalPropertyValueException
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 setObject(PropertyValue, Object)
will cause
an IllegalPropertyValueException
.
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.createValueFromObject(Object)
,
setObject(PropertyValue, Object)
void setValue(PropertyValue recordProperty, @UInt32 int index, PropertyValue fieldProperty) throws NullPointerException, IllegalPropertyValueException, IndexOutOfBoundsException, BadTypeException
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 getMemberType(int)
for the same index.
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.fieldProperty
- 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.getValue(PropertyValue, int)
,
setValue(PropertyValue, String, PropertyValue)
void setValue(PropertyValue recordProperty, String fieldName, PropertyValue fieldProperty) throws NullPointerException, IllegalPropertyValueException, IllegalArgumentException, BadTypeException
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.
recordProperty
- Property value containing a record that
is to have one of its fields set.fieldName
- Name of the field to set the value for within the given
record property value.fieldProperty
- 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.getValue(PropertyValue, String)
,
setValue(PropertyValue, int, PropertyValue)
void setObject(PropertyValue recordProperty, Object data) throws NullPointerException, IllegalPropertyValueException, BadTypeException
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 getObject(PropertyValue, Class)
with a record
property value created by this method may result in a different
object value.
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.createValueFromObject(Object)
,
getObject(PropertyValue, Class)
@UInt32 int getCount()
Returns the number of fields stored in a record defined by this record type definition.
|
Media Authoring with Java API |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |