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

java.lang.Object
  extended by com.tffenterprises.music.tag.id3v2.Frame
      extended by com.tffenterprises.music.tag.id3v2.frame.BaseFrame
          extended by com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
              extended by com.tffenterprises.music.tag.id3v2.frame.APICFrame
All Implemented Interfaces:
KeyedFrame, java.io.Serializable, java.lang.Cloneable

public class APICFrame
extends TextBasedFrame
implements KeyedFrame, java.io.Serializable, java.lang.Cloneable

This class is the ID3v2 APIC frame type; it handles image data.

Version:
1.0d1 $Date: 2004/04/25 04:02:46 $
Author:
Guillaume Lessard, Daniel M. Zimmerman
See Also:
Serialized Form

Field Summary
private  byte[] imageData
          The image data.
private  java.lang.String imageDescription
          The description text for this frame.
private  java.lang.String imageMimeType
          The image type (MIME) for this frame.
private  byte imageType
          The image type
private static java.lang.String MY_ID
          The frame ID of this frame.
 
Fields inherited from class com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
BOM_CHAR, BOM_CHAR_STRING, ENCODING_STRINGS, ISO_8859_1, NULL_BOM_STRING, NULL_CHAR, NULL_CHAR_STRING, UNICODE, UNICODE_BIG, UNICODE_LITTLE, UTF8
 
Constructor Summary
APICFrame()
          Constructs a new APICFrame with no description or value.
APICFrame(FrameHeader header)
          Constructs a APICFrame using the given header.
APICFrame(FrameHeader header, java.lang.String description, byte[] image)
          Constructs a new APICFrame with the specified header, description and value.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this ID3v2 frame.
 boolean equals(java.lang.Object other)
          Compares this ID3v2 frame with another object.
 java.lang.String getDescription()
          Returns the description field for the image embedded in this frame.
 byte[] getImageData()
          Returns the image data for this frame.
 byte[] getRawData()
          Returns the raw data corresponding to this frame.
 boolean isOfRepeatableType()
          Returns true, since it is legal for multiple frames of this type to exist in the same ID3v2 tag.
 void setDescription(java.lang.String frameDescription)
          Sets the description field for the image embedded in this frame.
 void setImageData(byte[] imageBytes)
          Sets the image data for this frame.
 void setRawData(byte[] rawData)
          Sets the raw data corresponding to this frame.
 java.lang.String toString()
          Returns a String representation of this frame.
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
getNullBytes, getTextEncoding, getTextEncoding, getTextEncoding, is8859String, read8859Characters, read8859String, readCharacters, readString, readUnicodeCharacters, readUnicodeString
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.BaseFrame
getBytes, getChecksum, getFormatFlags, getFrameID, getHeader, getStatusFlags, hashCode, isChanged, setChanged, setFormatFlags, setStatusFlags, toByteArray, updateChecksum, writeTo
 
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

MY_ID

private static final java.lang.String MY_ID
The frame ID of this frame.

See Also:
Constant Field Values

imageDescription

private java.lang.String imageDescription
The description text for this frame.


imageMimeType

private java.lang.String imageMimeType
The image type (MIME) for this frame.


imageType

private byte imageType
The image type


imageData

private byte[] imageData
The image data.

Constructor Detail

APICFrame

public APICFrame()
Constructs a new APICFrame with no description or value.


APICFrame

public APICFrame(FrameHeader header)
          throws java.lang.IllegalArgumentException
Constructs a APICFrame using the given header. The frame ID contained in the header will be redefined to "APIC", given that it is the only frame type handled by this class. The frame flags defined in the FrameHeader instance will be honored, however.

Parameters:
header - The FrameHeader to be used for this Frame instance. See FrameHeader for details.
Throws:
java.lang.IllegalArgumentException - This is exception is thrown when the parameter is unacceptable for use with an object of this Frame class/subclass.

APICFrame

public APICFrame(FrameHeader header,
                 java.lang.String description,
                 byte[] image)
          throws java.lang.IllegalArgumentException
Constructs a new APICFrame with the specified header, description and value.

Parameters:
header - The FrameHeader to be used for this Frame instance. See FrameHeader for details.
description - An image description.
image - The image as bytes.
Throws:
java.lang.IllegalArgumentException - if the specified frame type, the specified frame description, or the specified frame value is null.
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this ID3v2 frame.

Overrides:
clone in class BaseFrame
Returns:
a clone of this ID3v2 frame.

equals

public boolean equals(java.lang.Object other)
Compares this ID3v2 frame with another object.

Overrides:
equals in class BaseFrame
Parameters:
other - The other object.
Returns:
true if the two objects are equivalent, false otherwise.

toString

public java.lang.String toString()
Returns a String representation of this frame.

Overrides:
toString in class BaseFrame
Returns:
a String representation of this frame.

getRawData

public byte[] getRawData()
Returns the raw data corresponding to this frame. This does not include the frame header!

Specified by:
getRawData in class BaseFrame
Returns:
the raw data corresponding to this frame.

setRawData

public void setRawData(byte[] rawData)
                throws FrameDataFormatException,
                       java.lang.IllegalArgumentException
Sets the raw data corresponding to this frame.

Specified by:
setRawData in class BaseFrame
Parameters:
rawData - The raw data.
Throws:
FrameDataFormatException - if the raw data is not in an appropriate format for this frame's type.
java.lang.IllegalArgumentException - if the specified raw data is null.

isOfRepeatableType

public boolean isOfRepeatableType()
Returns true, since it is legal for multiple frames of this type to exist in the same ID3v2 tag.

Specified by:
isOfRepeatableType in interface KeyedFrame
Overrides:
isOfRepeatableType in class BaseFrame
Returns:
true, since this frame can coexist with others of its type.

getDescription

public java.lang.String getDescription()
Returns the description field for the image embedded in this frame.

Specified by:
getDescription in interface KeyedFrame
Returns:
the description field for the image embedded in this frame.

setDescription

public void setDescription(java.lang.String frameDescription)
Sets the description field for the image embedded in this frame.

Parameters:
frameDescription - The description text.
Throws:
java.lang.IllegalArgumentException - if the description text is null.

getImageData

public byte[] getImageData()
Returns the image data for this frame.

Returns:
the image data for this frame.

setImageData

public void setImageData(byte[] imageBytes)
Sets the image data for this frame.

Parameters:
imageBytes - the new image data for this frame.
Throws:
java.lang.IllegalArgumentException - if the array points to null.