package org.farng.mp3.id3; import java.io.IOException; import java.io.RandomAccessFile; import org.farng.mp3.InvalidTagException; import org.farng.mp3.object.ObjectByteArraySizeTerminated; import org.farng.mp3.object.ObjectNumberHashMap; import org.farng.mp3.object.ObjectStringDate; import org.farng.mp3.object.ObjectStringNullTerminated; /** * <h3>4.24.   Commercial frame</h3> * <p/> * <p>   This frame enables several competing offers in the same tag by<br> * <p/> *    bundling all needed information. That makes this frame rather complex<br>    but it's an * easier solution than if one tries to achieve the same<br>    result with several frames. The frame begins, * after the frame ID,<br>    size and encoding fields, with a price string field. A price is<br>    * constructed by one three character currency code, encoded according<br> * <p/> *    to ISO 4217 [ISO-4217] alphabetic currency code, followed by a<br>    numerical value where * "." is used as decimal separator. In the price<br>    string several prices may be concatenated, * separated by a "/"<br>    character, but there may only be one currency of each type.</p> * <p/> * <p>   The price string is followed by an 8 character date string in the<br>    format YYYYMMDD, * describing for how long the price is valid. After<br>    that is a contact URL, with which the user can * contact the seller,<br>    followed by a one byte 'received as' field. It describes how the<br> *    audio is delivered when bought according to the following list:</p> * <p/> * <p>        $00  Other<br>         * $01  Standard CD album with other songs<br>         $02  Compressed * audio on CD<br> * <p/> *         $03  File over the Internet<br> *         $04  Stream over the Internet<br> *         $05  As note sheets<br> * <p/> *         $06  As note sheets in a book with other sheets<br> *         $07  Music on other media<br>         * $08  Non-musical merchandise</p> * <p/> * <p>   Next follows a terminated string with the name of the seller followed<br>    by a * terminated string with a short description of the product. The<br>    last thing is the ability to include * a company logotype. The first of<br>    them is the 'Picture MIME type' field containing information * about<br>    which picture format is used. In the event that the MIME media type<br> * <p/> *    name is omitted, "image/" will be implied. Currently only "image/png"<br> *    and "image/jpeg" are allowed. This format string is followed by the<br>    binary * picture data. This two last fields may be omitted if no<br> * <p/> *    picture is attached. There may be more than one 'commercial frame' in<br>    a tag, but no two * may be identical.</p> * <p/> * <p>     <Header for 'Commercial frame', ID: "COMR"><br>      * Text encoding      $xx<br> * <p/> *      Price string       <text string> $00<br> *      Valid until        <text string><br> *      Contact URL        * <p/> * <text string> $00<br>      Received as        $xx<br> *      Name of seller     <text string according to encoding> $00 * (00)<br> * <p/> *      Description        <text string according to * encoding> $00 (00)<br>      Picture MIME type  <string> $00<br> * <p/> *      Seller logo        <binary data><br> </p> * * @author Eric Farng * @version $Revision: 2374 $ */ public class FrameBodyCOMR extends AbstractID3v2FrameBody { /** * Creates a new FrameBodyCOMR object. */ public FrameBodyCOMR() { super(); } /** * Creates a new FrameBodyCOMR object. */ public FrameBodyCOMR(final FrameBodyCOMR body) { super(body); } /** * Creates a new FrameBodyCOMR object. */ public FrameBodyCOMR(final byte textEncoding, final String priceString, final String validUntil, final String contactUrl, final byte recievedAs, final String nameOfSeller, final String description, final String mimeType, final byte[] sellerLogo) { setObject("Text Encoding", new Byte(textEncoding)); setObject("Price String", priceString); setObject("Valid Until", validUntil); setObject("Contact URL", contactUrl); setObject("Recieved As", new Byte(recievedAs)); setObject("Name Of Seller", nameOfSeller); setObject("Description", description); setObject("Picture MIME Type", mimeType); setObject("Seller Logo", sellerLogo); } /** * Creates a new FrameBodyCOMR object. */ public FrameBodyCOMR(final RandomAccessFile file) throws IOException, InvalidTagException { this.read(file); } public String getIdentifier() { String str = "COMR"; final java.util.Iterator iterator = getObjectListIterator(); while (iterator.hasNext()) { str += (((char) 0) + getOwner()); } return str; } public String getOwner() { return (String) getObject("Owner"); } public void getOwner(final String description) { setObject("Owner", description); } protected void setupObjectList() { appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1)); appendToObjectList(new ObjectStringNullTerminated("Price String")); appendToObjectList(new ObjectStringDate("Valid Until")); appendToObjectList(new ObjectStringNullTerminated("Contact URL")); appendToObjectList(new ObjectNumberHashMap(ObjectNumberHashMap.RECIEVED_AS, 1)); appendToObjectList(new ObjectStringNullTerminated("Name Of Seller")); appendToObjectList(new ObjectStringNullTerminated("Description")); appendToObjectList(new ObjectStringNullTerminated("Picture MIME Type")); appendToObjectList(new ObjectByteArraySizeTerminated("Seller Logo")); } }