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

COVERAGE SUMMARY FOR SOURCE FILE [ObjectStringFixedLength.java]

nameclass, %method, %block, %line, %
ObjectStringFixedLength.java100% (1/1)56%  (5/9)42%  (65/156)56%  (20/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ObjectStringFixedLength100% (1/1)56%  (5/9)42%  (65/156)56%  (20/36)
getLength (): int 0%   (0/1)0%   (0/3)0%   (0/1)
setLength (int): void 0%   (0/1)0%   (0/4)0%   (0/2)
toString (): String 0%   (0/1)0%   (0/3)0%   (0/1)
writeString (): String 0%   (0/1)0%   (0/47)0%   (0/9)
readString (String, int): void 100% (1/1)45%  (18/40)67%  (4/6)
ObjectStringFixedLength (String, int): void 100% (1/1)54%  (14/26)86%  (6/7)
ObjectStringFixedLength (ObjectStringFixedLength): 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)

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 ObjectStringFixedLength extends AbstractMP3Object {
13 
14    int length = 0;
15 
16    /**
17     * Creates a new ObjectStringFixedLength object.
18     */
19    public ObjectStringFixedLength(final String identifier, final int length) {
20        if (length < 0) {
21            throw new IllegalArgumentException("length is less than zero: " + length);
22        }
23        this.identifier = identifier;
24        this.length = length;
25    }
26 
27    /**
28     * Creates a new ObjectStringFixedLength object.
29     */
30    public ObjectStringFixedLength(final ObjectStringFixedLength copyObject) {
31        super(copyObject);
32        this.length = copyObject.length;
33    }
34 
35    public void setLength(final int size) {
36        this.length = size;
37    }
38 
39    public int getLength() {
40        return this.length;
41    }
42 
43    public int getSize() {
44        return this.length;
45    }
46 
47    public boolean equals(final Object obj) {
48        if ((obj instanceof ObjectStringFixedLength) == false) {
49            return false;
50        }
51        final ObjectStringFixedLength objectStringFixedLength = (ObjectStringFixedLength) obj;
52        if (this.length != objectStringFixedLength.length) {
53            return false;
54        }
55        return super.equals(obj);
56    }
57 
58    public void readString(final String str, final int offset) {
59        if (str == null) {
60            throw new NullPointerException("String is null");
61        }
62        if ((offset < 0) || (offset >= str.length())) {
63            throw new IndexOutOfBoundsException("Offset to String is out of bounds: offset = " +
64                                                offset +
65                                                ", string.length()" +
66                                                str.length());
67        }
68        this.value = str.substring(offset, this.length + offset);
69    }
70 
71    public String toString() {
72        return writeString();
73    }
74 
75    public String writeString() {
76        final String str;
77        if (this.value == null) {
78            str = String.valueOf(new char[this.length]);
79        } else {
80            final int vlength = ((String) this.value).length();
81            if (vlength > this.length) {
82                str = ((String) this.value).substring(0, this.length);
83            } else if (vlength == this.length) {
84                str = (String) this.value;
85            } else {
86                str = TagUtility.padString((String) this.value, this.length, ' ', false);
87            }
88        }
89        return str;
90    }
91}

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