public interface TypeDefinition extends MetaDefinition
Specifies the definition of a property type.
The methods of type definitions allow property values of the given type to be manipulated. The interfaces provided in the MAJ API allow property values to be converted to and from equivalent Java types. Taking the character type definition as an example:
createValueFromChar(char)
converts a value of the Java char primitive type into a new AAF property value with type definition TypeDefinitionCharacter. The createValue(Object)
method will do the same for a Character value.char getCharacter(PropertyValue) method
retrieves a value of Java char primitive type from an AAF property value of the correct type.
setCharacter(PropertyValue, char)
method sets an existing character type AAF property value to the given value of the
Java char primitive type.All other data types have similar methods.
PropertyDefinition.getTypeDefinition(),
PropertyValue.getType(),
Parameter.getTypeDefinition(),
Warehouse.lookForType(String),
Warehouse.lookForType(AUID),
TypeDefinitions.TypeDefinitionWeakReference,
TypeDefinitions.TypeDefinitionWeakReferenceVector,
TypeDefinitions.TypeDefinitionStrongReference,
TypeDefinitions.TypeDefinitionStrongReferenceSet| Modifier and Type | Method and Description |
|---|---|
TypeDefinition |
clone()
Create a cloned copy of this type 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 of this type from the
given Java value.
|
PropertyValue |
getPropertyValue(MetadataObject metadataObject,
PropertyDefinition property)
Get the specified property's value from the given object.
|
TypeCategory |
getTypeCategory()
Returns the type category to which this type definition belongs, which
corresponds to its sub interface.
|
long |
lengthAsBytes(PropertyValue value)
Returns the number of bytes that the given value of this type is serialized as a
sequence of bytes.
|
boolean |
resolveReferences(PropertyValue value,
Map<AUID,MetadataObject> referenceMap)
Resolve any unresolved object references using the given reference map.
|
void |
setPropertyValue(MetadataObject metadataObject,
PropertyDefinition property,
PropertyValue value)
On the given metadata object, set the specified property to the given 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.
|
appendMetadictXML, deepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getDescription, getName, getNamespace, getPrefix, getSymbol, hashCode, setAAFNamesInUse, setDescription, setName, setNamespace, setPrefix, setSymbol, toStringgetWeakTargetReferenceTypeCategory getTypeCategory()
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.
TypeCategoryPropertyValue createValue(Object javaValue) throws ClassCastException
Create a property value of this type from the given Java value. Each kind of type definition will do its best to convert the given value to a property value of its type.
javaValue - Java value to use to create a new property value from.ClassCastException - The given java value could not be cast to a
property value of this type.PropertyValue createFromBytes(ByteBuffer buffer) throws NullPointerException, EndOfDataException
Create 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
writeAsBytes(PropertyValue, ByteBuffer) method.
buffer - 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.writeAsBytes(PropertyValue, ByteBuffer),
lengthAsBytes(PropertyValue)List<PropertyValue> writeAsBytes(PropertyValue value, ByteBuffer buffer) throws NullPointerException, IllegalPropertyValueException, InsufficientSpaceException
Write 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
createFromBytes(ByteBuffer) method. The number of bytes written to
the byte buffer will be the same as returned by lengthAsBytes(PropertyValue).
value - 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.writeAsStructuredStorageBytes(PropertyValue, ByteBuffer),
createFromBytes(ByteBuffer),
lengthAsBytes(PropertyValue)List<PropertyValue> writeAsStructuredStorageBytes(PropertyValue value, ByteBuffer buffer) throws NullPointerException, IllegalPropertyValueException, InsufficientSpaceException
Write 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 lengthAsBytes(PropertyValue).
value - 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.writeAsBytes(PropertyValue, ByteBuffer),
lengthAsBytes(PropertyValue)long lengthAsBytes(PropertyValue value) throws NullPointerException, IllegalPropertyValueException
Returns 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 writeAsBytes(PropertyValue, ByteBuffer) method.
value - 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.writeAsBytes(PropertyValue, ByteBuffer),
createFromBytes(ByteBuffer)boolean resolveReferences(PropertyValue value, Map<AUID,MetadataObject> referenceMap) throws NullPointerException, IllegalPropertyValueException
Resolve any unresolved object references using the given reference map. Unresolved object references occur when a value has been read from a file but not linked to its strong or weak values. This method only effects types that are references or contain references in collections, which are:
TypeDefinitionWeakObjectReference;TypeDefinitionStrongObjectReference;TypeDefinitionVariableArray with elements of one of the object reference types;TypeDefinitionSet with elements of one of the object reference types.value - Value to resolve references for.referenceMap - Map of local identifications to values to be used for resolution.NullPointerException - The value or reference map is/are null.IllegalPropertyValueException - The given property value is not of this type.void setPropertyValue(MetadataObject metadataObject, PropertyDefinition property, PropertyValue value) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
On the given metadata object, set the specified property to the given value. The property must be of this type.
metadataObject - Object to set the value on.property - Property of the object to set.value - Value of this type to set the property value to.IllegalArgumentException - The given property value is not of this type.IllegalAccessException - Insufficient privileges to set properties on the given
metadata object.InvocationTargetException - Problem encountered while calling the set method
associated with the property for the given object.getPropertyValue(MetadataObject, PropertyDefinition)PropertyValue getPropertyValue(MetadataObject metadataObject, PropertyDefinition property) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
Get the specified property's value from the given object. The property must be of this type.
metadataObject - Object to retrieve the property value from.property - Property of this type to extract the value for.IllegalArgumentException - The given property value is not of this type.IllegalAccessException - Insufficient privileges to get properties on the given
metadata object.InvocationTargetException - Problem encountered while calling the get method
associated with the property for the given object.setPropertyValue(MetadataObject, PropertyDefinition, PropertyValue)TypeDefinition clone()
Create a cloned copy of this type definition.
clone in interface MetaDefinition(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.