TypeDefinitionObjectReferenceImpl (Media Authoring with Java API)
Date: 2016-02-05

tv.amwa.maj.meta.impl

## Class TypeDefinitionObjectReferenceImpl

- java.lang.Object
- - tv.amwa.maj.meta.impl.MetaDefinitionImpl
  - - tv.amwa.maj.meta.impl.TypeDefinitionImpl
    - - tv.amwa.maj.meta.impl.SingletonTypeDefinitionImpl
      - - tv.amwa.maj.meta.impl.TypeDefinitionObjectReferenceImpl

- All Implemented Interfaces:
    Serializable, Cloneable, CommonConstants, MetadataObject, WeakReferenceTarget, XMLSerializable, MetaDefinition, TypeDefinition, TypeDefinitionObjectReference, DefinitionType
  Direct Known Subclasses:
    TypeDefinitionStrongObjectReferenceImpl, TypeDefinitionWeakObjectReferenceImpl

      @HiddenClass
      public abstract class TypeDefinitionObjectReferenceImpl
      extends SingletonTypeDefinitionImpl
      implements TypeDefinitionObjectReference, XMLSerializable, Serializable, Cloneable

  Implements the definition of a property type that defines an object relationship.

  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `TypeDefinitionObjectReferenceImpl.ObjectReferenceValue`
    `static class` | `TypeDefinitionObjectReferenceImpl.UnresolvedReferenceValue`

    - ### Nested classes/interfaces inherited from class tv.amwa.maj.meta.impl.SingletonTypeDefinitionImpl

      `SingletonTypeDefinitionImpl.SingletonMethodBag`

    - ### Nested classes/interfaces inherited from class tv.amwa.maj.meta.impl.TypeDefinitionImpl

      `TypeDefinitionImpl.PropertyValueImpl`

  - ### Field Summary

    - ### Fields inherited from interface tv.amwa.maj.constant.CommonConstants

      `AAF_METADICT_NAMESPACE, AAF_METADICT_PREFIX, AAF_XML_NAMESPACE, AAF_XML_PREFIX, ApplicationPluginObjectID, ApplicationPluginsID, MAX_NUM_RGBA_COMPS, MemberOfID, ObjectClassID, ParentClassID, PropertiesID, XMLClassIDAsAttributeName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TypeDefinitionObjectReferenceImpl()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TypeDefinitionObjectReference` | `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 object)` Create a property value from the given Java object.
    `static AUID` | `getLocalReference(PropertyValue value)`
    `Object` | `getObject(PropertyValue propertyValue)` Returns the object referenced by the given object reference property value.
    `ClassDefinition` | `getObjectType()` Returns the class definition representing the class of objects to which this object reference type definition can refer.
    `long` | `lengthAsBytes(PropertyValue value)` Returns the number of bytes that the given value of this type is serialized as a sequence of bytes.
    `void` | `setObject(PropertyValue propertyValue, Object object)` Sets the given object as the target of the given object reference property value.
    `List<PropertyValue>` | `writeAsBytes(PropertyValue value, ByteBuffer buffer)` Write the given property value of this type to the given byte stream.

    - ### Methods inherited from class tv.amwa.maj.meta.impl.SingletonTypeDefinitionImpl

      `setPropertyValue`

    - ### Methods inherited from class tv.amwa.maj.meta.impl.TypeDefinitionImpl

      `getNamespace, getPrefix, getPropertyValue, getTypeCategory, initalizeTypeNameMap, nameToAAFName, resolveReferences, writeAsStructuredStorageBytes`

    - ### Methods inherited from class tv.amwa.maj.meta.impl.MetaDefinitionImpl

      `aafNameToName, appendMetadictXML, appendXMLChildren, deepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getComment, getDescription, getIdentification, getName, getSymbol, getWeakTargetReference, hashCode, initializeMetaDefinitionIdentification, initializeMetaDefinitionName, setAAFNamesInUse, setAliases, setDescription, setIdentification, setName, setNamespace, setPrefix, setSymbol, toString`

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface tv.amwa.maj.meta.TypeDefinition

      `getPropertyValue, getTypeCategory, resolveReferences, setPropertyValue, writeAsStructuredStorageBytes`

    - ### Methods inherited from interface tv.amwa.maj.meta.MetaDefinition

      `appendMetadictXML, deepEquals, equals, getAAFNamesInUse, getAliases, getAUID, getDescription, getName, getNamespace, getPrefix, getSymbol, hashCode, setAAFNamesInUse, setDescription, setName, setNamespace, setPrefix, setSymbol, toString`

    - ### Methods inherited from interface tv.amwa.maj.industry.WeakReferenceTarget

      `getWeakTargetReference`

    - ### Methods inherited from interface tv.amwa.maj.io.xml.XMLSerializable

      `appendXMLChildren, getComment`

