FrameBodyCOMMpublic class FrameBodyCOMM extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBodyComments frame.
This frame is intended for any kind of full text information that does not fit in any other frame. It consists of a
frame header followed by encoding, language and content descriptors and is ended with the actual comment as a
text string. Newline characters are allowed in the comment text string. There may be more than one comment frame
in each tag, but only one with the same language and* content descriptor.
<Header for 'Comment', ID: "COMM"> |
Text encoding | $xx |
Language | $xx xx xx |
Short content descrip. | <text string according to encoding> $00 (00) |
The actual text | <full text string according to encoding> |
For more details, please refer to the ID3 specifications:
|
Fields Summary |
---|
public static final String | DEFAULT | public static final String | ITUNES_NORMALIZATION | private static final String | MM_PREFIX | public static final String | MM_CUSTOM1 | public static final String | MM_CUSTOM2 | public static final String | MM_CUSTOM3 | public static final String | MM_CUSTOM4 | public static final String | MM_CUSTOM5 | public static final String | MM_OCCASION | public static final String | MM_QUALITY | public static final String | MM_TEMPO |
Constructors Summary |
---|
public FrameBodyCOMM()Creates a new FrameBodyCOMM datatype.
setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
setObjectValue(DataTypes.OBJ_LANGUAGE, Languages.DEFAULT_ID);
setObjectValue(DataTypes.OBJ_DESCRIPTION, "");
setObjectValue(DataTypes.OBJ_TEXT, "");
| public FrameBodyCOMM(FrameBodyCOMM body)
super(body);
| public FrameBodyCOMM(byte textEncoding, String language, String description, String text)Creates a new FrameBodyCOMM datatype.
setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
setObjectValue(DataTypes.OBJ_LANGUAGE, language);
setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
setObjectValue(DataTypes.OBJ_TEXT, text);
| public FrameBodyCOMM(ByteBuffer byteBuffer, int frameSize)Construct a Comment frame body from the buffer
super(byteBuffer, frameSize);
|
Methods Summary |
---|
public java.lang.String | getDescription()Get the description field, which describes the type of comment
return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
| public java.lang.String | getIdentifier()The ID3v2 frame identifier
return ID3v24Frames.FRAME_ID_COMMENT;
| public java.lang.String | getLanguage()Get the language the comment is written in
return (String) getObjectValue(DataTypes.OBJ_LANGUAGE);
| public java.lang.String | getText()Returns the the text field which holds the comment, adjusted to ensure does not return trailing null
which is due to a iTunes bug.
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
return text.getValueAtIndex(0);
| public java.lang.String | getUserFriendlyValue()
return getText();
| public boolean | isItunesFrame()
String desc = getDescription();
if(desc!=null && !(desc.length()==0))
{
if(desc.equals(ITUNES_NORMALIZATION))
{
return true;
}
}
return false;
| public boolean | isMediaMonkeyFrame()
String desc = getDescription();
if(desc!=null && !(desc.length()==0))
{
if(desc.startsWith(MM_PREFIX))
{
return true;
}
}
return false;
| public void | setDescription(java.lang.String description)Set the description field, which describes the type of comment
if (description == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
| public void | setLanguage(java.lang.String language)Sets the language the comment is written in
//TODO not sure if this might break existing code
/*if(language==null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
} */
setObjectValue(DataTypes.OBJ_LANGUAGE, language);
| public void | setText(java.lang.String text)
if (text == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
setObjectValue(DataTypes.OBJ_TEXT, text);
| protected void | setupObjectList()
objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
objectList.add(new StringHashMap(DataTypes.OBJ_LANGUAGE, this, Languages.LANGUAGE_FIELD_SIZE));
objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
objectList.add(new TextEncodedStringSizeTerminated(DataTypes.OBJ_TEXT, this));
| public void | write(java.io.ByteArrayOutputStream tagBuffer)Because COMM have a text encoding we need to check the text String does
not contain characters that cannot be encoded in current encoding before
we write data. If there are we change the encoding.
//Ensure valid for type
setTextEncoding(ID3TextEncodingConversion.getTextEncoding(getHeader(), getTextEncoding()));
//Ensure valid for data
if (!((AbstractString) getObject(DataTypes.OBJ_TEXT)).canBeEncoded())
{
this.setTextEncoding(ID3TextEncodingConversion.getUnicodeTextEncoding(getHeader()));
}
if (!((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded())
{
this.setTextEncoding(ID3TextEncodingConversion.getUnicodeTextEncoding(getHeader()));
}
super.write(tagBuffer);
|
|