com.tffenterprises.music.tag.id3v2.frame
Class Container

java.lang.Object
  extended by com.tffenterprises.music.tag.id3v2.Frame
      extended by com.tffenterprises.music.tag.id3v2.frame.Container
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
GenericContainer, KeyedContainer

public abstract class Container
extends Frame
implements java.io.Serializable, java.lang.Cloneable

Container is a fake frame that holds multiple frames of the same type in ID3v2's frame table. Many types of frames can have multiple occurrences in a single ID3v2 tag, but they generally have a sub-key by which they can be uniquely identified. The classes that represent such frames must implement the com.tffenterprises.music.tag.id3v2.frame.KeyedFrame interface.

Version:
1.0d1 $Date: 2002/10/09 07:40:34 $
Author:
Guillaume Lessard
See Also:
Serialized Form

Field Summary
private  boolean changed
          The changed bit for this frame.
private  java.lang.String frameid
          The frame ID of the frames contained within.
 
Constructor Summary
Container()
          Public default constructor.
Container(java.lang.String id)
          Container is not a "real" subclass of Frame.
 
Method Summary
abstract  Frame addFrame(Frame frame)
           
 java.lang.Object clone()
          Returns a clone of this Container.
abstract  boolean contains(Frame frame)
           
 boolean equals(java.lang.Object other)
          Compares this Container with another object.
abstract  java.util.Enumeration frames()
           
 java.util.zip.Checksum getChecksum()
          Returns a checksum updated with this frame's data.
 byte getFormatFlags()
          Returns the format flags of this frame.
 java.lang.String getFrameID()
          Returns the frame ID of this frame.
protected  FrameHeader getHeader()
          Returns this frame object's FrameHeader instance.
 byte[] getRawData()
          Returns some raw data corresponding to this frame.
 byte getStatusFlags()
          Returns the status flags of this frame.
 int hashCode()
          Returns a hash code for this ID3v2 frame.
 boolean isChanged()
          Returns true is this frame has been changed.
abstract  boolean isEmpty()
           
 boolean isOfRepeatableType()
          Returns whether it is correct for multiple frames of the same type as this one to coexist in the same ID3v2 tag.
abstract  Frame removeFrame(Frame frame)
           
 void setChanged(boolean changed)
          Sets the changed state of this frame
 void setFormatFlags(byte flags)
          Sets the format flags of this frame.
 void setRawData(byte[] rawData)
          Does nothing.
 void setStatusFlags(byte flags)
          Sets the status flags of this frame.
abstract  int size()
           
 byte[] toByteArray()
          Returns a byte array containing the representation of all the contained frames, as they should be written to an ID3v2 tag.
 java.lang.String toString()
          Returns a String representation of this frame.
 void updateChecksum(DataOutputChecksum checksum)
          Returns a CheckSum object updated with this object.
 void writeTo(java.io.OutputStream outputStream)
          Writes this tag to an output stream.
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.Frame
FromByteArray, FromByteArray, FromInputStream, GetFrameClassForID, getNewInstance, getNewInstance, getNewInstance, MinimumLength, RegisterFrameClass, UnregisterFrameClass
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

frameid

private java.lang.String frameid
The frame ID of the frames contained within.


changed

private transient boolean changed
The changed bit for this frame.

Constructor Detail

Container

public Container()
Public default constructor.


Container

public Container(java.lang.String id)
          throws java.lang.IllegalArgumentException
Container is not a "real" subclass of Frame. If there were some kind of interface, I'd feel a bit better about it.

Parameters:
id - the frame id of the frames to be contained in this Container.
Throws:
java.lang.IllegalArgumentException - This is exception is thrown when the parameter is unacceptable or unusable.
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this Container. The object returned by this implementation already has the proper type, and the contained frames have been copied using the frames() and the addFrame methods. In order for this cloning method to work, subclasses of Container must have a public default constructor.

Specified by:
clone in class Frame
Returns:
a clone of this Container.

updateChecksum

public void updateChecksum(DataOutputChecksum checksum)
Returns a CheckSum object updated with this object. If a subclass's contained frames are all returned by the frames() method (as they should be), there is no need to override this method.

Specified by:
updateChecksum in class Frame
Parameters:
checksum - the checksum to update

getChecksum