- - ### Constructor Detail

    - #### TypeDefinitionObjectReferenceImpl

          public TypeDefinitionObjectReferenceImpl()

  - ### Method Detail

    - #### createValue

          public PropertyValue createValue(Object object)
                                    throws ClassCastException

      Description copied from class: `TypeDefinitionImpl`

      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 interface `TypeDefinitionObjectReference`
      Specified by:
        `createValue` in class `TypeDefinitionImpl`
      Parameters:
        `object` - 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.
      See Also:
        `TypeDefinitionObjectReference.setObject(PropertyValue, Object)`

    - #### getObject

          public Object getObject(PropertyValue propertyValue)
                           throws NullPointerException,
                                  IllegalPropertyValueException

      Description copied from interface: `TypeDefinitionObjectReference`

      Returns the object referenced by the given object reference property value.

      Specified by:
        `getObject` in interface `TypeDefinitionObjectReference`
      Parameters:
        `propertyValue` - Property value form which the value is to be read.
      Throws:
        `NullPointerException` - The given property value containing a reference is `null`.
        `IllegalPropertyValueException` - The given property value is not defined by this object reference type.

    - #### getObjectType

          public ClassDefinition getObjectType()

      Description copied from interface: `TypeDefinitionObjectReference`

      Returns the class definition representing the class of objects to which this object reference type definition can refer. The returned definition is the least-derived type that it is permissible to represent, in other words the type definition can represent objects of the given class and any of its sub-classes.

      Specified by:
        `getObjectType` in interface `TypeDefinitionObjectReference`
      Returns:
        Class definition representing the class of objects to which property values of the object reference type can refer.

    - #### setObject

          public void setObject(PropertyValue propertyValue,
                                Object object)
                         throws NullPointerException,
                                IllegalPropertyValueException,
                                ClassCastException

      Description copied from interface: `TypeDefinitionObjectReference`

      Sets the given object as the target of the given object reference property value.

      Specified by:
        `setObject` in interface `TypeDefinitionObjectReference`
      Parameters:
        `propertyValue` - Property value containing the object reference to be set.
        `object` - Target of the object reference to set for the given property value.
      Throws:
        `NullPointerException` - Argument is null.
        `IllegalPropertyValueException` - The given property value is not defined by this object reference type.
        `ClassCastException` - The given object cannot be cast to one compatible with the permissible classes, as returned by `TypeDefinitionObjectReference.getObjectType()`.
      See Also:
        `TypeDefinitionObjectReference.createValue(Object)`

    - #### createFromBytes

          public PropertyValue createFromBytes(ByteBuffer buffer)
                                        throws NullPointerException,
                                               EndOfDataException

      Description copied from interface: `TypeDefinition`

      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 `TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer)` method.

      Specified by:
        `createFromBytes` in interface `TypeDefinition`
      Overrides:
        `createFromBytes` in class `TypeDefinitionImpl`
      Parameters:
        `buffer` - Buffer to create a value from.
      Returns:
        Value of this type created from the given byte array.
      Throws:
        `NullPointerException` - Cannot read values from a `null` buffer.
        `EndOfDataException` - Insufficient bytes remaining in the given buffer to create a value of this type.
      See Also:
        `TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer)`, `TypeDefinition.lengthAsBytes(PropertyValue)`

    - #### lengthAsBytes

          public long lengthAsBytes(PropertyValue value)
                             throws NullPointerException,
                                    IllegalPropertyValueException

      Description copied from interface: `TypeDefinition`

      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 `TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer)` method.

      Specified by:
        `lengthAsBytes` in interface `TypeDefinition`
      Overrides:
        `lengthAsBytes` in class `TypeDefinitionImpl`
      Parameters:
        `value` - Value to find the length of when serialized to bytes.
      Returns:
        Number of bytes used to represent the given value when serialized.
      Throws:
        `NullPointerException` - Cannot compute the serialized length of a `null` value.
        `IllegalPropertyValueException` - The given property value is not of this type.
      See Also:
        `TypeDefinition.writeAsBytes(PropertyValue, ByteBuffer)`, `TypeDefinition.createFromBytes(ByteBuffer)`

    - #### writeAsBytes

          public List<PropertyValue> writeAsBytes(PropertyValue value,
                                                  ByteBuffer buffer)
                                           throws NullPointerException,
                                                  IllegalPropertyValueException,
                                                  InsufficientSpaceException

      Description copied from interface: `TypeDefinition`

      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 `TypeDefinition.createFromBytes(ByteBuffer)` method. The number of bytes written to the byte buffer will be the same as returned by `TypeDefinition.lengthAsBytes(PropertyValue)`.

      Specified by:
        `writeAsBytes` in interface `TypeDefinition`
      Overrides:
        `writeAsBytes` in class `TypeDefinitionImpl`
      Parameters:
        `value` - Value to write to the given buffer.
        `buffer` - Buffer to write the value to.
      Returns:
        List of any strongly referenced property values referenced from the new structure of bytes. Elements of this list will require separate serialization to the stream if the reference if to be resolved.
      Throws:
        `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.
      See Also:
        `TypeDefinition.writeAsStructuredStorageBytes(PropertyValue, ByteBuffer)`, `TypeDefinition.createFromBytes(ByteBuffer)`, `TypeDefinition.lengthAsBytes(PropertyValue)`

    - #### getLocalReference

          public static final AUID getLocalReference(PropertyValue value)
                                              throws NullPointerException,
                                                     IllegalPropertyValueException

      Throws:
        `NullPointerException`
        `IllegalPropertyValueException`

    - #### clone

          public TypeDefinitionObjectReference clone()

      Description copied from interface: `MetaDefinition`

      Create a cloned copy of this meta definition.

      Specified by:
        `clone` in interface `MetaDefinition`
      Specified by:
        `clone` in interface `TypeDefinition`
      Specified by:
        `clone` in interface `TypeDefinitionObjectReference`
      Overrides:
        `clone` in class `TypeDefinitionImpl`
      Returns:
        Cloned copy of this meta definition.

(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.