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

COVERAGE SUMMARY FOR SOURCE FILE [ObjectNumberVariableLength.java]

nameclass, %method, %block, %line, %
ObjectNumberVariableLength.java100% (1/1)17%  (2/12)13%  (31/247)17%  (10.5/61)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ObjectNumberVariableLength100% (1/1)17%  (2/12)13%  (31/247)17%  (10.5/61)
ObjectNumberVariableLength (ObjectNumberVariableLength): void 0%   (0/1)0%   (0/11)0%   (0/4)
getMaximumLenth (): int 0%   (0/1)0%   (0/2)0%   (0/1)
getMinimumLength (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getSize (): int 0%   (0/1)0%   (0/41)0%   (0/10)
readByteArray (byte [], int): void 0%   (0/1)0%   (0/58)0%   (0/10)
readString (String, int): void 0%   (0/1)0%   (0/37)0%   (0/6)
setMinimumSize (int): void 0%   (0/1)0%   (0/6)0%   (0/3)
toString (): String 0%   (0/1)0%   (0/9)0%   (0/3)
writeByteArray (): byte [] 0%   (0/1)0%   (0/38)0%   (0/9)
writeString (): String 0%   (0/1)0%   (0/9)0%   (0/3)
equals (Object): boolean 100% (1/1)89%  (17/19)83%  (5/6)
ObjectNumberVariableLength (String, int): void 100% (1/1)100% (14/14)100% (6/6)

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 ObjectNumberVariableLength extends AbstractMP3Object {
13 
14    int minLength = 1;
15 
16    /**
17     * Creates a new ObjectNumberVariableLength object.
18     */
19    public ObjectNumberVariableLength(final String identifier, final int minimumSize) {
20        this.identifier = identifier;
21        if (minimumSize > 0) {
22            this.minLength = minimumSize;
23        }
24    }
25 
26    /**
27     * Creates a new ObjectNumberVariableLength object.
28     */
29    public ObjectNumberVariableLength(final ObjectNumberVariableLength copyObject) {
30        super(copyObject);
31        this.minLength = copyObject.minLength;
32    }
33 
34    public int getMaximumLenth() {
35        return 8;
36    }
37 
38    public int getMinimumLength() {
39        return this.minLength;
40    }
41 
42    public void setMinimumSize(final int minimumSize) {
43        if (minimumSize > 0) {
44            this.minLength = minimumSize;
45        }
46    }
47 
48    public int getSize() {
49        if (this.value == null) {
50            return 0;
51        }
52        int current;
53        long temp = TagUtility.getWholeNumber(this.value);
54        int size = 0;
55        for (int i = 1; i <= 8; i++) {
56            current = (byte) temp & 0xFF;
57            if (current != 0) {
58                size = i;
59            }
60            temp >>= 8;
61        }
62        return (this.minLength > size) ? this.minLength : size;
63    }
64 
65    public boolean equals(final Object obj) {
66        if ((obj instanceof ObjectNumberVariableLength) == false) {
67            return false;
68        }
69        final ObjectNumberVariableLength objectNumberVariableLength = (ObjectNumberVariableLength) obj;
70        if (this.minLength != objectNumberVariableLength.minLength) {
71            return false;
72        }
73        return super.equals(obj);
74    }
75 
76    public void readByteArray(final byte[] arr, final int offset) {
77        if (arr == null) {
78            throw new NullPointerException("Byte array is null");
79        }
80        if ((offset < 0) || (offset >= arr.length)) {
81            throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " +
82                                                offset +
83                                                ", array.length = " +
84                                                arr
85                                                        .length);
86        }
87        long lvalue = 0;
88        for (int i = offset; i < arr.length; i++) {
89            lvalue <<= 8;
90            lvalue += arr[i];
91        }
92        this.value = new Long(lvalue);
93    }
94 
95    public void readString(final String str, final int offset) {
96        if (str == null) {
97            throw new NullPointerException("Number string is null");
98        }
99        if ((offset < 0) || (offset >= str.length())) {
100            throw new IndexOutOfBoundsException("Offset to number string is out of bounds: offset = " +
101                                                offset +
102                                                ", string.length()" +
103                                                str.length());
104        }
105        this.value = Long.getLong(str.substring(offset));
106    }
107 
108    public String toString() {
109        if (this.value == null) {
110            return "";
111        }
112        return this.value.toString();
113    }
114 
115    public byte[] writeByteArray() {
116        final int size = getSize();
117        final byte[] arr;
118        if (size == 0) {
119            arr = new byte[0];
120        } else {
121            long temp = TagUtility.getWholeNumber(this.value);
122            arr = new byte[size];
123            for (int i = size - 1; i >= 0; i--) {
124                arr[i] = (byte) (temp & 0xFF);
125                temp >>= 8;
126            }
127        }
128        return arr;
129    }
130 
131    public String writeString() {
132        if (this.value == null) {
133            return "";
134        }
135        return this.value.toString();
136    }
137}

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