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

tv.amwa.maj.io.mxf.impl

## Class PartitionImpl

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

- All Implemented Interfaces:
    Cloneable, Partition
  Direct Known Subclasses:
    EssencePartitionImpl, FooterPartitionImpl

      public abstract class PartitionImpl
      extends Object
      implements Partition, Cloneable

  Data relating to a single MXF partition.

- - ### Field Summary

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

      `SIZE_UNKNOWN`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PartitionImpl()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `Partition` | `clone()` Create a cloned copy of this partition.
    `long` | `getActualSize()` Returns the current size allocated for the partition, including any fill.
    `long` | `getInitialSize()` Returns the initial partition size given for this partition that is used to calculate the minimum allowed size for the partition.
    `abstract PartitionPack` | `getPartitionPack()` Returns the partition pack that describes this partition, including its size and what it contains.
    `boolean` | `hasEssenceContainer()` Determines whether this partition has an essence container, indicating the presence of (part of) a body stream.
    `boolean` | `hasHeaderMetadata()` Determines whether this partition contains header metadata.
    `boolean` | `hasIndexTable()` Determines whether this partition contains index table data.
    `static Partition` | `partitionFactory(MXFFileImpl mxfFile)`
    `HeaderMetadata` | `readHeaderMetadata()` Returns the header metadata contained within the partition, if any.
    `IndexTableSegment` | `readIndexTableSegment()` Reads the index table segment of this partition, if any is present.
    `void` | `setActualSize(long actualSize)`
    `void` | `setInitialDataSize(long initialSize)` Sets the initial partition size for this partition that is used to calculate the minimum allowed size for the partition.
    `abstract void` | `setPartitionPackPadding(long paddingFillSize)` Set the amount of padding to include after each significant entry in the partition, allowing space for the metadata to expand over time.
    `String` | `toString()`
    `void` | `updateSizes()` Update the size of partition based on the best information known at this time.
    `void` | `writeHeaderMetadata(Preface preface, long headerByteCount)` Write the header metadata of this partition using that provided in the given preface.
    `void` | `writeIndexTableSegment(IndexTableSegment indexTableSegment, long segmentLength)`
    `void` | `writePartitionPack()`
    `void` | `writeSingleIndexSegment(IndexTableSegment indexTableSegment)`

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

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PartitionImpl

          public PartitionImpl()

  - ### Method Detail

    - #### getPartitionPack

          public abstract PartitionPack getPartitionPack()

      Description copied from interface: `Partition`

      Returns the partition pack that describes this partition, including its size and what it contains.

      Specified by:
        `getPartitionPack` in interface `Partition`
      Returns:
        Partition pack that describes this partition.
      See Also:
        `HeaderPartition.getPartitionPack()`, `FooterPartition.getPartitionPack()`, `BodyPartition.getPartitionPack()`

    - #### setPartitionPackPadding

          public abstract void setPartitionPackPadding(long paddingFillSize)
                                                throws IllegalArgumentException

      Description copied from interface: `Partition`

      Set the amount of padding to include after each significant entry in the partition, allowing space for the metadata to expand over time.

      Specified by:
        `setPartitionPackPadding` in interface `Partition`
      Parameters:
        `paddingFillSize` - Size of padding to include after the partition.
      Throws:
        `IllegalArgumentException` - Cannot set the padding size to a negative value.
      See Also:
        `Padded.getPaddingFillSize()`, `Padded.setPaddingFillSize(long)`

    - #### hasHeaderMetadata

          public boolean hasHeaderMetadata()

      Description copied from interface: `Partition`

      Determines whether this partition contains header metadata. All header partitions must contain header metadata. Other partitions may contain header metadata.

      Specified by:
        `hasHeaderMetadata` in interface `Partition`
      Returns:
        Does this partition have header metadata?
      See Also:
        `Partition.readHeaderMetadata()`, `Partition.writeHeaderMetadata(Preface, long)`

    - #### hasIndexTable

          public boolean hasIndexTable()

      Description copied from interface: `Partition`

      Determines whether this partition contains index table data. The partition may contain a complete index table or just a segment of an index table stream.

      Specified by:
        `hasIndexTable` in interface `Partition`
      Returns:
        Does this partition have index table data?
      See Also:
        `Partition.readIndexTableSegment()`

    - #### hasEssenceContainer

          public boolean hasEssenceContainer()

      Description copied from interface: `Partition`

      Determines whether this partition has an essence container, indicating the presence of (part of) a body stream.

      Specified by:
        `hasEssenceContainer` in interface `Partition`
      Returns:
        Does this partition have an essence container?

    - #### clone

          public Partition clone()

      Description copied from interface: `Partition`

      Create a cloned copy of this partition.

      Specified by:
        `clone` in interface `Partition`
      Overrides:
        `clone` in class `Object`
      Returns:
        Cloned copy of this partition.

    - #### readHeaderMetadata

          public HeaderMetadata readHeaderMetadata()
                                            throws NullPointerException

      Description copied from interface: `Partition`

      Returns the header metadata contained within the partition, if any.

      Specified by:
        `readHeaderMetadata` in interface `Partition`
      Returns:
        Header metadata of this partition, or `null` if no header metadata is present.
      Throws:
        `NullPointerException` - The partition's MXF file is `null` which may occur if this partition is being created unattached.
      See Also:
        `Partition.hasHeaderMetadata()`, `Partition.writeHeaderMetadata(Preface, long)`

    - #### writeHeaderMetadata

          public void writeHeaderMetadata(Preface preface,
                                          long headerByteCount)
                                   throws NullPointerException,
                                          InsufficientSpaceException,
                                          IOException

      Description copied from interface: `Partition`

      Write the header metadata of this partition using that provided in the given preface. Previous header metadata will be overwritten. Note that sufficient space must be available.

      Specified by:
        `writeHeaderMetadata` in interface `Partition`
        `headerByteCount` - Number of bytes the encoded header should fit within, including filler.
      Throws:
        `NullPointerException` - Cannot associate `null` header metadata with this partition.
        `InsufficientSpaceException` - Calculations based on partition sizes shows that insufficient space is available to write this header metadata.
        `IOException` - Problem occurred writing to the filesystem.
      See Also:
        `Partition.readHeaderMetadata()`, `Partition.hasHeaderMetadata()`, `#calculateMinimumHeaderMetadataSize(Preface)`

    - #### writeIndexTableSegment

          public void writeIndexTableSegment(IndexTableSegment indexTableSegment,
                                             long segmentLength)
                                      throws NullPointerException,
                                             InsufficientSpaceException,
                                             IOException

      Specified by:
        `writeIndexTableSegment` in interface `Partition`
      Throws:
        `NullPointerException`
        `InsufficientSpaceException`
        `IOException`

    - #### writeSingleIndexSegment

          public void writeSingleIndexSegment(IndexTableSegment indexTableSegment)
                                       throws NullPointerException,
                                              InsufficientSpaceException,
                                              IOException

      Specified by:
        `writeSingleIndexSegment` in interface `Partition`
      Throws:
        `NullPointerException`
        `InsufficientSpaceException`
        `IOException`

    - #### writePartitionPack

          public void writePartitionPack()
                                  throws NullPointerException,
                                         InsufficientSpaceException,
                                         IOException

      Throws:
        `NullPointerException`
        `InsufficientSpaceException`
        `IOException`

    - #### readIndexTableSegment

          public IndexTableSegment readIndexTableSegment()
                                                  throws NullPointerException

      Description copied from interface: `Partition`

      Reads the index table segment of this partition, if any is present.

      Specified by:
        `readIndexTableSegment` in interface `Partition`
      Returns:
        The index data segment of this partition, or `null` if no index data is present.
      Throws:
        `NullPointerException` - The partition's MXF file is `null` which may occur if this partition is being created unattached.
      See Also:
        `Partition.hasIndexTable()`

    - #### getInitialSize

          public long getInitialSize()

      Description copied from interface: `Partition`

      Returns the initial partition size given for this partition that is used to calculate the minimum allowed size for the partition. Note that this value does not necessarily reflect the actual size of the partition.

      Specified by:
        `getInitialSize` in interface `Partition`
      Returns:
        Initial partition size.
      See Also:
        `Partition.SIZE_UNKNOWN`, `Partition.getActualSize()`

    - #### setInitialDataSize

          public void setInitialDataSize(long initialSize)

      Description copied from interface: `Partition`

      Sets the initial partition size for this partition that is used to calculate the minimum allowed size for the partition. Use a value of `Partition.SIZE_UNKNOWN` to get MAJ to calculate the size. Note that the implementation will expand the size of the partition beyond the minimum given with this method if required. The size is specified excluding the size of the partition pack.

      Specified by:
        `setInitialDataSize` in interface `Partition`
      Parameters:
        `initialSize` - Initial partition size.
      See Also:
        `Partition.SIZE_UNKNOWN`, `Partition.getActualSize()`

    - #### getActualSize

          public long getActualSize()

      Description copied from interface: `Partition`

      Returns the current size allocated for the partition, including any fill. This size may be updated during writing.

      Specified by:
        `getActualSize` in interface `Partition`
      Returns:
        Current size allocated for the partition.
      See Also:
        `Partition.getInitialSize()`

    - #### setActualSize

          public void setActualSize(long actualSize)

    - #### updateSizes

          public void updateSizes()

      Description copied from interface: `Partition`

      Update the size of partition based on the best information known at this time.

      Specified by:
        `updateSizes` in interface `Partition`
      See Also:
        `MXFFile.updatePackSizes()`

    - #### partitionFactory

          public static final Partition partitionFactory(MXFFileImpl mxfFile)
                                                  throws EndOfDataException

      Throws:
        `EndOfDataException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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