~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic

« back to all changes in this revision

Viewing changes to src/org/jaudiotagger/tag/id3/framebody/FrameBodyLINK.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2011-04-28 23:52:43 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20110428235243-pzalvw6lncis3ukf
Tags: 2.0.3-1
* d/control: Drop Depends on default-jre per Debian Java Policy as its
  a library package.
* d/watch: Fix to directly monitor SVN tags.
* Switch to 3.0 (quilt) format.
* Bump Standards-Version to 3.9.2 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  MusicTag Copyright (C)2003,2004
3
 
 *
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.
7
 
 *
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.
11
 
 *
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
15
 
 */
16
 
package org.jaudiotagger.tag.id3.framebody;
17
 
 
18
 
import org.jaudiotagger.tag.InvalidTagException;
19
 
import org.jaudiotagger.tag.datatype.DataTypes;
20
 
import org.jaudiotagger.tag.datatype.StringFixedLength;
21
 
import org.jaudiotagger.tag.datatype.StringNullTerminated;
22
 
import org.jaudiotagger.tag.datatype.StringSizeTerminated;
23
 
import org.jaudiotagger.tag.id3.ID3v24Frames;
24
 
 
25
 
import java.nio.ByteBuffer;
26
 
 
27
 
/**
28
 
 * Linked information frame.
29
 
 * <p/>
30
 
 * <p/>
31
 
 * To keep space waste as low as possible this frame may be used to link
32
 
 * information from another ID3v2 tag that might reside in another audio
33
 
 * file or alone in a binary file. It is recommended that this method is
34
 
 * only used when the files are stored on a CD-ROM or other
35
 
 * circumstances when the risk of file seperation is low. The frame
36
 
 * contains a frame identifier, which is the frame that should be linked
37
 
 * into this tag, a URL field, where a reference to the file where
38
 
 * the frame is given, and additional ID data, if needed. Data should be
39
 
 * retrieved from the first tag found in the file to which this link
40
 
 * points. There may be more than one "LINK" frame in a tag, but only
41
 
 * one with the same contents. A linked frame is to be considered as
42
 
 * part of the tag and has the same restrictions as if it was a physical
43
 
 * part of the tag (i.e. only one "RVRB" frame allowed, whether it's
44
 
 * linked or not).
45
 
 * </p><p><table border=0 width="70%">
46
 
 * <tr><td>&lt;Header for 'Linked information', ID: "LINK"&gt;   </td></tr>
47
 
 * <tr><td>Frame identifier      </td><td>$xx xx xx              </td></tr>
48
 
 * <tr><td>URL                   </td><td>&lt;text string&gt; $00</td></tr>
49
 
 * <tr><td>ID and additional data</td><td>&lt;text string(s)&gt; </td></tr>
50
 
 * </table></p>
51
 
 * <p/>
52
 
 * Frames that may be linked and need no additional data are "IPLS",
53
 
 * "MCID", "ETCO", "MLLT", "SYTC", "RVAD", "EQUA", "RVRB", "RBUF", the
54
 
 * text information frames and the URL link frames.
55
 
 * </p><p>
56
 
 * The "TXXX", "APIC", "GEOB" and "AENC" frames may be linked with
57
 
 * the content descriptor as additional ID data.
58
 
 * </p><p>
59
 
 * The "COMM", "SYLT" and "USLT" frames may be linked with three bytes
60
 
 * of language descriptor directly followed by a content descriptor as
61
 
 * additional ID data.
62
 
 * </p>
63
 
 * <p/>
64
 
 * <p>For more details, please refer to the ID3 specifications:
65
 
 * <ul>
66
 
 * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
67
 
 * </ul>
68
 
 *
69
 
 * @author : Paul Taylor
70
 
 * @author : Eric Farng
71
 
 * @version $Id: FrameBodyLINK.java,v 1.14 2009/11/12 13:25:22 paultaylor Exp $
72
 
 */
73
 
public class FrameBodyLINK extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
74
 
{
75
 
    /**
76
 
     * Creates a new FrameBodyLINK datatype.
77
 
     */
78
 
    public FrameBodyLINK()
79
 
    {
80
 
        //        this.setObject("Frame Identifier", "");
81
 
        //        this.setObject("URL", "");
82
 
        //        this.setObject("ID and Additional Data", "");
83
 
    }
84
 
 
85
 
    public FrameBodyLINK(FrameBodyLINK body)
86
 
    {
87
 
        super(body);
88
 
    }
89
 
 
90
 
    /**
91
 
     * Creates a new FrameBodyLINK datatype.
92
 
     *
93
 
     * @param frameIdentifier
94
 
     * @param url
95
 
     * @param additionalData
96
 
     */
97
 
    public FrameBodyLINK(String frameIdentifier, String url, String additionalData)
98
 
    {
99
 
        this.setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier);
100
 
        this.setObjectValue(DataTypes.OBJ_URL, url);
101
 
        this.setObjectValue(DataTypes.OBJ_ID, additionalData);
102
 
    }
