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

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.TXXXFrame
                  extended by com.tffenterprises.music.tag.id3v2.frame.CommentFrame
All Implemented Interfaces:
KeyedFrame, java.io.Serializable, java.lang.Cloneable

public class CommentFrame
extends TXXXFrame
implements KeyedFrame, java.io.Serializable, java.lang.Cloneable

This class is the ID3v2 Comment frame (and non-synchronized lyrics) type. It has a structure similar to TXXX, which contains two strings (the "Description" and the "Value"), but the first string is preceded by a three-byte language identifier.

Version:
1.0d1 $Date: 2002/10/11 00:57:30 $
Author:
Guillaume Lessard, Daniel M. Zimmerman
See Also:
Serialized Form

Field Summary
private  java.lang.String frameLanguage
          A language identifier for the text in this frame.
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
CommentFrame()
          Constructs a new CommentFrame with no description or value.
CommentFrame(FrameHeader header)
          Constructs a CommentFrame using the given header.
CommentFrame(FrameHeader header, java.lang.String languageID, java.lang.String frameDescription, java.lang.String frameValue)
          Constructs a new CommentFrame with the specified header, language 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 getTextEncoding(ByteArrayInputStream in)
          Returns a string representing the text encoding used by this frame.
 byte[] getTextEncoding(java.lang.String s)
          Returns a byte array representing the text encoding used by this frame.
 java.lang.String toString()
          Returns a String representation of this frame.
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.TXXXFrame
getDescription, getRawData, getValue, isOfRepeatableType, setDescription, setRawData, setValue
 
Methods inherited from class com.tffenterprises.music.tag.id3v2.frame.TextBasedFrame
getNullBytes, 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
 
Methods inherited from interface com.tffenterprises.music.tag.id3v2.frame.KeyedFrame
getDescription, isOfRepeatableType
 

Field Detail

MY_ID

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

See Also:
Constant Field Values

frameLanguage

private java.lang.String frameLanguage
A language identifier for the text in this frame.

Constructor Detail

CommentFrame

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


CommentFrame

public CommentFrame(FrameHeader header)
             throws java.lang.IllegalArgumentException
Constructs a CommentFrame using the given header. The frame ID contained in the header will be redefined to "COMM", 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.

CommentFrame

public CommentFrame(FrameHeader header,
                    java.lang.String languageID,
                    java.lang.String frameDescription,
                    java.lang.String frameValue)
             throws java.lang.IllegalArgumentException
Constructs a new CommentFrame with the specified header, language description and value.

Parameters:
header - The FrameHeader to be used for this frame.
languageID - The language in which this comment is written.
frameDescription - The frame description.
frameValue - The frame value.
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 TXXXFrame
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 TXXXFrame
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 TXXXFrame
Returns:
a String representation of this frame.

getTextEncoding

public java.lang.String getTextEncoding(ByteArrayInputStream in)
                                 throws FrameDataFormatException
Returns a string representing the text encoding used by this frame. This will always be an encoding type useable by java, either natively or through a converter supplied with this library.

For the moment, this method returns either "ISO8859_1" or "Unicode". Note that in the case of Unicode, further probing may be necessary in order to determine the byte ordering. The readUnicodeString() method does such additional probing.

Overrides:
getTextEncoding in class TextBasedFrame
Parameters:
in - the input stream from which the information will be read.
Returns:
a string representing the text encoding used by this frame.
Throws:
FrameDataFormatException - if the text encoding is unknown.

getTextEncoding

public byte[] getTextEncoding(java.lang.String s)
                       throws FrameDataFormatException
Returns a byte array representing the text encoding used by this frame. This will always be an encoding type useable by java, either natively or through a converter supplied with this library.

This method will concatenate the language code bytes to the encoding byte.

Overrides:
getTextEncoding in class TextBasedFrame
Parameters:
s - the encoding used, as a string.
Returns:
a byte array representing the text encoding used by this frame.
Throws:
FrameDataFormatException - if somehow the passed string represents an unknown encoding.