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

COVERAGE SUMMARY FOR SOURCE FILE [ObjectNumberFixedLength.java]

nameclass, %method, %block, %line, %
ObjectNumberFixedLength.java100% (1/1)55%  (6/11)54%  (119/221)62%  (31/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ObjectNumberFixedLength100% (1/1)55%  (6/11)54%  (119/221)62%  (31/50)
getLength (): int 0%   (0/1)0%   (0/3)0%   (0/1)
readString (String, int): void 0%   (0/1)0%   (0/37)0%   (0/6)
setSize (int): void 0%   (0/1)0%   (0/6)0%   (0/3)
toString (): String 0%   (0/1)0%   (0/9)0%   (0/3)
writeString (): String 0%   (0/1)0%   (0/12)0%   (0/3)
ObjectNumberFixedLength (String, int): void 100% (1/1)52%  (14/27)86%  (6/7)
readByteArray (byte [], int): void 100% (1/1)63%  (38/60)80%  (8/10)
ObjectNumberFixedLength (ObjectNumberFixedLength): void 100% (1/1)100% (11/11)100% (4/4)
equals (Object): boolean 100% (1/1)100% (19/19)100% (6/6)
getSize (): int 100% (1/1)100% (3/3)100% (1/1)
writeByteArray (): byte [] 100% (1/1)100% (34/34)100% (7/7)

1package org.farng.mp3.object;
2 
3import org.farng.mp3.TagUtility;
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.5 $
11 */
12public class ObjectNumberFixedLength extends AbstractMP3Object {
13 
14    int length = 0;
15 
16    /**
17     * Creates a new ObjectNumberFixedLength object.
18     */
19    public ObjectNumberFixedLength(final String identifier, final int size) {
20        if (size < 0) {
21            throw new IllegalArgumentException("Length is less than zero: " + this.length);
22        }
23        this.length = size;
24        this.identifier = identifier;
25    }
26 
27    /**
28     * Creates a new ObjectNumberFixedLength object.
29     */
30    public ObjectNumberFixedLength(final ObjectNumberFixedLength copyObject) {
31        super(copyObject);
32        this.length = copyObject.length;
33    }
34 
35    public int getLength() {
36        return this.length;
37    }
38 
39    public void setSize(final int length) {
40        if (length > 0) {
41            this.length = length;
42        }
43    }
44 
45    public int getSize() {
46        return this.length;
47    }
48 
49    public boolean equals(final Object obj) {
50        if ((obj instanceof ObjectNumberFixedLength) == false) {
51            return false;
52        }
53        final ObjectNumberFixedLength objectNumberFixedLength = (ObjectNumberFixedLength) obj;
54        if (this.length != objectNumberFixedLength.length) {
55            return false;
56        }
57        return super.equals(obj);
58    }
59 
60    public void readByteArray(final byte[] arr, final int offset) {
61        if (arr == null) {
62            throw new NullPointerException("Byte array is null");
63        }
64        if ((offset < 0) || (offset >= arr.length)) {
65            throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " +
66                                                offset +
67                                                ", array.length = " +
68                                                arr
69                                                        .length);
70        }
71        long lvalue = 0;
72        for (int i = offset; i < (offset + this.length); i++) {
73            lvalue <<= 8;
74            lvalue += arr[i];
75        }
76        this.value = new Long(lvalue);
77    }
78 
79    public void readString(final String str, final int offset) {
80        if (str == null) {
81            throw new NullPointerException("Number string is null");
82        }
83        if ((offset < 0) || (offset >= str.length())) {
84            throw new IndexOutOfBoundsException("Offset to number string is out of bounds: offset = " +
85                                                offset +
86                                                ", string.length()" +
87                                                str.length());
88        }
89        this.value = Long.getLong(str.substring(offset));
90    }
91 
92    public String toString() {
93        if (this.value == null) {
94            return "";
95        }
96        return this.value.toString();
97    }
98 
99    public byte[] writeByteArray() {
100        final byte[] arr;
101        arr = new byte[this.length];
102        if (this.value != null) {
103            long temp = TagUtility.getWholeNumber(this.value);
104            for (int i = this.length - 1; i >= 0; i--) {
105                arr[i] = (byte) (temp & 0xFF);
106                temp >>= 8;
107            }
108        }
109        return arr;
110    }
111 
112    public String writeString() {
113        if (this.value == null) {
114            return String.valueOf(new char[this.length]);
115        }
116        return this.value.toString();
117    }
118}

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