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

COVERAGE SUMMARY FOR SOURCE FILE [ObjectGroupRepeated.java]

nameclass, %method, %block, %line, %
ObjectGroupRepeated.java100% (1/1)45%  (5/11)29%  (77/262)35%  (23/65)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ObjectGroupRepeated100% (1/1)45%  (5/11)29%  (77/262)35%  (23/65)
ObjectGroupRepeated (ObjectGroupRepeated): void 0%   (0/1)0%   (0/46)0%   (0/8)
getObjectList (): ArrayList 0%   (0/1)0%   (0/3)0%   (0/1)
getPropertyList (): ArrayList 0%   (0/1)0%   (0/3)0%   (0/1)
readByteArray (byte [], int): void 0%   (0/1)0%   (0/77)0%   (0/19)
toString (): String 0%   (0/1)0%   (0/28)0%   (0/6)
writeByteArray (): byte [] 0%   (0/1)0%   (0/28)0%   (0/7)
ObjectGroupRepeated (String): void 100% (1/1)100% (16/16)100% (5/5)
addObject (AbstractMP3Object): void 100% (1/1)100% (6/6)100% (2/2)
addProperty (AbstractMP3Object): void 100% (1/1)100% (6/6)100% (2/2)
equals (Object): boolean 100% (1/1)100% (28/28)100% (8/8)
getSize (): int 100% (1/1)100% (21/21)100% (6/6)

1package org.farng.mp3.object;
2 
3import org.farng.mp3.TagUtility;
4 
5import java.util.ArrayList;
6import java.util.Iterator;
7 
8/**
9 * ID3v2 and Lyrics3v2 tags have individual fields <code>AbstractMP3Fragment</code>s Then each fragment is broken down
10 * in to individual <code>AbstractMP3Object</code>s
11 *
12 * @author Eric Farng
13 * @version $Revision: 1.5 $
14 */
15public class ObjectGroupRepeated extends AbstractMP3Object {
16 
17    private ArrayList objectList;
18    private ArrayList propertyList;
19 
20    /**
21     * Creates a new ObjectGroupRepeated object.
22     */
23    public ObjectGroupRepeated(final String identifier) {
24        this.identifier = identifier;
25        this.propertyList = new ArrayList();
26        this.objectList = new ArrayList();
27    }
28 
29    /**
30     * Creates a new ObjectGroupRepeated object.
31     */
32    public ObjectGroupRepeated(final ObjectGroupRepeated copyObject) {
33        super(copyObject);
34        AbstractMP3Object newObject;
35        for (int i = 0; i < copyObject.objectList.size(); i++) {
36            newObject = (AbstractMP3Object) TagUtility.copyObject(copyObject.objectList.get(i));
37            this.objectList.add(newObject);
38        }
39        for (int i = 0; i < copyObject.propertyList.size(); i++) {
40            newObject = (AbstractMP3Object) TagUtility.copyObject(copyObject.propertyList.get(i));
41            this.propertyList.add(newObject);
42        }
43    }
44 
45    public ArrayList getObjectList() {
46        return this.objectList;
47    }
48 
49    public ArrayList getPropertyList() {
50        return this.propertyList;
51    }
52 
53    public int getSize() {
54        int size = 0;
55        AbstractMP3Object object;
56        final Iterator iterator = this.objectList.listIterator();
57        while (iterator.hasNext()) {
58            object = (AbstractMP3Object) iterator.next();
59            size += object.getSize();
60        }
61        return size;
62    }
63 
64    public void addObject(final AbstractMP3Object object) {
65        this.objectList.add(object);
66    }
67 
68    public void addProperty(final AbstractMP3Object object) {
69        this.propertyList.add(object);
70    }
71 
72    public boolean equals(final Object obj) {
73        if ((obj instanceof ObjectGroupRepeated) == false) {
74            return false;
75        }
76        final ObjectGroupRepeated objectGroupRepeated = (ObjectGroupRepeated) obj;
77        if (this.objectList.equals(objectGroupRepeated.objectList) == false) {
78            return false;
79        }
80        if (this.propertyList.equals(objectGroupRepeated.propertyList) == false) {
81            return false;
82        }
83        return super.equals(obj);
84    }
85 
86    public void readByteArray(final byte[] arr, int offset) {
87        if (arr == null) {
88            throw new NullPointerException("Byte array is null");
89        }
90        if ((offset < 0) || (offset >= arr.length)) {
91            throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " +
92                                                offset +
93                                                ", array.length = " +
94                                                arr
95                                                        .length);
96        }
97        AbstractMP3Object object;
98        Class className;
99        Iterator iterator;
100        if (this.propertyList.size() > 0) {
101            while (offset < arr.length) {
102                iterator = this.propertyList.listIterator();
103                while (iterator.hasNext()) {
104                    className = iterator.next().getClass();
105                    try {
106                        object = (AbstractMP3Object) className.newInstance();
107                        this.objectList.add(object);
108                        object.readByteArray(arr, offset);
109                        offset += object.getSize();
110                    } catch (IllegalAccessException ex) {
111                        ex.printStackTrace();
112 
113                        // do nothing, just skip this one
114                    } catch (InstantiationException ex) {
115                        ex.printStackTrace();
116 
117                        // do nothing, just skip this one
118                    }
119                }
120            }
121        }
122    }
123 
124    public String toString() {
125        String str = "";
126        AbstractMP3Object object;
127        final Iterator iterator = this.objectList.listIterator();
128        while (iterator.hasNext()) {
129            object = (AbstractMP3Object) iterator.next();
130            str += (object.toString() + "\n");
131        }
132        return str;
133    }
134 
135    public byte[] writeByteArray() {
136        AbstractMP3Object object;
137        final byte[] totalArray = new byte[this.getSize()];
138        byte[] objectArray;
139        final Iterator iterator = this.objectList.listIterator();
140        while (iterator.hasNext()) {
141            object = (AbstractMP3Object) iterator.next();
142            objectArray = object.writeByteArray();
143            System.arraycopy(objectArray, 0, totalArray, 0, totalArray.length);
144        }
145        return totalArray;
146    }
147}

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