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

tv.amwa.maj.model.impl

## Class RIFFChunkImpl

- java.lang.Object
- - tv.amwa.maj.model.impl.InterchangeObjectImpl
  - - tv.amwa.maj.model.impl.RIFFChunkImpl

- All Implemented Interfaces:
    Serializable, Cloneable, MediaEntity, MetadataObject, XMLSerializable, InterchangeObject, RIFFChunk

      @MediaClass(uuid1=218169601,
                  uuid2=257,
                  uuid3=20224,
                  uuid4={6,14,43,52,2,6,1,1},
                  definedName="RIFFChunk",
                  description="Chunk of data as defined by the Resource Interchange File Format (RIFF).",
                  symbol="RIFFChunk")
      public class RIFFChunkImpl
      extends InterchangeObjectImpl
      implements RIFFChunk, Serializable, XMLSerializable, Cloneable

  Implements the representation of a chunk of resource interchange file format (RIFF) data, identified by a 4-byte tag and variable size field.

  See Also:
    `TypeDefinitions.RIFFChunkStrongReference`, `TypeDefinitions.RIFFChunkStrongReferenceVector`, Serialized Form

- - ### Field Summary

    - ### Fields inherited from class tv.amwa.maj.model.impl.InterchangeObjectImpl

      `ObjectClassPropertyID`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RIFFChunkImpl()`
    `RIFFChunkImpl(int chunkID)` Creates and initializes a new RIFF data chunk with the given chunk identifier.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RIFFChunk` | `clone()` Create a cloned copy of this interchange object.
    `Stream` | `getChunkData()` Returns the complete data of this RIFF chunk.
    `int` | `getChunkID()` Returns the chunk id of this RIFF chunk, which is a 4-byte tag that identifies this tag.
    `String` | `getComment()` Include a comment when serializing a value to XML.
    `int` | `getLength()` Returns the total size of this RIFF chunk measured in bytes.
    `long` | `getPosition()` Returns the current position for reading or writing the RIFF chunk data.
    `static Stream` | `initializeChunkData()`
    `static int` | `initializeChunkID()`
    `static long` | `initializeChunkLength()`
    `ByteBuffer` | `read(int numberOfBytes)` Read the requested number of bytes from the RIFF chunk at the current position.
    `void` | `setChunkData(Stream chunkData)` Sets the complete data of this RIFF chunk and initializes the position to zero.
    `void` | `setChunkID(int chunkID)` Sets the chunk id of this RIFF chunk, which is a 4-byte tag that identifies this tag.
    `void` | `setChunkLength(long chunkLength)`
    `void` | `setPosition(long offset)` Sets the position for reading or writing this RIFF chunk data.
    `void` | `write(ByteBuffer bytes)` Writes the given bytes to this RIFF chunk data at the current position.

    - ### Methods inherited from class tv.amwa.maj.model.impl.InterchangeObjectImpl

      `addApplicationPlugin, appendXMLChildren, clearApplicationPlugins, containsApplicationPlugin, containsApplicationPlugin, countApplicationPlugins, deepEquals, disableGenerationTracking, enableGenerationTracking, equals, getApplicationPlugins, getGeneration, getLinkedGenerationID, getLinkedGenerationIDString, getObjectClass, getPersistentID, getPersistentIndex, hashCode, isGenerationTracked, removeApplicationPlugin, removeApplicationPlugin, setLinkedGenerationID, setLinkedGenerationIDString, setObjectClass, setPersistentID, setPersistentIndex, toString`

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

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

    - ### Methods inherited from interface tv.amwa.maj.model.InterchangeObject

      `addApplicationPlugin, clearApplicationPlugins, containsApplicationPlugin, containsApplicationPlugin, countApplicationPlugins, deepEquals, disableGenerationTracking, enableGenerationTracking, equals, getApplicationPlugins, getGeneration, getLinkedGenerationID, getObjectClass, isGenerationTracked, removeApplicationPlugin, removeApplicationPlugin, setLinkedGenerationID, setObjectClass, toString`

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

      `getPersistentID, setPersistentIndex`

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

      `appendXMLChildren`

