package org.farng.mp3.id3;
import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectLyrics3Line;
import org.farng.mp3.object.ObjectNumberHashMap;
import org.farng.mp3.object.ObjectStringHashMap;
import org.farng.mp3.object.ObjectStringNullTerminated;
import org.farng.mp3.object.ObjectStringSizeTerminated;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* <h3>4.8. Unsynchronised lyrics/text transcription</h3>
* <p/>
* <p> This frame contains the lyrics of the song or a text transcription of<br> other vocal
* activities. The head includes an encoding descriptor and<br>
* <p/>
* a content descriptor. The body consists of the actual text. The<br> 'Content descriptor' is
* a terminated string. If no descriptor is<br> entered, 'Content descriptor' is $00 (00) only. Newline
* characters<br> are allowed in the text. There may be more than one 'Unsynchronised<br>
* lyrics/text transcription' frame in each tag, but only one with the<br>
* <p/>
* same language and content descriptor.</p>
* <p/>
* <p> <Header for 'Unsynchronised lyrics/text transcription', ID: "USLT"><br>
* Text encoding $xx<br>
* <p/>
* Language $xx xx xx<br>
* Content descriptor <text string according to encoding> $00 (00)<br>
* Lyrics/text <full text string
* according to encoding><br>
* <p/>
* </p>
*
* @author Eric Farng
* @version $Revision: 1.4 $
*/
public class FrameBodyUSLT extends AbstractID3v2FrameBody {
/**
* Creates a new FrameBodyUSLT object.
*/
public FrameBodyUSLT() {
super();
}
/**
* Creates a new FrameBodyUSLT object.
*/
public FrameBodyUSLT(final FrameBodyUSLT body) {
super(body);
}
/**
* Creates a new FrameBodyUSLT object.
*/
public FrameBodyUSLT(final byte textEncoding, final String language, final String description, final String text) {
setObject("Text Encoding", new Byte(textEncoding));
setObject("Language", language);
setObject("Description", description);
setObject("Lyrics/Text", text);
}
/**
* Creates a new FrameBodyUSLT object.
*/
public FrameBodyUSLT(final RandomAccessFile file) throws IOException, InvalidTagException {
this.read(file);
}
public void setDescription(final String description) {
setObject("Description", description);
}
public String getDescription() {
return (String) getObject("Description");
}
public String getIdentifier() {
return "USLT" + ((char) 0) + getLanguage() + ((char) 0) + getDescription();
}
public void setLanguage(final String language) {
setObject("Language", language);
}
public String getLanguage() {
return (String) getObject("Language");
}
public void setLyric(final String lyric) {
setObject("Lyrics/Text", lyric);
}
public String getLyric() {
return (String) getObject("Lyrics/Text");
}
public void addLyric(final String text) {
setLyric(getLyric() + text);
}
public void addLyric(final ObjectLyrics3Line line) {
setLyric(getLyric() + line.writeString());
}
protected void setupObjectList() {
appendToObjectList(new ObjectNumberHashMap("Text Encoding", 1));
appendToObjectList(new ObjectStringHashMap("Language", 3));
appendToObjectList(new ObjectStringNullTerminated("Description"));
appendToObjectList(new ObjectStringSizeTerminated("Lyrics/Text"));
}
}