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

tv.amwa.maj.io.mxf.impl

## Class RandomIndexPackImpl

- java.lang.Object
- - tv.amwa.maj.io.mxf.impl.RandomIndexPackImpl

- All Implemented Interfaces:
    Serializable, Cloneable, MetadataObject, MXFUnit, RandomIndexPack

      @MediaClass(uuid1=218169857,
                  uuid2=273,
                  uuid3=256,
                  uuid4={6,14,43,52,2,5,1,1},
                  definedName="RandomIndexPack",
                  description="A device to help find partitions scattered throughout an MXF file.",
                  namespace="http://www.smpte-ra.org/rp210",
                  prefix="mxf",
                  symbol="RandomIndexPack")
      public class RandomIndexPackImpl
      extends Object
      implements MetadataObject, Serializable, Cloneable, RandomIndexPack

  Random index pack data for an MXF file.

  See Also:
    `PartitionImpl`, `PartitionInformation`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface tv.amwa.maj.io.mxf.RandomIndexPack

      `ripKeyValue`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RandomIndexPackImpl()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRandomIndexItem(int bodySID, long byteOffset)` Add a random index item to this pack by its body stream identifier and byte offset.
    `void` | `addRandomIndexItem(RandomIndexItem randomPartitionItem)` Add an existing random index item to this pack.
    `void` | `clear()` Clears the partition table within this random index pack.
    `RandomIndexPack` | `clone()` Creates a cloned copy of this random index pack.
    `int` | `count()` Returns the number of partitions indexed by this random index pack.
    `static RandomIndexPack` | `createFromBytes(ByteBuffer ripBytes)`
    `boolean` | `equals(Object o)`
    `int` | `getLength()` Returns the overall length of the random index pack when encoded as bytes, including the key and BER length.
    `RandomIndexItem[]` | `getPartitionIndex()` Returns the array random index items of this random index pack.
    `UnitType` | `getUnitType()`
    `int` | `hashCode()`
    `static int` | `initializeLength()`
    `static RandomIndexItem[]` | `initializePartitionIndex()`
    `long[]` | `lookupPartitionOffsets(int bodySID)` Returns an ordered list of the byte offsets for partitions containing the given body stream identifier.
    `void` | `setLength(int length)`
    `void` | `setPartitionIndex(RandomIndexItem[] partitionIndex)` Sets the array of random index items of this random index pack.
    `String` | `toString()`
    `int` | `writeAsBytes(ByteBuffer buffer)` Serializes this random index pack into its file-based KLV-encoded version in the given buffer.

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

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

- - ### Constructor Detail

    - #### RandomIndexPackImpl

          public RandomIndexPackImpl()

  - ### Method Detail

    - #### getPartitionIndex

          @MediaProperty(uuid1=251658240,
                         uuid2=0,
                         uuid3=115,
                         uuid4={6,14,43,52,0,0,0,0},
                         definedName="PartitionIndex",
                         typeName="RandomIndexItemArray",
                         optional=false,
                         uniqueIdentifier=false,
                         symbol="PartitionIndex")
          public RandomIndexItem[] getPartitionIndex()

      Description copied from interface: `RandomIndexPack`

      Returns the array random index items of this random index pack. Each partition of the MXF file indexed should have an entry in this array. The array is ordered by the byte offset of the partition.

      Specified by:
        `getPartitionIndex` in interface `RandomIndexPack`
      Returns:
        Array of random index items of this random index pack.
      See Also:
        `PartitionPack.getThisPartition()`, `TypeDefinitions.RandomIndexItem`, `TypeDefinitions.RandomIndexItemArray`

    - #### setPartitionIndex

          @MediaPropertySetter(value="PartitionIndex")
          public void setPartitionIndex(RandomIndexItem[] partitionIndex)
                                                                              throws NullPointerException

      Description copied from interface: `RandomIndexPack`

      Sets the array of random index items of this random index pack. Each partition of the MXF file indexed should have an entry in this array. The items will be sorted into byte offset order.

      Specified by:
        `setPartitionIndex` in interface `RandomIndexPack`
      Parameters:
        `partitionIndex` - Array of random index items of this random index pack.
      Throws:
        `NullPointerException` - Cannot set the partition index with a `null` array.

    - #### lookupPartitionOffsets

          @UInt64Array
          public long[] lookupPartitionOffsets(@UInt32
                                                            int bodySID)

      Description copied from interface: `RandomIndexPack`

      Returns an ordered list of the byte offsets for partitions containing the given body stream identifier. The order of the partitions is the play order of the essence contained in the essence streams.

      Specified by:
        `lookupPartitionOffsets` in interface `RandomIndexPack`
      Parameters:
        `bodySID` - Body stream identifier to query the partition offsets for.
      Returns:
        List of byte offsets to partitions containing part of the given body SID.

    - #### count

          @MediaPropertyCount(value="PartitionIndex")
          public int count()

      Description copied from interface: `RandomIndexPack`

      Returns the number of partitions indexed by this random index pack.

      Specified by:
        `count` in interface `RandomIndexPack`
      Returns:
        Number of partitions indexed by this random index pack.

    - #### clear

          @MediaPropertyClear(value="PartitionIndex")
          public void clear()

      Description copied from interface: `RandomIndexPack`

      Clears the partition table within this random index pack.

      Specified by:
        `clear` in interface `RandomIndexPack`

    - #### addRandomIndexItem

          public void addRandomIndexItem(@UInt32
                                         int bodySID,
                                         @UInt64
                                         long byteOffset)
                                  throws IllegalArgumentException

      Description copied from interface: `RandomIndexPack`

      Add a random index item to this pack by its body stream identifier and byte offset. A random index item describes the location of a partition and which body stream it contains data for.

      Specified by:
        `addRandomIndexItem` in interface `RandomIndexPack`
      Parameters:
        `bodySID` - Body stream identifier of the partition.
        `byteOffset` - Byte offset of the partition in the file, measured from the beginning of the header partition.
      Throws:
        `IllegalArgumentException` - Cannot set the body stream identifier or the byte offset to a negative value.
      See Also:
        `RandomIndexPack.addRandomIndexItem(RandomIndexItem)`, `PartitionPack.getThisPartition()`, `PartitionPack.getBodySID()`

    - #### addRandomIndexItem

          public void addRandomIndexItem(RandomIndexItem randomPartitionItem)
                                  throws NullPointerException

      Description copied from interface: `RandomIndexPack`

      Add an existing random index item to this pack. A random index item describes the location of a partition and which body stream it contains data for.

      Specified by:
        `addRandomIndexItem` in interface `RandomIndexPack`
      Parameters:
        `randomPartitionItem` - Item to add to this pack.
      Throws:
        `NullPointerException` - Cannot add a `null` index item.
      See Also:
        `RandomIndexPack.addRandomIndexItem(int, long)`

    - #### getLength

          @MediaProperty(uuid1=67506177,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,4},
                         definedName="Length",
                         typeName="UInt32",
                         uniqueIdentifier=false,
                         optional=false,
                         symbol="Length")
           @UInt32
          public int getLength()

      Description copied from interface: `RandomIndexPack`

      Returns the overall length of the random index pack when encoded as bytes, including the key and BER length.

      Specified by:
        `getLength` in interface `RandomIndexPack`
      Returns:
        Overall length of the random index pack when encoded as bytes, including the key and BER length.
      See Also:
        `RandomIndexPack.writeAsBytes(ByteBuffer)`

    - #### setLength

          @MediaPropertySetter(value="Length")
          public void setLength(@UInt32
                                                                     int length)
                                                              throws IllegalArgumentException

      Throws:
        `IllegalArgumentException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### clone

          public RandomIndexPack clone()

      Description copied from interface: `RandomIndexPack`

      Creates a cloned copy of this random index pack.

      Specified by:
        `clone` in interface `RandomIndexPack`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this random index pack.

    - #### writeAsBytes

          public int writeAsBytes(ByteBuffer buffer)
                           throws NullPointerException,
                                  InsufficientSpaceException

      Description copied from interface: `RandomIndexPack`

      Serializes this random index pack into its file-based KLV-encoded version in the given buffer. The buffer must have at least `RandomIndexPack.getLength()` bytes remaining.

      Specified by:
        `writeAsBytes` in interface `RandomIndexPack`
      Parameters:
        `buffer` - Buffer to write this random index pack into.
      Returns:
        Number of bytes written.
      Throws:
        `NullPointerException` - Cannot write this random index pack to a null buffer.
        `InsufficientSpaceException` - The given buffer does not have sufficient space remaining.
      See Also:
        `RandomIndexPack.getLength()`

    - #### getUnitType

          public UnitType getUnitType()

      Specified by:
        `getUnitType` in interface `MXFUnit`

    - #### createFromBytes

          public static RandomIndexPack createFromBytes(ByteBuffer ripBytes)
                                                 throws BufferUnderflowException

      Throws:
        `BufferUnderflowException`

    - #### initializeLength

          public static final int initializeLength()

    - #### initializePartitionIndex

          public static final RandomIndexItem[] initializePartitionIndex()

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