| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FrameBodyLINK |
|
| 1.0;1 |
| 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><Header for 'Linked information', ID: "LINK"> </td></tr> | |
| 47 | * <tr><td>Frame identifier </td><td>$xx xx xx </td></tr> | |
| 48 | * <tr><td>URL </td><td><text string> $00</td></tr> | |
| 49 | * <tr><td>ID and additional data</td><td><text string(s)> </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.13 2008/07/21 10:45:42 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 | 0 | { |
| 80 | // this.setObject("Frame Identifier", ""); | |
| 81 | // this.setObject("URL", ""); | |
| 82 | // this.setObject("ID and Additional Data", ""); | |
| 83 | 0 | } |
| 84 | ||
| 85 | public FrameBodyLINK(FrameBodyLINK body) | |
| 86 | { | |
| 87 | 0 | super(body); |
| 88 | 0 | } |
| 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 | 0 | { |
| 99 | 0 | this.setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier); |
| 100 | 0 | this.setObjectValue(DataTypes.OBJ_URL, url); |
| 101 | 0 | this.setObjectValue(DataTypes.OBJ_ID, additionalData); |
| 102 | 0 | } |
| 103 | ||
| 104 | /** | |
| 105 | * Creates a new FrameBodyLINK datatype. | |
| 106 | * | |
| 107 | * @throws InvalidTagException if unable to create framebody from buffer | |
| 108 | */ | |
| 109 | public FrameBodyLINK(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException | |
| 110 | { | |
| 111 | 0 | super(byteBuffer, frameSize); |
| 112 | 0 | } |
| 113 | ||
| 114 | /** | |
| 115 | * @return | |
| 116 | */ | |
| 117 | public String getAdditionalData() | |
| 118 | { | |
| 119 | 0 | return (String) getObjectValue(DataTypes.OBJ_ID); |
| 120 | } | |
| 121 | ||
| 122 | /** | |
| 123 | * @param additionalData | |
| 124 | */ | |
| 125 | public void getAdditionalData(String additionalData) | |
| 126 | { | |
| 127 | 0 | setObjectValue(DataTypes.OBJ_ID, additionalData); |
| 128 | 0 | } |
| 129 | ||
| 130 | /** | |
| 131 | * @return | |
| 132 | */ | |
| 133 | public String getFrameIdentifier() | |
| 134 | { | |
| 135 | 0 | return (String) getObjectValue(DataTypes.OBJ_DESCRIPTION); |
| 136 | } | |
| 137 | ||
| 138 | /** | |
| 139 | * @param frameIdentifier | |
| 140 | */ | |
| 141 | public void getFrameIdentifier(String frameIdentifier) | |
| 142 | { | |
| 143 | 0 | setObjectValue(DataTypes.OBJ_DESCRIPTION, frameIdentifier); |
| 144 | 0 | } |
| 145 | ||
| 146 | /** | |
| 147 | * The ID3v2 frame identifier | |
| 148 | * | |
| 149 | * @return the ID3v2 frame identifier for this frame type | |
| 150 | */ | |
| 151 | public String getIdentifier() | |
| 152 | { | |
| 153 | 0 | return ID3v24Frames.FRAME_ID_LINKED_INFO; |
| 154 | } | |
| 155 | ||
| 156 | ||
| 157 | /** | |
| 158 | * | |
| 159 | */ | |
| 160 | protected void setupObjectList() | |
| 161 | { | |
| 162 | 0 | objectList.add(new StringFixedLength(DataTypes.OBJ_DESCRIPTION, this, 4)); |
| 163 | 0 | objectList.add(new StringNullTerminated(DataTypes.OBJ_URL, this)); |
| 164 | 0 | objectList.add(new StringSizeTerminated(DataTypes.OBJ_ID, this)); |
| 165 | 0 | } |
| 166 | } |