Media Authoring
with Java API

tv.amwa.maj.entity
Class RIFFChunk

java.lang.Object
  extended by tv.amwa.maj.entity.InterchangeObject
      extended by tv.amwa.maj.entity.RIFFChunk
All Implemented Interfaces:
Serializable, Cloneable, MAJCommon, InterchangeObject, RIFFChunk, XMLSerializable

@AAFClass(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).")
public class RIFFChunk
extends InterchangeObject
implements RIFFChunk, Serializable, Cloneable, MAJCommon

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

THE COMMENTS FOR THIS CLASS ARE INCOMPLETE.

Author:
Richard Cartwright
See Also:
Serialized Form

Nested Class Summary
static class RIFFChunk.XMLHandler
           
 
Nested classes/interfaces inherited from class tv.amwa.maj.entity.InterchangeObject
InterchangeObject.InterchangeObjectXMLHandler
 
Field Summary
static String RIFFCHUNK_TAG
           
 
Constructor Summary
RIFFChunk(int chunkID)
          Creates and initializes a new RIFF data chunk with the given chunk identifier.
 
Method Summary
 void appendXMLChildren(Node parent)
          Append child elements to the given parent node to serialize the value of an object to an XML fragment.
 RIFFChunk clone()
          Creates a cloned copy of this entity.
 boolean equals(Object o)
          Tests to see if the given object is equal to this interchange object.
 byte[] 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.
 long 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.
 int hashCode()
          Returns a hash code value for this interchange object.
 byte[] read(int numberOfBytes)
          Read the requested number of bytes from the RIFF chunk at the current position.
 void setChunkData(byte[] 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 setPosition(long offset)
          Sets the position for reading or writing this RIFF chunk data.
 void setPropertiesFromInterface(RIFFChunk castFrom)
           
 void write(byte[] bytes)
          Writes the given bytes to this RIFF chunk data at the current position.
 
Methods inherited from class tv.amwa.maj.entity.InterchangeObject
castFromInterface, countProperties, createOptionalPropertyValue, disableGenerationTracking, enableGenerationTracking, getDefinition, getGeneration, getGenerationAUID, getProperties, getPropertyValue, isGenerationTracked, isPropertyPresent, omitOpionalProperty, registerImplementation, setPropertiesFromInterface, setPropertyValue, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface tv.amwa.maj.iface.InterchangeObject
countProperties, createOptionalPropertyValue, disableGenerationTracking, enableGenerationTracking, getDefinition, getGeneration, getGenerationAUID, getProperties, getPropertyValue, isGenerationTracked, isPropertyPresent, omitOpionalProperty, setPropertyValue
 
Methods inherited from interface tv.amwa.maj.entity.MAJCommon
toString
 

Field Detail

RIFFCHUNK_TAG

public static final String RIFFCHUNK_TAG
See Also:
Constant Field Values
Constructor Detail

RIFFChunk

public RIFFChunk(@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

setPropertiesFromInterface

public final void setPropertiesFromInterface(RIFFChunk castFrom)
See Also:
InterchangeObject.setPropertiesFromInterface(tv.amwa.maj.iface.InterchangeObject)

getChunkData

@AAFProperty(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)
public byte[] 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

public void setChunkData(byte[] 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.

getChunkID

@AAFProperty(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)
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

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.

getLength

@AAFProperty(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)
public long 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(byte[]) has been called.

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

getPosition

public long getPosition()
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.

setPosition

public void setPosition(long offset)
                 throws PositionOutOfRangeException
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.
See Also:
RIFFChunk.getLength()

read

public byte[] read(int numberOfBytes)
            throws IllegalArgumentException,
                   EndOfDataException
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.
See Also:
RIFFChunk.getPosition()

write

public void write(byte[] bytes)
           throws NullPointerException,
                  EndOfDataException
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.
See Also:
RIFFChunk.getPosition()

equals

public boolean equals(Object o)
Description copied from interface: MAJCommon

Tests to see if the given object is equal to this interchange object. To be equal, the given value must be not null, share the same interface to its value and each of the properties of the value must each be equal.

Specified by:
equals in interface MAJCommon
Overrides:
equals in class Object
Parameters:
o - Object to test for equality with.
Returns:
Is the given object equals to this value?
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Description copied from interface: MAJCommon

Returns a hash code value for this interchange object.

Specified by:
hashCode in interface MAJCommon
Overrides:
hashCode in class Object
Returns:
Hash code value for this interchange object.
See Also:
Object.hashCode()

clone

public RIFFChunk clone()
Description copied from interface: MAJCommon

Creates a cloned copy of this entity. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.

This method does not throw a CloneNotSupportedException as all entity values must implement the Cloneable interface. If a cloning error does occur, a null value will be returned but this is very unlikely to happen.

Specified by:
clone in interface MAJCommon
Overrides:
clone in class Object
Returns:
Independent clone of this value, which is a deep copy.
See Also:
Object.clone()

appendXMLChildren

public void appendXMLChildren(Node parent)
Description copied from interface: XMLSerializable

Append child elements to the given parent node to serialize the value of an object to an XML fragment. Methods of the XMLBuilder class are provided to help with this process.

Specified by:
appendXMLChildren in interface XMLSerializable
Overrides:
appendXMLChildren in class InterchangeObject
Parameters:
parent - XML parent element to append child nodes to.

Media Authoring
with Java API

(c) 2007-2008 Richard Cartwright, all rights reserved. Subject to the terms of the AAF SDK Public Source License.