EMMA Coverage Report (generated Tue Dec 18 20:38:46 CET 2007)
[all classes][cz.vutbr.feec.packets.rsi]

## COVERAGE SUMMARY FOR SOURCE FILE [BandwidthBlock.java]

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
BandwidthBlock.java | 100% (1/1) | 80% (4/5) | 81% (156/192) | 86% (26,6/31)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class BandwidthBlock | 100% (1/1) | 80% (4/5) | 81% (156/192) | 86% (26,6/31)
toString (): String |  | 0% (0/1) | 0% (0/14) | 0% (0/2)
parse (byte [], int, int): int |  | 100% (1/1) | 85% (75/88) | 86% (9,5/11)
<static initializer> |  | 100% (1/1) | 88% (7/8) | 87% (0,9/1)
generate (byte [], int): int |  | 100% (1/1) | 88% (59/67) | 93% (10,2/11)
BandwidthBlock (): void |  | 100% (1/1) | 100% (15/15) | 100% (6/6)

1 | package cz.vutbr.feec.packets.rsi;
2 |
3 | import cz.vutbr.feec.packets.PacketGenerateException;
4 | import cz.vutbr.feec.packets.PacketParseException;
5 | import cz.vutbr.feec.packets.PacketUtils;
6 | import org.apache.commons.lang.builder.ToStringBuilder;
7 |
8 | public class BandwidthBlock extends SubReportBlock {
9 | public boolean receiver = false;
10 | public boolean sender = false;
11 | public long bandwidth = -1;
12 |
13 | public BandwidthBlock() {
14 | this.setType(receiverBandwidth);
15 | }
16 |
17 | public int parse(byte[] array, int offset, int packetLength) throws PacketParseException {
18 | if(packetLength < 4*2) {
19 | throw new PacketParseException("array too short!");
20 | }
21 | // SBRT + Length
22 | super.parse(array, offset, packetLength);
23 | assert this.getType() == receiverBandwidth;
24 |
25 | sender = (array[2] & 0x80 ) != 0;
26 | receiver = (array[2] & 0x40 ) != 0;
27 |
28 | // Bandwidth
29 | this.bandwidth = ((array[4 + offset] & 0xff) << 24)
30 | | ((array[5 + offset] & 0xff) << 16)
31 | | ((array[6 + offset] & 0xff) << 8)
32 | | (array[7 + offset] & 0xff);
33 |
34 | return 4*2;
35 | }
36 |
37 | public int generate(byte[] array, int offset) throws PacketGenerateException {
38 | assert this.getType() == receiverBandwidth;
39 | this.length = 2*4;
40 | // SBRT + length
41 | super.generate(array, offset);
42 |
43 | if(sender) {
44 | array[2] |= 0x80; // 0b10000000
45 | } else {
46 | array[2] &= 0x7F; // 0b01111111
47 | }
48 | if(receiver) {
49 | array[2] |= 0x40; // 0b01000000
50 | } else {
51 | array[2] &= 0xBF; // 0b10111111
52 | }
53 |
54 | // Median jitter
55 | PacketUtils.setOctet4(array, offset+4, bandwidth);
56 | return 4*2;
57 | }
58 |
59 | /**
60 | * @see java.lang.Object#toString()
61 | */
62 | public String toString() {
63 | return new ToStringBuilder(this).append("type", this.getType()).append(
64 | "length", this.length).toString();
65 | }
66 |
67 | }

[all classes][cz.vutbr.feec.packets.rsi]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov