AbstractFrameBodyTextInfopublic abstract class AbstractFrameBodyTextInfo extends AbstractID3v2FrameBody Abstract representation of a Text Frame
The text information frames are often the most important frames, containing information like artist, album and
more. There may only be one text information frame of its kind in an tag. In ID3v24 All text information frames
supports multiple strings, stored as a null separated list, where null is represented by the termination code
for the character encoding. All text frame identifiers begin with "T". Only text frame identifiers begin with "T",
with the exception of the "TXXX" frame. All the text information frames have the following format:
Text encoding $xx
Information
The list of valid text encodings increased from two in ID3v23 to four in ID3v24
iTunes incorrectly writes null terminators at the end of every String, even though it only writes one String.
You can retrieve the first value without the null terminator using {@link #getFirstTextValue} |
Constructors Summary |
---|
protected AbstractFrameBodyTextInfo()Creates a new FrameBodyTextInformation datatype. The super.super
Constructor sets up the Object list for the frame.
super();
setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
setObjectValue(DataTypes.OBJ_TEXT, "");
| protected AbstractFrameBodyTextInfo(AbstractFrameBodyTextInfo body)Copy Constructor
super(body);
| protected AbstractFrameBodyTextInfo(byte textEncoding, String text)Creates a new FrameBodyTextInformation data type. This is used when user
wants to create a new frame based on data in a user interface.
super();
setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
setObjectValue(DataTypes.OBJ_TEXT, text);
| protected AbstractFrameBodyTextInfo(ByteBuffer byteBuffer, int frameSize)Creates a new FrameBodyTextInformation data type from file.
The super.super Constructor sets up the Object list for the frame.
super(byteBuffer, frameSize);
|
Methods Summary |
---|
public void | addTextValue(java.lang.String value)Add additional value to value
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
text.addValue(value);
| public java.lang.String | getFirstTextValue()Get first value
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
return text.getValueAtIndex(0);
| public int | getNumberOfValues()
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
return text.getNumberOfValues();
| public java.lang.String | getText()Retrieve the complete text String as it is held internally.
If multiple values are held these wil be returned, needless trailing nulls will also be returned
return (String) getObjectValue(DataTypes.OBJ_TEXT);
| public java.lang.String | getTextWithoutTrailingNulls()Retrieve the complete text String but without any trailing nulls
If multiple values are held these will be returned, needless trailing nulls will not be returned
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
return text.getValueWithoutTrailingNull();
| public java.lang.String | getUserFriendlyValue()
return getTextWithoutTrailingNulls();
| public java.lang.String | getValueAtIndex(int index)Get text value at index
When a multiple values are stored within a single text frame this method allows access to any of the
individual values.
TextEncodedStringSizeTerminated text = (TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT);
return text.getValueAtIndex(index);
| public void | setText(java.lang.String text)Set the Full Text String.
If this String contains null terminator characters these are parsed as value
separators, allowing you to hold multiple strings within one text frame. This functionality is only
officially support in ID3v24.
if (text == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
setObjectValue(DataTypes.OBJ_TEXT, text);
| protected void | setupObjectList()Setup the Object List. All text frames contain a text encoding
and then a text string.
TODO:would like to make final but cannot because overridden by FrameBodyTXXX
objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
objectList.add(new TextEncodedStringSizeTerminated(DataTypes.OBJ_TEXT, this));
| public void | write(java.io.ByteArrayOutputStream tagBuffer)Because Text frames 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 change the text
encoding.
//Ensure valid for type
setTextEncoding(ID3TextEncodingConversion.getTextEncoding(getHeader(), getTextEncoding()));
//Ensure valid for data
if (!((TextEncodedStringSizeTerminated) getObject(DataTypes.OBJ_TEXT)).canBeEncoded())
{
this.setTextEncoding(ID3TextEncodingConversion.getUnicodeTextEncoding(getHeader()));
}
super.write(tagBuffer);
|
|