| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractTagFrame |
|
| 3.3333333333333335;3.333 |
| 1 | /** | |
| 2 | * @author : Paul Taylor | |
| 3 | * @author : Eric Farng | |
| 4 | * | |
| 5 | * Version @version:$Id: AbstractTagFrame.java,v 1.4 2008/07/21 10:45:47 paultaylor Exp $ | |
| 6 | * | |
| 7 | * MusicTag Copyright (C)2003,2004 | |
| 8 | * | |
| 9 | * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser | |
| 10 | * General Public License as published by the Free Software Foundation; either version 2.1 of the License, | |
| 11 | * or (at your option) any later version. | |
| 12 | * | |
| 13 | * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
| 14 | * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 15 | * See the GNU Lesser General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU Lesser General Public License along with this library; if not, | |
| 18 | * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software | |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 20 | * | |
| 21 | * Description: | |
| 22 | * This class represents 'parts of tags'. It contains methods that they all use | |
| 23 | * use. ID3v2 tags have frames. Lyrics3 tags have fields. ID3v1 tags do not | |
| 24 | * have parts. It also contains their header while the body contains the | |
| 25 | * actual fragments. | |
| 26 | */ | |
| 27 | package org.jaudiotagger.tag.id3; | |
| 28 | ||
| 29 | /** | |
| 30 | * A frame contains meta-information of a particular type. A frame contains a header and a body | |
| 31 | */ | |
| 32 | public abstract class AbstractTagFrame extends AbstractTagItem | |
| 33 | { | |
| 34 | ||
| 35 | /** | |
| 36 | * Actual data this fragment holds | |
| 37 | */ | |
| 38 | protected AbstractTagFrameBody frameBody; | |
| 39 | ||
| 40 | public AbstractTagFrame() | |
| 41 | 3419 | { |
| 42 | 3419 | } |
| 43 | ||
| 44 | /** | |
| 45 | * This constructs the bodies copy constructor this in turn invokes | |
| 46 | * * bodies objectlist. | |
| 47 | */ | |
| 48 | public AbstractTagFrame(AbstractTagFrame copyObject) | |
| 49 | 0 | { |
| 50 | 0 | this.frameBody = (AbstractTagFrameBody) ID3Tags.copyObject(copyObject.frameBody); |
| 51 | 0 | this.frameBody.setHeader(this); |
| 52 | 0 | } |
| 53 | ||
| 54 | /** | |
| 55 | * Sets the body datatype for this fragment. The body datatype contains the | |
| 56 | * actual information for the fragment. | |
| 57 | * | |
| 58 | * @param frameBody the body datatype | |
| 59 | */ | |
| 60 | public void setBody(AbstractTagFrameBody frameBody) | |
| 61 | { | |
| 62 | 140 | this.frameBody = frameBody; |
| 63 | 140 | this.frameBody.setHeader(this); |
| 64 | 140 | } |
| 65 | ||
| 66 | /** | |
| 67 | * Returns the body datatype for this fragment. The body datatype contains the | |
| 68 | * actual information for the fragment. | |
| 69 | * | |
| 70 | * @return the body datatype | |
| 71 | */ | |
| 72 | public AbstractTagFrameBody getBody() | |
| 73 | { | |
| 74 | 3092 | return this.frameBody; |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * Returns true if this datatype and it's body is a subset of the argument. | |
| 79 | * This datatype is a subset if the argument is the same class. | |
| 80 | * | |
| 81 | * @param obj datatype to determine if subset of | |
| 82 | * @return true if this datatype and it's body is a subset of the argument. | |
| 83 | */ | |
| 84 | public boolean isSubsetOf(Object obj) | |
| 85 | { | |
| 86 | 0 | if ((obj instanceof AbstractTagFrame) == false) |
| 87 | { | |
| 88 | 0 | return false; |
| 89 | } | |
| 90 | ||
| 91 | 0 | if ((frameBody == null) && (((AbstractTagFrame) obj).frameBody == null)) |
| 92 | { | |
| 93 | 0 | return true; |
| 94 | } | |
| 95 | ||
| 96 | 0 | if ((frameBody == null) || (((AbstractTagFrame) obj).frameBody == null)) |
| 97 | { | |
| 98 | 0 | return false; |
| 99 | } | |
| 100 | ||
| 101 | 0 | if (frameBody.isSubsetOf(((AbstractTagFrame) obj).frameBody) == false) |
| 102 | { | |
| 103 | 0 | return false; |
| 104 | } | |
| 105 | ||
| 106 | 0 | return super.isSubsetOf(obj); |
| 107 | } | |
| 108 | ||
| 109 | /** | |
| 110 | * Returns true if this datatype and its body equals the argument and its | |
| 111 | * body. this datatype is equal if and only if they are the same class and | |
| 112 | * have the same <code>getSubId</code> id string. | |
| 113 | * | |
| 114 | * @param obj datatype to determine equality of | |
| 115 | * @return true if this datatype and its body equals the argument and its | |
| 116 | * body. | |
| 117 | */ | |
| 118 | public boolean equals(Object obj) | |
| 119 | { | |
| 120 | 0 | if ((obj instanceof AbstractTagFrame) == false) |
| 121 | { | |
| 122 | 0 | return false; |
| 123 | } | |
| 124 | ||
| 125 | 0 | AbstractTagFrame object = (AbstractTagFrame) obj; |
| 126 | ||
| 127 | 0 | if (this.getIdentifier().equals(object.getIdentifier()) == false) |
| 128 | { | |
| 129 | 0 | return false; |
| 130 | } | |
| 131 | ||
| 132 | 0 | if (this.frameBody.equals(object.frameBody) == false) |
| 133 | { | |
| 134 | 0 | return false; |
| 135 | } | |
| 136 | ||
| 137 | 0 | return super.equals(obj); |
| 138 | } | |
| 139 | } |