| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FrameBodyGRID |
|
| 1.2;1.2 |
| 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.ByteArraySizeTerminated; | |
| 20 | import org.jaudiotagger.tag.datatype.DataTypes; | |
| 21 | import org.jaudiotagger.tag.datatype.NumberFixedLength; | |
| 22 | import org.jaudiotagger.tag.datatype.StringNullTerminated; | |
| 23 | import org.jaudiotagger.tag.id3.ID3v24Frames; | |
| 24 | ||
| 25 | import java.nio.ByteBuffer; | |
| 26 | ||
| 27 | /** | |
| 28 | * Group identification registration frame. | |
| 29 | * <p/> | |
| 30 | * <p/> | |
| 31 | * This frame enables grouping of otherwise unrelated frames. This can | |
| 32 | * be used when some frames are to be signed. To identify which frames | |
| 33 | * belongs to a set of frames a group identifier must be registered in | |
| 34 | * the tag with this frame. The 'Owner identifier' is a null-terminated | |
| 35 | * string with a URL containing an email address, or a link to a | |
| 36 | * location where an email address can be found, that belongs to the | |
| 37 | * organisation responsible for this grouping. Questions regarding the | |
| 38 | * grouping should be sent to the indicated email address. The 'Group | |
| 39 | * symbol' contains a value that associates the frame with this group | |
| 40 | * throughout the whole tag. Values below $80 are reserved. The 'Group | |
| 41 | * symbol' may optionally be followed by some group specific data, e.g. | |
| 42 | * a digital signature. There may be several "GRID" frames in a tag but | |
| 43 | * only one containing the same symbol and only one containing the same | |
| 44 | * owner identifier. The group symbol must be used somewhere in the tag. | |
| 45 | * See section 3.3.1, flag j for more information. | |
| 46 | * </p><p><table border=0 width="70%"> | |
| 47 | * <tr><td colspan=2><Header for 'Group ID registration', ID: "GRID"></td></tr> | |
| 48 | * <tr><td>Owner identifier </td><td><text string> $00</td></tr> | |
| 49 | * <tr><td>Group symbol </td><td width="80%">$xx </td></tr> | |
| 50 | * <tr><td>Group dependent data </td><td><binary data> </td></tr> | |
| 51 | * </table></p> | |
| 52 | * <p/> | |
| 53 | * <p>For more details, please refer to the ID3 specifications: | |
| 54 | * <ul> | |
| 55 | * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a> | |
| 56 | * </ul> | |
| 57 | * | |
| 58 | * @author : Paul Taylor | |
| 59 | * @author : Eric Farng | |
| 60 | * @version $Id: FrameBodyGRID.java,v 1.14 2008/07/21 10:45:42 paultaylor Exp $ | |
| 61 | */ | |
| 62 | public class FrameBodyGRID extends AbstractID3v2FrameBody implements ID3v24FrameBody, ID3v23FrameBody | |
| 63 | { | |
| 64 | /** | |
| 65 | * Creates a new FrameBodyGRID datatype. | |
| 66 | */ | |
| 67 | public FrameBodyGRID() | |
| 68 | 0 | { |
| 69 | // this.setObject(ObjectTypes.OBJ_OWNER, ""); | |
| 70 | // this.setObject("Group Symbol", new Byte((byte) 0)); | |
| 71 | // this.setObject("Group Dependent Data", new byte[0]); | |
| 72 | 0 | } |
| 73 | ||
| 74 | public FrameBodyGRID(FrameBodyGRID body) | |
| 75 | { | |
| 76 | 0 | super(body); |
| 77 | 0 | } |
| 78 | ||
| 79 | /** | |
| 80 | * Creates a new FrameBodyGRID datatype. | |
| 81 | * | |
| 82 | * @param owner | |
| 83 | * @param groupSymbol | |
| 84 | * @param data | |
| 85 | */ | |
| 86 | public FrameBodyGRID(String owner, byte groupSymbol, byte[] data) | |
| 87 | 0 | { |
| 88 | 0 | this.setObjectValue(DataTypes.OBJ_OWNER, owner); |
| 89 | 0 | this.setObjectValue(DataTypes.OBJ_GROUP_SYMBOL, groupSymbol); |
| 90 | 0 | this.setObjectValue(DataTypes.OBJ_GROUP_DATA, data); |
| 91 | 0 | } |
| 92 | ||
| 93 | /** | |
| 94 | * Creates a new FrameBodyGRID datatype. | |
| 95 | * | |
| 96 | * @throws InvalidTagException if unable to create framebody from buffer | |
| 97 | */ | |
| 98 | public FrameBodyGRID(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException | |
| 99 | { | |
| 100 | 0 | super(byteBuffer, frameSize); |
| 101 | 0 | } |
| 102 | ||
| 103 | /** | |
| 104 | * @param textEncoding | |
| 105 | */ | |
| 106 | public void setGroupSymbol(byte textEncoding) | |
| 107 | { | |
| 108 | 0 | setObjectValue(DataTypes.OBJ_GROUP_SYMBOL, textEncoding); |
| 109 | 0 | } |
| 110 | ||
| 111 | /** | |
| 112 | * @return | |
| 113 | */ | |
| 114 | public byte getGroupSymbol() | |
| 115 | { | |
| 116 | 0 | if (getObjectValue(DataTypes.OBJ_GROUP_SYMBOL) != null) |
| 117 | { | |
| 118 | 0 | return ((Long) getObjectValue(DataTypes.OBJ_GROUP_SYMBOL)).byteValue(); |
| 119 | } | |
| 120 | else | |
| 121 | { | |
| 122 | 0 | return (byte) 0; |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | /** | |
| 127 | * The ID3v2 frame identifier | |
| 128 | * | |
| 129 | * @return the ID3v2 frame identifier for this frame type | |
| 130 | */ | |
| 131 | public String getIdentifier() | |
| 132 | { | |
| 133 | 0 | return ID3v24Frames.FRAME_ID_GROUP_ID_REG; |
| 134 | } | |
| 135 | ||
| 136 | ||
| 137 | /** | |
| 138 | * @param owner | |
| 139 | */ | |
| 140 | public void setOwner(String owner) | |
| 141 | { | |
| 142 | 0 | setObjectValue(DataTypes.OBJ_OWNER, owner); |
| 143 | 0 | } |
| 144 | ||
| 145 | /** | |
| 146 | * @return | |
| 147 | */ | |
| 148 | public String getOwner() | |
| 149 | { | |
| 150 | 0 | return (String) getObjectValue(DataTypes.OBJ_OWNER); |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * | |
| 155 | */ | |
| 156 | protected void setupObjectList() | |
| 157 | { | |
| 158 | 0 | objectList.add(new StringNullTerminated(DataTypes.OBJ_OWNER, this)); |
| 159 | 0 | objectList.add(new NumberFixedLength(DataTypes.OBJ_GROUP_SYMBOL, this, 1)); |
| 160 | 0 | objectList.add(new ByteArraySizeTerminated(DataTypes.OBJ_GROUP_DATA, this)); |
| 161 | 0 | } |
| 162 | } |