| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectNumberHashMap; |
| 5 | import org.farng.mp3.object.ObjectStringNullTerminated; |
| 6 | import org.farng.mp3.object.ObjectStringSizeTerminated; |
| 7 | |
| 8 | import java.io.IOException; |
| 9 | import java.io.RandomAccessFile; |
| 10 | |
| 11 | /** |
| 12 | * <p> This frame is intended for one-string text information concerning the<br> audio file in |
| 13 | * a similar way to the other "T"-frames. The frame body<br> consists of a description of the |
| 14 | * string, represented as a terminated<br> string, followed by the actual string. There may be more than |
| 15 | * one<br> |
| 16 | * <p/> |
| 17 | * "TXXX" frame in each tag, but only one with the same description.</p> |
| 18 | * <p/> |
| 19 | * <p> <Header for 'User defined text information frame', ID: "TXXX"><br> |
| 20 | * Text encoding $xx<br> |
| 21 | * <p/> |
| 22 | * Description <text string according to encoding> |
| 23 | * $00 (00)<br> Value |
| 24 | * <text string according to encoding><br> |
| 25 | * <p/> |
| 26 | * </p> |
| 27 | * |
| 28 | * @author Eric Farng |
| 29 | * @version $Revision: 1.4 $ |
| 30 | */ |
| 31 | public class FrameBodyTXXX extends AbstractID3v2FrameBody { |
| 32 | |
| 33 | /** |
| 34 | * Creates a new FrameBodyTXXX object. |
| 35 | */ |
| 36 | public FrameBodyTXXX() { |
| 37 | super(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Creates a new FrameBodyTXXX object. |
| 42 | */ |
| 43 | public FrameBodyTXXX(final FrameBodyTXXX body) { |
| 44 | super(body); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Creates a new FrameBodyTXXX object. |
| 49 | */ |
| 50 | public FrameBodyTXXX(final byte textEncoding, final String description, final String text) { |
| 51 | setObject("Text Encoding", new Byte(textEncoding)); |
| 52 | setObject("Description", description); |
| 53 | setObject("Text", text); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Creates a new FrameBodyTXXX object. |
| 58 | */ |
| 59 | public FrameBodyTXXX(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 60 | this.read(file); |
| 61 | } |
| 62 | |
| 63 | public String getBriefDescription() { |
| 64 | return this.getText(); |
| 65 | } |
| 66 | |
| 67 | public void setDescription(final String description) { |
| 68 | setObject("Description", description); |
| 69 | } |
| 70 | |
| 71 | public String getDescription() { |
| 72 | return (String) getObject("Description"); |
| 73 | } |
| 74 | |
| 75 | public String getIdentifier() { |
| 76 | return "TXXX" + ((char) 0) + getDescription(); |
| 77 | } |
| 78 | |
| 79 | public void setText(final String text) { |
| 80 | setObject("Text", text); |
| 81 | } |
| 82 | |
| 83 | public String getText() { |
| 84 | return (String) getObject("Text"); |
| 85 | } |
| 86 | |
| 87 | protected void setupObjectList() { |
| 88 | appendToObjectList(new ObjectNumberHashMap("Text Encoding", 1)); |
| 89 | appendToObjectList(new ObjectStringNullTerminated("Description")); |
| 90 | appendToObjectList(new ObjectStringSizeTerminated("Text")); |
| 91 | } |
| 92 | } |