| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.InvalidTagException; |
| 4 | import org.farng.mp3.object.ObjectLyrics3Line; |
| 5 | import org.farng.mp3.object.ObjectNumberHashMap; |
| 6 | import org.farng.mp3.object.ObjectStringHashMap; |
| 7 | import org.farng.mp3.object.ObjectStringNullTerminated; |
| 8 | import org.farng.mp3.object.ObjectStringSizeTerminated; |
| 9 | |
| 10 | import java.io.IOException; |
| 11 | import java.io.RandomAccessFile; |
| 12 | |
| 13 | /** |
| 14 | * <h3>4.8. Unsynchronised lyrics/text transcription</h3> |
| 15 | * <p/> |
| 16 | * <p> This frame contains the lyrics of the song or a text transcription of<br> other vocal |
| 17 | * activities. The head includes an encoding descriptor and<br> |
| 18 | * <p/> |
| 19 | * a content descriptor. The body consists of the actual text. The<br> 'Content descriptor' is |
| 20 | * a terminated string. If no descriptor is<br> entered, 'Content descriptor' is $00 (00) only. Newline |
| 21 | * characters<br> are allowed in the text. There may be more than one 'Unsynchronised<br> |
| 22 | * lyrics/text transcription' frame in each tag, but only one with the<br> |
| 23 | * <p/> |
| 24 | * same language and content descriptor.</p> |
| 25 | * <p/> |
| 26 | * <p> <Header for 'Unsynchronised lyrics/text transcription', ID: "USLT"><br> |
| 27 | * Text encoding $xx<br> |
| 28 | * <p/> |
| 29 | * Language $xx xx xx<br> |
| 30 | * Content descriptor <text string according to encoding> $00 (00)<br> |
| 31 | * Lyrics/text <full text string |
| 32 | * according to encoding><br> |
| 33 | * <p/> |
| 34 | * </p> |
| 35 | * |
| 36 | * @author Eric Farng |
| 37 | * @version $Revision: 1.4 $ |
| 38 | */ |
| 39 | public class FrameBodyUSLT extends AbstractID3v2FrameBody { |
| 40 | |
| 41 | /** |
| 42 | * Creates a new FrameBodyUSLT object. |
| 43 | */ |
| 44 | public FrameBodyUSLT() { |
| 45 | super(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Creates a new FrameBodyUSLT object. |
| 50 | */ |
| 51 | public FrameBodyUSLT(final FrameBodyUSLT body) { |
| 52 | super(body); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a new FrameBodyUSLT object. |
| 57 | */ |
| 58 | public FrameBodyUSLT(final byte textEncoding, final String language, final String description, final String text) { |
| 59 | setObject("Text Encoding", new Byte(textEncoding)); |
| 60 | setObject("Language", language); |
| 61 | setObject("Description", description); |
| 62 | setObject("Lyrics/Text", text); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Creates a new FrameBodyUSLT object. |
| 67 | */ |
| 68 | public FrameBodyUSLT(final RandomAccessFile file) throws IOException, InvalidTagException { |
| 69 | this.read(file); |
| 70 | } |
| 71 | |
| 72 | public void setDescription(final String description) { |
| 73 | setObject("Description", description); |
| 74 | } |
| 75 | |
| 76 | public String getDescription() { |
| 77 | return (String) getObject("Description"); |
| 78 | } |
| 79 | |
| 80 | public String getIdentifier() { |
| 81 | return "USLT" + ((char) 0) + getLanguage() + ((char) 0) + getDescription(); |
| 82 | } |
| 83 | |
| 84 | public void setLanguage(final String language) { |
| 85 | setObject("Language", language); |
| 86 | } |
| 87 | |
| 88 | public String getLanguage() { |
| 89 | return (String) getObject("Language"); |
| 90 | } |
| 91 | |
| 92 | public void setLyric(final String lyric) { |
| 93 | setObject("Lyrics/Text", lyric); |
| 94 | } |
| 95 | |
| 96 | public String getLyric() { |
| 97 | return (String) getObject("Lyrics/Text"); |
| 98 | } |
| 99 | |
| 100 | public void addLyric(final String text) { |
| 101 | setLyric(getLyric() + text); |
| 102 | } |
| 103 | |
| 104 | public void addLyric(final ObjectLyrics3Line line) { |
| 105 | setLyric(getLyric() + line.writeString()); |
| 106 | } |
| 107 | |
| 108 | protected void setupObjectList() { |
| 109 | appendToObjectList(new ObjectNumberHashMap("Text Encoding", 1)); |
| 110 | appendToObjectList(new ObjectStringHashMap("Language", 3)); |
| 111 | appendToObjectList(new ObjectStringNullTerminated("Description")); |
| 112 | appendToObjectList(new ObjectStringSizeTerminated("Lyrics/Text")); |
| 113 | } |
| 114 | } |