- - ### Constructor Detail

    - #### RIFFChunkImpl

          public RIFFChunkImpl()

    - #### RIFFChunkImpl

          public RIFFChunkImpl(@UInt32
                               int chunkID)

      Creates and initializes a new RIFF data chunk with the given chunk identifier. The identifier is used to represent 4 ASCII characters that represent the kind of data stored inside the chunk.

      Parameters:
        `chunkID` - Identifier for the new chunk.

  - ### Method Detail

    - #### getChunkData

          @MediaProperty(uuid1=67568640,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,8},
                         definedName="ChunkData",
                         typeName="Stream",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=20227,
                         symbol="ChunkData")
          public Stream getChunkData()

      Description copied from interface: `RIFFChunk`

      Returns the complete data of this RIFF chunk.

      Specified by:
        `getChunkData` in interface `RIFFChunk`
      Returns:
        Actual data of this RIFF chunk.

    - #### setChunkData

          @MediaPropertySetter(value="ChunkData")
          public void setChunkData(Stream chunkData)
                                                                    throws NullPointerException

      Description copied from interface: `RIFFChunk`

      Sets the complete data of this RIFF chunk and initializes the position to zero. The length property of this RIFF chunk will be set to the length of the given chunk data.

      Specified by:
        `setChunkData` in interface `RIFFChunk`
      Parameters:
        `chunkData` - Actual data for this RIFF chunk.
      Throws:
        `NullPointerException` - The chunk data argument is `null.`

    - #### initializeChunkData

          public static final Stream initializeChunkData()

    - #### getChunkID

          @MediaProperty(uuid1=67504130,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,8},
                         definedName="ChunkID",
                         typeName="UInt32",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=20225,
                         symbol="ChunkID")
          public int getChunkID()

      Description copied from interface: `RIFFChunk`

      Returns the chunk id of this RIFF chunk, which is a 4-byte tag that identifies this tag.

      Note that in the representation of this tag, care needs to be taken to ensure that the sign bit is not confused with an 8-bit character code. Negative values are accepted by this method.

      Specified by:
        `getChunkID` in interface `RIFFChunk`
      Returns:
        Chunk identifier for this RIFF chunk.

    - #### setChunkID

          @MediaPropertySetter(value="ChunkID")
          public void setChunkID(int chunkID)

      Description copied from interface: `RIFFChunk`

      Sets the chunk id of this RIFF chunk, which is a 4-byte tag that identifies this tag.

      Note that in the representation of this tag, care needs to be taken to ensure that the sign bit is not confused with an 8-bit character code. Negative values are accepted by this method.

      Specified by:
        `setChunkID` in interface `RIFFChunk`
      Parameters:
        `chunkID` - Chunk identifier for this RIFF chunk.

    - #### initializeChunkID

          public static final int initializeChunkID()

    - #### getLength

          @MediaProperty(uuid1=67504387,
                         uuid2=0,
                         uuid3=0,
                         uuid4={6,14,43,52,1,1,1,8},
                         definedName="ChunkLength",
                         typeName="UInt32",
                         optional=false,
                         uniqueIdentifier=false,
                         pid=20226,
                         symbol="ChunkLength")
          public int getLength()

      Description copied from interface: `RIFFChunk`

      Returns the total size of this RIFF chunk measured in bytes. The length is initially 0 until `RIFFChunk.setChunkData(Stream)` has been called.

      Specified by:
        `getLength` in interface `RIFFChunk`
      Returns:
        Total size size of this RIFF chunk measured in bytes.

    - #### setChunkLength

          @MediaPropertySetter(value="ChunkLength")
          public void setChunkLength(long chunkLength)
                                                                        throws IllegalArgumentException

      Throws:
        `IllegalArgumentException`

    - #### initializeChunkLength

          public static final long initializeChunkLength()

    - #### getPosition

          public long getPosition()
                           throws IOException

      Description copied from interface: `RIFFChunk`

      Returns the current position for reading or writing the RIFF chunk data.

      Specified by:
        `getPosition` in interface `RIFFChunk`
      Returns:
        Current position for reading or writing the RIFF chunk data.
      Throws:
        `IOException` - Error occurred when trying to set the position for the underlying stream.

    - #### setPosition

          public void setPosition(long offset)
                           throws PositionOutOfRangeException,
                                  IOException

      Description copied from interface: `RIFFChunk`

      Sets the position for reading or writing this RIFF chunk data.

      Specified by:
        `setPosition` in interface `RIFFChunk`
      Parameters:
        `offset` - Position offset to set for reading or writing RIFF chunk data.
      Throws:
        `PositionOutOfRangeException` - The given offset is outside the acceptable range for this RIFF chunk data, which is between 0 and the length of the data.
        `IOException` - Error occurred when trying to set the position for the underlying stream.
      See Also:
        `RIFFChunk.getLength()`

    - #### read

          public ByteBuffer read(int numberOfBytes)
                          throws IllegalArgumentException,
                                 EndOfDataException,
                                 IOException

      Description copied from interface: `RIFFChunk`

      Read the requested number of bytes from the RIFF chunk at the current position. The position is advanced by the number of bytes read.

      Specified by:
        `read` in interface `RIFFChunk`
      Parameters:
        `numberOfBytes` - Number of bytes to read from the RIFF chunk.
      Returns:
        Bytes read from the RIFF chunk at the current position.
      Throws:
        `IllegalArgumentException` - Cannot read a negative number of bytes.
        `EndOfDataException` - The number of bytes requested are not available in the RIFF chunk relative to the current position.
        `IOException` - Error occurred when trying to read from the underlying stream.
      See Also:
        `RIFFChunk.getPosition()`

    - #### write

          public void write(ByteBuffer bytes)
                     throws NullPointerException,
                            EndOfDataException,
                            IOException

      Description copied from interface: `RIFFChunk`

      Writes the given bytes to this RIFF chunk data at the current position. The position is advanced by the number of bytes written. Any data beyond the new position is lost by truncating the buffer.

      Specified by:
        `write` in interface `RIFFChunk`
      Parameters:
        `bytes` - Bytes to write to the RIFF chunk data.
      Throws:
        `NullPointerException` - The given array of bytes is `null`.
        `EndOfDataException` - The size of the RIFF chunk is less than the number of bytes to write relative to the current position.
        `IOException` - Error occurred when trying to write to the underlying stream.
      See Also:
        `RIFFChunk.getPosition()`

    - #### clone

          public RIFFChunk clone()

      Description copied from interface: `InterchangeObject`

      Create a cloned copy of this interchange object.

      Specified by:
        `clone` in interface `MediaEntity`
      Specified by:
        `clone` in interface `InterchangeObject`
      Specified by:
        `clone` in interface `RIFFChunk`
      Overrides:
        `clone` in class `InterchangeObjectImpl`
      Returns:
        Cloned copy of this interchange object.

    - #### getComment

          public String getComment()

      Description copied from interface: `XMLSerializable`

      Include a comment when serializing a value to XML. The comment will be inserted as the first child node of the element representing the class.

      Specified by:
        `getComment` in interface `XMLSerializable`
      Overrides:
        `getComment` in class `InterchangeObjectImpl`
      Returns:
        Comment to add as the first child node of the element representing this class.

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