public java.util.zip.Checksum getChecksum()
Description copied from class: Frame
Returns a checksum updated with this frame's data.

Specified by:
getChecksum in class Frame
Returns:
a checksum updated with this frame's data.

hashCode

public final int hashCode()
Returns a hash code for this ID3v2 frame. This method should be overridden by subclasses and updated with their local data.

Specified by:
hashCode in class Frame
Returns:
a hash code for this ID3v2 frame.

equals

public boolean equals(java.lang.Object other)
Compares this Container with another object. This method compares the classes of the objects, and returns false if the objects are either not of the same class or if one is null but the other is not. If both objects are Container instances, this method then proceeds to compare the contained Frame objects, verifying that there are the same number and that all this instance's contained Frames are also contained by the other object. To do this, this method uses the methods frames() and contains().

Specified by:
equals in class Frame
Parameters:
other - The other object.
Returns:
true if the two objects are of the same class and both non-null, false otherwise.

toString

public java.lang.String toString()
Description copied from class: Frame
Returns a String representation of this frame.

Specified by:
toString in class Frame
Returns:
a String representation of this frame.

getFrameID

public java.lang.String getFrameID()
Description copied from class: Frame
Returns the frame ID of this frame.

Specified by:
getFrameID in class Frame
Returns:
the frame ID of this frame.

getStatusFlags

public byte getStatusFlags()
Description copied from class: Frame
Returns the status flags of this frame.

Specified by:
getStatusFlags in class Frame
Returns:
the status flags of this frame.

setStatusFlags

public void setStatusFlags(byte flags)
Sets the status flags of this frame.

Specified by:
setStatusFlags in class Frame
Parameters:
flags - The new status flags.

getFormatFlags

public byte getFormatFlags()
Description copied from class: Frame
Returns the format flags of this frame.

Specified by:
getFormatFlags in class Frame
Returns:
the format flags of this frame.

setFormatFlags

public void setFormatFlags(byte flags)
Sets the format flags of this frame.

Specified by:
setFormatFlags in class Frame
Parameters:
flags - The new format flags.

isChanged

public boolean isChanged()
Description copied from class: Frame
Returns true is this frame has been changed.

Specified by:
isChanged in class Frame
Returns:
the changed state of this frame.

setChanged

public void setChanged(boolean changed)
Sets the changed state of this frame

Specified by:
setChanged in class Frame
Parameters:
changed - whether the frame is to be considered changed.

getRawData

public byte[] getRawData()
Returns some raw data corresponding to this frame. In this case, it is a contatenation of the raw data byte arrays of all the contained frames.

Specified by:
getRawData in class Frame
Returns:
some raw data corresponding to this frame.

setRawData

public void setRawData(byte[] rawData)
Does nothing.

Specified by:
setRawData in class Frame
Parameters:
rawData - The raw data.

toByteArray

public byte[] toByteArray()
Returns a byte array containing the representation of all the contained frames, as they should be written to an ID3v2 tag.

Specified by:
toByteArray in class Frame
Returns:
a byte array containing the representation of the frames as it should be written to an ID3v2 tag.

writeTo

public void writeTo(java.io.OutputStream outputStream)
             throws java.io.IOException,
                    java.lang.IllegalArgumentException
Writes this tag to an output stream. The bytes written to the stream are identical to those returned by toByteArray().

Specified by:
writeTo in class Frame
Parameters:
outputStream - The output stream.
Throws:
java.io.IOException - if there is a problem writing to the stream.
java.lang.IllegalArgumentException - if the specified output stream is null.

isOfRepeatableType

public boolean isOfRepeatableType()
Returns whether it is correct for multiple frames of the same type as this one to coexist in the same ID3v2 tag.

Specified by:
isOfRepeatableType in class Frame
Returns:
true if it is correct for multiple frames of this type to exist in the same ID3v2 tag, false otherwise.

getHeader

protected FrameHeader getHeader()
Returns this frame object's FrameHeader instance.

Specified by:
getHeader in class Frame
Returns:
this frame object's FrameHeader instance.

addFrame

public abstract Frame addFrame(Frame frame)
                        throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

removeFrame

public abstract Frame removeFrame(Frame frame)

frames

public abstract java.util.Enumeration frames()

contains

public abstract boolean contains(Frame frame)

isEmpty

public abstract boolean isEmpty()

size

public abstract int size()