package org.farng.mp3.id3;
import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectByteArraySizeTerminated;
import org.farng.mp3.object.ObjectNumberHashMap;
import org.farng.mp3.object.ObjectStringNullTerminated;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* <h3>4.15. General encapsulated object</h3>
* <p/>
* <p> In this frame any type of file can be encapsulated. After the header,<br> 'Frame size'
* and 'Encoding' follows 'MIME type' [MIME] represented as<br> as a terminated string encoded with ISO
* 8859-1 [ISO-8859-1]. The<br> filename is case sensitive and is encoded as 'Encoding'. Then follows<br>
* <p/>
* a content description as terminated string, encoded as 'Encoding'.<br> The last thing in
* the frame is the actual object. The first two<br> strings may be omitted, leaving only their
* terminations. MIME type is<br> always an ISO-8859-1 text string. There may be more than one
* "GEOB"<br>
* <p/>
* frame in each tag, but only one with the same content descriptor.</p>
* <p/>
* <p> <Header for 'General encapsulated object', ID: "GEOB"><br>
* Text encoding $xx<br>
* MIME type
* <p/>
* <text string> $00<br> Filename
* <text string according to encoding> $00 (00)<br> Content description
* <text string according to encoding> $00 (00)<br>
* <p/>
* Encapsulated object <binary data><br> </p>
*
* @author Eric Farng
* @version $Revision: 1.4 $
*/
public class FrameBodyGEOB extends AbstractID3v2FrameBody {
/**
* Creates a new FrameBodyGEOB object.
*/
public FrameBodyGEOB() {
super();
}
/**
* Creates a new FrameBodyGEOB object.
*/
public FrameBodyGEOB(final FrameBodyGEOB body) {
super(body);
}
/**
* Creates a new FrameBodyGEOB object.
*/
public FrameBodyGEOB(final byte textEncoding,
final String mimeType,
final String filename,
final String description,
final byte[] object) {
setObject("TextEncoding", new Byte(textEncoding));
setObject("MIME Type", mimeType);
setObject("Filename", filename);
setObject("Description", description);
setObject("Encapsulated Object", object);
}
/**
* Creates a new FrameBodyGEOB object.
*/
public FrameBodyGEOB(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 "GEOB" + ((char) 0) + getDescription();
}
protected void setupObjectList() {
appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1));
appendToObjectList(new ObjectStringNullTerminated("MIME Type"));
appendToObjectList(new ObjectStringNullTerminated("Filename"));
appendToObjectList(new ObjectStringNullTerminated("Description"));
appendToObjectList(new ObjectByteArraySizeTerminated("Encapsulated Object"));
}
}