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

COVERAGE SUMMARY FOR SOURCE FILE [FrameBodyUnsupported.java]

nameclass, %method, %block, %line, %
FrameBodyUnsupported.java100% (1/1)18%  (2/11)11%  (22/198)12%  (6/50)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class FrameBodyUnsupported100% (1/1)18%  (2/11)11%  (22/198)12%  (6/50)
FrameBodyUnsupported (FrameBodyUnsupported): void 0%   (0/1)0%   (0/20)0%   (0/5)
FrameBodyUnsupported (RandomAccessFile): void 0%   (0/1)0%   (0/9)0%   (0/4)
FrameBodyUnsupported (byte []): void 0%   (0/1)0%   (0/9)0%   (0/4)
equals (Object): boolean 0%   (0/1)0%   (0/28)0%   (0/8)
getIdentifier (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getSize (): int 0%   (0/1)0%   (0/13)0%   (0/4)
isSubsetOf (Object): boolean 0%   (0/1)0%   (0/30)0%   (0/8)
toString (): String 0%   (0/1)0%   (0/18)0%   (0/1)
write (RandomAccessFile): void 0%   (0/1)0%   (0/10)0%   (0/3)
read (RandomAccessFile): void 100% (1/1)37%  (21/57)38%  (5/13)
setupObjectList (): void 100% (1/1)100% (1/1)100% (1/1)

1package org.farng.mp3.id3;
2 
3import org.farng.mp3.InvalidTagException;
4 
5import java.io.IOException;
6import java.io.RandomAccessFile;
7import java.util.Arrays;
8 
9/**
10 * This frame is used if the frame identifier is not recognized. the contents of the frame are read as a byte stream and
11 * kept so they can be saved when the file is written again
12 *
13 * @author Eric Farng
14 * @version $Revision: 1.4 $
15 */
16public class FrameBodyUnsupported extends AbstractID3v2FrameBody {
17 
18    private String identifier = "";
19    private byte[] value;
20 
21    /**
22     * Creates a new FrameBodyUnsupported object.
23     */
24    public FrameBodyUnsupported(final byte[] value) {
25        this.value = value;
26    }
27 
28    /**
29     * Creates a new FrameBodyUnsupported object.
30     */
31    public FrameBodyUnsupported(final FrameBodyUnsupported copyObject) {
32        super(copyObject);
33        this.identifier = new String(copyObject.identifier);
34        this.value = (byte[]) copyObject.value.clone();
35    }
36 
37    /**
38     * Creates a new FrameBodyUnsupported object.
39     */
40    public FrameBodyUnsupported(final RandomAccessFile file) throws IOException, InvalidTagException {
41        this.read(file);
42    }
43 
44    public String getIdentifier() {
45        return this.identifier;
46    }
47 
48    public int getSize() {
49        int size = 0;
50        if (this.value != null) {
51            size += this.value.length;
52        }
53        return size;
54    }
55 
56    public boolean isSubsetOf(final Object object) {
57        if ((object instanceof FrameBodyUnsupported) == false) {
58            return false;
59        }
60        final FrameBodyUnsupported frameBodyUnsupported = (FrameBodyUnsupported) object;
61        final String subset = new String(this.value);
62        final String superset = new String(frameBodyUnsupported.value);
63        if (superset.indexOf(subset) < 0) {
64            return false;
65        }
66        return super.isSubsetOf(object);
67    }
68 
69    public boolean equals(final Object obj) {
70        if ((obj instanceof FrameBodyUnsupported) == false) {
71            return false;
72        }
73        final FrameBodyUnsupported frameBodyUnsupported = (FrameBodyUnsupported) obj;
74        if (this.identifier.equals(frameBodyUnsupported.identifier) == false) {
75            return false;
76        }
77        if (Arrays.equals(this.value, frameBodyUnsupported.value) == false) {
78            return false;
79        }
80        return super.equals(obj);
81    }
82 
83    protected void setupObjectList() {
84//        throw new UnsupportedOperationException();
85    }
86 
87    public void read(final RandomAccessFile file) throws IOException, InvalidTagException {
88        final int size;
89        final byte[] buffer;
90        if (has6ByteHeader()) {
91            // go back and read the 3 byte unsupported identifier;
92            file.seek(file.getFilePointer() - 3);
93            buffer = new byte[3];
94            file.read(buffer);
95            this.identifier = new String(buffer, 0, 3);
96        } else {
97            // go back and read the 4 byte unsupported identifier;
98            file.seek(file.getFilePointer() - 4);
99            buffer = new byte[4];
100            file.read(buffer);
101            this.identifier = new String(buffer);
102        }
103        size = readHeader(file);
104 
105        // read the data
106        this.value = new byte[size];
107        file.read(this.value);
108    }
109 
110    public String toString() {
111        return "??" + getIdentifier() + " : " + (new String(this.value));
112    }
113 
114    public void write(final RandomAccessFile file) throws IOException {
115        writeHeader(file, this.getSize());
116        file.write(this.value);
117    }
118}

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