EMMA Coverage Report (generated Tue Mar 14 21:50:42 EST 2006)
[all classes][org.farng.mp3.object]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractMP3Object.java]

nameclass, %method, %block, %line, %
AbstractMP3Object.java100% (1/1)83%  (10/12)43%  (226/525)52%  (52.5/101)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractMP3Object100% (1/1)83%  (10/12)43%  (226/525)52%  (52.5/101)
readString (String, int): void 0%   (0/1)0%   (0/8)0%   (0/2)
writeString (): String 0%   (0/1)0%   (0/6)0%   (0/1)
equals (Object): boolean 100% (1/1)37%  (76/204)40%  (15.5/39)
AbstractMP3Object (AbstractMP3Object): void 100% (1/1)40%  (103/260)50%  (22/44)
AbstractMP3Object (): void 100% (1/1)100% (15/15)100% (6/6)
getIdentifier (): String 100% (1/1)100% (3/3)100% (1/1)
getValue (): Object 100% (1/1)100% (3/3)100% (1/1)
readByteArray (byte []): void 100% (1/1)100% (5/5)100% (2/2)
readByteArray (byte [], int): void 100% (1/1)100% (8/8)100% (2/2)
readString (String): void 100% (1/1)100% (5/5)100% (2/2)
setValue (Object): void 100% (1/1)100% (4/4)100% (2/2)
writeByteArray (): byte [] 100% (1/1)100% (4/4)100% (1/1)