103
 
 
104
 
    /**
105
 
     * Creates a new FrameBodyLINK datatype.
106
 
     *
107
 
     * @param byteBuffer
108
 
     * @param frameSize
109
 
     * @throws InvalidTagException if unable to create framebody from buffer
110
 
     */
111
 
    public FrameBodyLINK(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
112
 
    {
113
 
        super(byteBuffer, frameSize);
114
 
    }
115
 
 
116
 
    /**
117
 
     * @return
118
 
     */
119
 
    public String getAdditionalData()
120
 
    {
121
 
        return (String) getObjectValue(DataTypes.OBJ_ID);
122
 
    }
123
 
 
124
 
    /**
125
 
     * @param additionalData
126
 
     */
127
 
    public void getAdditionalData(String additionalData)
128
 
    {
129
 
        setObjectValue(DataTypes.OBJ_ID, additionalData);
130
 
    }
131
 
 
132
 
    /**
133
 
     * @return
134
 
     */
135
 
    public String getFrameIdentifier()
136
 
    {
137
 
        return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
138
 
    }
139
 
 
140
 
    /**
141
 
     * @param frameIdentifier
142
 
     */
143
 
    public void getFrameIdentifier(String frameIdentifier)
144
 
    {
145
 
        setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier);
146
 
    }
147
 
 
148
 
    /**
149
 
     * The ID3v2 frame identifier
150
 
     *
151
 
     * @return the ID3v2 frame identifier  for this frame type
152
 
     */
153
 
    public String getIdentifier()
154
 
    {
155
 
        return ID3v24Frames.FRAME_ID_LINKED_INFO;
156
 
    }
157
 
 
158
 
 
159
 
    /**
160
 
     *
161
 
     */
162
 
    protected void setupObjectList()
163
 
    {
164
 
        objectList.add(new StringFixedLength(DataTypes.OBJ_DESCRIPTION, this, 4));
165
 
        objectList.add(new StringNullTerminated(DataTypes.OBJ_URL, this));
166
 
        objectList.add(new StringSizeTerminated(DataTypes.OBJ_ID, this));
167
 
    }
168
 
}
 
1
/*
 
2
 *  MusicTag Copyright (C)2003,2004
 
3
 *
 
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.
 
7
 *
 
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.
 
11
 *
 
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
 
15
 */
 
16
package org.jaudiotagger.tag.id3.framebody;
 
17
 
 
18
import org.jaudiotagger.tag.InvalidTagException;
 
19
import org.jaudiotagger.tag.datatype.DataTypes;
 
20
import org.jaudiotagger.tag.datatype.StringFixedLength;
 
21
import org.jaudiotagger.tag.datatype.StringNullTerminated;
 
22
import org.jaudiotagger.tag.datatype.StringSizeTerminated;
 
23
import org.jaudiotagger.tag.id3.ID3v24Frames;
 
24
 
 
25
import java.nio.ByteBuffer;
 
26
 
 
27
/**
 
28
 * Linked information frame.
 
29
 * <p/>
 
30
 * <p/>
 
31
 * To keep space waste as low as possible this frame may be used to link
 
32
 * information from another ID3v2 tag that might reside in another audio
 
33
 * file or alone in a binary file. It is recommended that this method is
 
34
 * only used when the files are stored on a CD-ROM or other
 
35
 * circumstances when the risk of file seperation is low. The frame
 
36
 * contains a frame identifier, which is the frame that should be linked
 
37
 * into this tag, a URL field, where a reference to the file where
 
38
 * the frame is given, and additional ID data, if needed. Data should be
 
39
 * retrieved from the first tag found in the file to which this link
 
40
 * points. There may be more than one "LINK" frame in a tag, but only
 
41
 * one with the same contents. A linked frame is to be considered as
 
42
 * part of the tag and has the same restrictions as if it was a physical
 
43
 * part of the tag (i.e. only one "RVRB" frame allowed, whether it's
 
44
 * linked or not).
 
45
 * </p><p><table border=0 width="70%">
 
46
 * <tr><td>&lt;Header for 'Linked information', ID: "LINK"&gt;   </td></tr>
 
47
 * <tr><td>Frame identifier      </td><td>$xx xx xx              </td></tr>
 
48
 * <tr><td>URL                   </td><td>&lt;text string&gt; $00</td></tr>
 
49
 * <tr><td>ID and additional data</td><td>&lt;text string(s)&gt; </td></tr>
 
50
 * </table></p>
 
51
 * <p/>
 
52
 * Frames that may be linked and need no additional data are "IPLS",
 
53
 * "MCID", "ETCO", "MLLT", "SYTC", "RVAD", "EQUA", "RVRB", "RBUF", the
 
54
 * text information frames and the URL link frames.
 
55
 * </p><p>
 
56
 * The "TXXX", "APIC", "GEOB" and "AENC" frames may be linked with
 
57
 * the content descriptor as additional ID data.
 
58
 * </p><p>
 
59
 * The "COMM", "SYLT" and "USLT" frames may be linked with three bytes
 
60
 * of language descriptor directly followed by a content descriptor as
 
61
 * additional ID data.
 
62
 * </p>
 
63
 * <p/>
 
64
 * <p>For more details, please refer to the ID3 specifications:
 
65
 * <ul>
 
66
 * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
 
67
 * </ul>
 
68
 *
 
69
 * @author : Paul Taylor
 
70
 * @author : Eric Farng
 
71
 * @version $Id: FrameBodyLINK.java 832 2009-11-12 13:25:38Z paultaylor $
 
72
 */
 
73
public class FrameBodyLINK extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody
 
74
{
 
75
    /**
 
76
     * Creates a new FrameBodyLINK datatype.
 
77
     */
 
78
    public FrameBodyLINK()
 
79
    {
 
80
        //        this.setObject("Frame Identifier", "");
 
81
        //        this.setObject("URL", "");
 
82
        //        this.setObject("ID and Additional Data", "");
 
83
    }
 
84
 
 
85
    public FrameBodyLINK(FrameBodyLINK body)
 
86
    {
 
87
        super(body);
 
88
    }
 
89
 
 
90
    /**
 
91
     * Creates a new FrameBodyLINK datatype.
 
92
     *
 
93
     * @param frameIdentifier
 
94
     * @param url
 
95
     * @param additionalData
 
96
     */
 
97
    public FrameBodyLINK(String frameIdentifier, String url, String additionalData)
 
98
    {
 
99
        this.setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier);
 
100
        this.setObjectValue(DataTypes.OBJ_URL, url);
 
101
        this.setObjectValue(DataTypes.OBJ_ID, additionalData);
 
102
    }
 
103
 
 
104
    /**
 
105
     * Creates a new FrameBodyLINK datatype.
 
106
     *
 
107
     * @param byteBuffer
 
108
     * @param frameSize
 
109
     * @throws InvalidTagException if unable to create framebody from buffer
 
110
     */
 
111
    public FrameBodyLINK(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException
 
112
    {
 
113
        super(byteBuffer, frameSize);
 
114
    }
 
115
 
 
116
    /**
 
117
     * @return
 
118
     */
 
119
    public String getAdditionalData()
 
120
    {
 
121
        return (String) getObjectValue(DataTypes.OBJ_ID);
 
122
    }
 
123
 
 
124
    /**
 
125
     * @param additionalData
 
126
     */
 
127
    public void getAdditionalData(String additionalData)
 
128
    {
 
129
        setObjectValue(DataTypes.OBJ_ID, additionalData);
 
130
    }
 
131
 
 
132
    /**
 
133
     * @return
 
134
     */
 
135
    public String getFrameIdentifier()
 
136
    {
 
137
        return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION);
 
138
    }
 
139
 
 
140
    /**
 
141
     * @param frameIdentifier
 
142
     */
 
143
    public void getFrameIdentifier(String frameIdentifier)
 
144
    {
 
145
        setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier);
 
146
    }
 
147
 
 
148
    /**
 
149
     * The ID3v2 frame identifier
 
150
     *
 
151
     * @return the ID3v2 frame identifier  for this frame type
 
152
     */
 
153
    public String getIdentifier()
 
154
    {
 
155
        return ID3v24Frames.FRAME_ID_LINKED_INFO;
 
156
    }
 
157
 
 
158
 
 
159
    /**
 
160
     *
 
161
     */
 
162
    protected void setupObjectList()
 
163
    {
 
164
        objectList.add(new StringFixedLength(DataTypes.OBJ_DESCRIPTION, this, 4));
 
165
        objectList.add(new StringNullTerminated(DataTypes.OBJ_URL, this));
 
166
        objectList.add(new StringSizeTerminated(DataTypes.OBJ_ID, this));
 
167
    }
 
168
}