2
* MusicTag Copyright (C)2003,2004
4
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
5
* General Public License as published by the Free Software Foundation; either version 2.1 of the License,
6
* or (at your option) any later version.
8
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
* See the GNU Lesser General Public License for more details.
12
* You should have received a copy of the GNU Lesser General Public License along with this library; if not,
13
* you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
package org.jaudiotagger.tag.id3.framebody;
18
import org.jaudiotagger.tag.InvalidTagException;
19
import org.jaudiotagger.tag.datatype.*;
20
import org.jaudiotagger.tag.id3.ID3v24Frames;
21
import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
23
import java.io.ByteArrayOutputStream;
24
import java.nio.ByteBuffer;
30
* This frame enables several competing offers in the same tag by
31
* bundling all needed information. That makes this frame rather complex
32
* but it's an easier solution than if one tries to achieve the same
33
* result with several frames. The frame begins, after the frame ID,
34
* size and encoding fields, with a price string field. A price is
35
* constructed by one three character currency code, encoded according
36
* to ISO-4217 alphabetic currency code, followed by a
37
* numerical value where "." is used as decimal seperator. In the price
38
* string several prices may be concatenated, seperated by a "/"
39
* character, but there may only be one currency of each type.
41
* The price string is followed by an 8 character date string in the
42
* format YYYYMMDD, describing for how long the price is valid. After
43
* that is a contact URL, with which the user can contact the seller,
44
* followed by a one byte 'received as' field. It describes how the
45
* audio is delivered when bought according to the following list:
46
* </p><p><table border=0 width="70%">
47
* <tr><td>$00 </td><td>Other </td></tr>
48
* <tr><td>$01 </td><td>Standard CD album with other songs </td></tr>
49
* <tr><td>$02 </td><td>Compressed audio on CD </td></tr>
50
* <tr><td>$03 </td><td>File over the Internet </td></tr>
51
* <tr><td>$04 </td><td>Stream over the Internet </td></tr>
52
* <tr><td>$05 </td><td>As note sheets </td></tr>
53
* <tr><td>$06 </td><td>As note sheets in a book with other sheets </td></tr>
54
* <tr><td>$07 </td><td>Music on other media </td></tr>
55
* <tr><td>$08 </td><td>Non-musical merchandise </td></tr>
57
* Next follows a terminated string with the name of the seller followed
58
* by a terminated string with a short description of the product. The
59
* last thing is the ability to include a company logotype. The first of
60
* them is the 'Picture MIME type' field containing information about
61
* which picture format is used. In the event that the MIME media type
62
* name is omitted, "image/" will be implied. Currently only "image/png"
63
* and "image/jpeg" are allowed. This format string is followed by the
64
* binary picture data. This two last fields may be omitted if no
65
* picture is to attach.
66
* </p><p><table border=0 width="70%">
67
* <tr><td colspan=2> <Header for 'Commercial frame', ID: "COMR"></td></tr>
68
* <tr><td>Text encoding </td><td>$xx </td></tr>
69
* <tr><td>Price string </td><td><text string> $00 </td></tr>
70
* <tr><td>Valid until </td><td><text string> </td></tr>
71
* <tr><td>Contact URL </td><td><text string> $00 </td></tr>
72
* <tr><td>Received as </td><td>$xx </td></tr>
73
* <tr><td>Name of seller</td><td><text string according to encoding> $00 (00)</td></tr>
74
* <tr><td>Description </td><td><text string according to encoding> $00 (00)</td></tr>
75
* <tr><td>Picture MIME type</td><td><string> $00 </td></tr>
76
* <tr><td>Seller logo </td><td><binary data> </td></tr>
79
* <p>For more details, please refer to the ID3 specifications:
81
* <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
84
* @author : Paul Taylor
85
* @author : Eric Farng
86
* @version $Id: FrameBodyCOMR.java,v 1.16 2008/07/21 10:45:42 paultaylor Exp $
88
public class FrameBodyCOMR extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
91
* Creates a new FrameBodyCOMR datatype.
93
public FrameBodyCOMR()
95
// this.setObject("Text Encoding", new Byte((byte) 0));
96
// this.setObject("Price String", "");
97
// this.setObject("Valid Until", "");
98
// this.setObject("Contact URL", "");
99
// this.setObject("Recieved As", new Byte((byte) 0));
100
// this.setObject("Name Of Seller", "");
101
// this.setObject(ObjectTypes.OBJ_DESCRIPTION, "");
102
// this.setObject("Picture MIME Type", "");
103
// this.setObject("Seller Logo", new byte[0]);
106
public FrameBodyCOMR(FrameBodyCOMR body)
112
* Creates a new FrameBodyCOMR datatype.
114
* @param textEncoding
119
* @param nameOfSeller
124
public FrameBodyCOMR(byte textEncoding, String priceString, String validUntil, String contactUrl, byte recievedAs, String nameOfSeller, String description, String mimeType, byte[] sellerLogo)
126
this.setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
127
this.setObjectValue(DataTypes.OBJ_PRICE_STRING, priceString);
128
this.setObjectValue(DataTypes.OBJ_VALID_UNTIL, validUntil);
129
this.setObjectValue(DataTypes.OBJ_CONTACT_URL, contactUrl);
130
this.setObjectValue(DataTypes.OBJ_RECIEVED_AS, recievedAs);
131
this.setObjectValue(DataTypes.OBJ_SELLER_NAME, nameOfSeller);
132
this.setObjectValue(DataTypes.OBJ_DESCRIPTION, description);
133
this.setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType);
134
this.setObjectValue(DataTypes.OBJ_SELLER_LOGO, sellerLogo);
138
* Creates a new FrameBodyCOMR datatype.
140
* @throws InvalidTagException if unable to create framebody from buffer
142
public FrameBodyCOMR(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
144
super(byteBuffer, frameSize);
148
* The ID3v2 frame identifier
150
* @return the ID3v2 frame identifier for this frame type
152
public String getIdentifier()
154
return ID3v24Frames.FRAME_ID_COMMERCIAL_FRAME;
160
public String getOwner()
162
return (String) getObjectValue(DataTypes.OBJ_OWNER);
168
public void getOwner(String description)
170
setObjectValue(DataTypes.OBJ_OWNER, description);
174
* If the seller or description cannot be encoded using current encoder, change the encoder
176
public void write(ByteArrayOutputStream tagBuffer)
178
if (((AbstractString) getObject(DataTypes.OBJ_SELLER_NAME)).canBeEncoded() == false)
180
this.setTextEncoding(TextEncoding.UTF_16);
182
if (((AbstractString) getObject(DataTypes.OBJ_DESCRIPTION)).canBeEncoded() == false)
184
this.setTextEncoding(TextEncoding.UTF_16);
186
super.write(tagBuffer);
192
protected void setupObjectList()
194
objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
195
objectList.add(new StringNullTerminated(DataTypes.OBJ_PRICE_STRING, this));
196
objectList.add(new StringDate(DataTypes.OBJ_VALID_UNTIL, this));
197
objectList.add(new StringNullTerminated(DataTypes.OBJ_CONTACT_URL, this));
198
objectList.add(new NumberHashMap(DataTypes.OBJ_RECIEVED_AS, this, 1));
199
objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_SELLER_NAME, this));
200
objectList.add(new TextEncodedStringNullTerminated(DataTypes.OBJ_DESCRIPTION, this));
201
objectList.add(new StringNullTerminated(DataTypes.OBJ_MIME_TYPE, this));
202
objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_SELLER_LOGO, this));