1package org.farng.mp3.object;
2 
3import java.util.Arrays;
4 
5/**
6 * ID3v2 and Lyrics3v2 tags have individual fields <code>AbstractMP3Fragment</code>s Then each fragment is broken down
7 * in to individual <code>AbstractMP3Object</code>s
8 *
9 * @author Eric Farng
10 * @version $Revision: 1.4 $
11 */
12public abstract class AbstractMP3Object extends java.lang.Object {
13 
14    protected Object value = null;
15    protected String identifier = "";
16 
17    /**
18     * Creates a new AbstractMP3Object object.
19     */
20    public AbstractMP3Object() {
21        this.value = null;
22        this.identifier = "";
23    }
24 
25    /**
26     * Creates a new AbstractMP3Object object.
27     */
28    public AbstractMP3Object(final AbstractMP3Object copyObject) {
29        // no copy constructor in super class
30        this.identifier = new String(copyObject.identifier);
31        if (copyObject.value == null) {
32            this.value = null;
33        } else if (copyObject.value instanceof String) {
34            this.value = new String((String) copyObject.value);
35        } else if (copyObject.value instanceof Boolean) {
36            this.value = new Boolean(((Boolean) copyObject.value).booleanValue());
37        } else if (copyObject.value instanceof Byte) {
38            this.value = new Byte(((Byte) copyObject.value).byteValue());
39        } else if (copyObject.value instanceof Character) {
40            this.value = new Character(((Character) copyObject.value).charValue());
41        } else if (copyObject.value instanceof Double) {
42            this.value = new Double(((Double) copyObject.value).doubleValue());
43        } else if (copyObject.value instanceof Float) {
44            this.value = new Float(((Float) copyObject.value).floatValue());
45        } else if (copyObject.value instanceof Integer) {
46            this.value = new Integer(((Integer) copyObject.value).intValue());
47        } else if (copyObject.value instanceof Long) {
48            this.value = new Long(((Long) copyObject.value).longValue());
49        } else if (copyObject.value instanceof Short) {
50            this.value = new Short(((Short) copyObject.value).shortValue());
51        } else if (copyObject.value instanceof boolean[]) {
52            this.value = ((boolean[]) copyObject.value).clone();
53        } else if (copyObject.value instanceof byte[]) {
54            this.value = ((byte[]) copyObject.value).clone();
55        } else if (copyObject.value instanceof char[]) {
56            this.value = ((char[]) copyObject.value).clone();
57        } else if (copyObject.value instanceof double[]) {
58            this.value = ((double[]) copyObject.value).clone();
59        } else if (copyObject.value instanceof float[]) {
60            this.value = ((float[]) copyObject.value).clone();
61        } else if (copyObject.value instanceof int[]) {
62            this.value = ((int[]) copyObject.value).clone();
63        } else if (copyObject.value instanceof long[]) {
64            this.value = ((long[]) copyObject.value).clone();
65        } else if (copyObject.value instanceof short[]) {
66            this.value = ((short[]) copyObject.value).clone();
67        } else if (copyObject.value instanceof Object[]) {
68            this.value = ((Object[]) copyObject.value).clone();
69        } else {
70            throw new UnsupportedOperationException("Unable to create copy of class " + copyObject.getClass());
71        }
72    }
73 
74    public String getIdentifier() {
75        return this.identifier;
76    }
77 
78    public void setValue(final Object value) {
79        this.value = value;
80    }
81 
82    public Object getValue() {
83        return this.value;
84    }
85 
86    public final void readByteArray(final byte[] arr) {
87        readByteArray(arr, 0);
88    }
89 
90    public final void readString(final String str) {
91        readString(str, 0);
92    }
93 
94    public abstract int getSize();
95 
96    public void readByteArray(final byte[] arr, final int offset) {
97        readString(new String(arr), offset);
98    }
99 
100    public void readString(final String str, final int offset) {
101        readByteArray(str.substring(offset).getBytes(), 0);
102    }
103 
104    public abstract String toString();
105 
106    public boolean equals(final Object obj) {
107        if ((obj instanceof AbstractMP3Object) == false) {
108            return false;
109        }
110        final AbstractMP3Object abstractMp3Object = (AbstractMP3Object) obj;
111        if (this.identifier.equals(abstractMp3Object.identifier) == false) {
112            return false;
113        }
114        if ((this.value == null) && (abstractMp3Object.value == null)) {
115            return true;
116        } else if ((this.value == null) || (abstractMp3Object.value == null)) {
117            return false;
118        }
119 
120        // boolean[]
121        if (this.value instanceof boolean[] && abstractMp3Object.value instanceof boolean[]) {
122            if (Arrays.equals((boolean[]) this.value, (boolean[]) abstractMp3Object.value) == false) {
123                return false;
124            }
125 
126            // byte[]
127        } else if (this.value instanceof byte[] && abstractMp3Object.value instanceof byte[]) {
128            if (Arrays.equals((byte[]) this.value, (byte[]) abstractMp3Object.value) == false) {
129                return false;
130            }
131 
132            // char[]
133        } else if (this.value instanceof char[] && abstractMp3Object.value instanceof char[]) {
134            if (Arrays.equals((char[]) this.value, (char[]) abstractMp3Object.value) == false) {
135                return false;
136            }
137 
138            // double[]
139        } else if (this.value instanceof double[] && abstractMp3Object.value instanceof double[]) {
140            if (Arrays.equals((double[]) this.value, (double[]) abstractMp3Object.value) == false) {
141                return false;
142            }
143 
144            // float[]
145        } else if (this.value instanceof float[] && abstractMp3Object.value instanceof float[]) {
146            if (Arrays.equals((float[]) this.value, (float[]) abstractMp3Object.value) == false) {
147                return false;
148            }
149 
150            // int[]
151        } else if (this.value instanceof int[] && abstractMp3Object.value instanceof int[]) {
152            if (Arrays.equals((int[]) this.value, (int[]) abstractMp3Object.value) == false) {
153                return false;
154            }
155 
156            // long[]
157        } else if (this.value instanceof long[] && abstractMp3Object.value instanceof long[]) {
158            if (Arrays.equals((long[]) this.value, (long[]) abstractMp3Object.value) == false) {
159                return false;
160            }
161 
162            // Object[]
163        } else if (this.value instanceof Object[] && abstractMp3Object.value instanceof Object[]) {
164            if (Arrays.equals((Object[]) this.value, (Object[]) abstractMp3Object.value) == false) {
165                return false;
166            }
167 
168            // short[]
169        } else if (this.value instanceof short[] && abstractMp3Object.value instanceof short[]) {
170            if (Arrays.equals((short[]) this.value, (short[]) abstractMp3Object.value) == false) {
171                return false;
172            }
173        } else if (this.value.equals(abstractMp3Object.value) == false) {
174            return false;
175        }
176        return true;
177    }
178 
179    public byte[] writeByteArray() {
180        return writeString().getBytes();
181    }
182 
183    public String writeString() {
184        return new String(writeByteArray());
185    }
186}

[all classes][org.farng.mp3.object]
EMMA 2.0.5312 (C) Vladimir Roubtsov