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

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

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
FTSPacket.java | 100% (1/1) | 84% (16/19) | 69% (243/352) | 75% (49,6/66)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class FTSPacket | 100% (1/1) | 84% (16/19) | 69% (243/352) | 75% (49,6/66)
getGroupBlock (int): FTSGroupBlock |  | 0% (0/1) | 0% (0/6) | 0% (0/1)
hashCode (): int |  | 0% (0/1) | 0% (0/22) | 0% (0/3)
toString (): String |  | 0% (0/1) | 0% (0/42) | 0% (0/8)
generateRestFTS (byte [], int): int |  | 100% (1/1) | 62% (59/95) | 73% (8,7/12)
<static initializer> |  | 100% (1/1) | 88% (7/8) | 87% (0,9/1)
equals (Object): boolean |  | 100% (1/1) | 95% (40/42) | 88% (7/8)
FTSPacket (): void |  | 100% (1/1) | 100% (9/9) | 100% (3/3)
addGroupBlock (FTSGroupBlock): void |  | 100% (1/1) | 100% (6/6) | 100% (2/2)
generate (byte [], int): int |  | 100% (1/1) | 100% (16/16) | 100% (3/3)
getIncreaseFactor (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getLMSseqNumber (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getReservedEnd (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getSessionSize (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
parse (byte [], int, int): int |  | 100% (1/1) | 100% (16/16) | 100% (3/3)
parseRestFTS (byte [], int, int): int |  | 100% (1/1) | 100% (62/62) | 100% (10/10)
setIncreaseFactor (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setLMSseqNumber (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setReservedEnd (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setSessionSize (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)

1 | package cz.vutbr.feec.packets.ttp;
2 |
3 | import java.util.Vector;
4 |
5 | import cz.vutbr.feec.packets.PacketGenerateException;
6 | import cz.vutbr.feec.packets.PacketParseException;
7 | import cz.vutbr.feec.packets.PacketUtils;
8 | import org.apache.commons.lang.builder.ToStringBuilder;
9 | import org.apache.commons.lang.builder.EqualsBuilder;
10 | import org.apache.commons.lang.builder.HashCodeBuilder;
11 |
12 | public class FTSPacket extends GeneralTTPHeader {
13 |
14 | private long LMSseqNumber;
15 |
16 | private long sessionSize;
17 |
18 | private long increaseFactor;
19 |
20 | private long reservedEnd;
21 |
22 | public FTSPacket() {
23 | super(5);
24 | }
25 |
26 | private Vector<FTSGroupBlock> groupList = new Vector<FTSGroupBlock>();
27 |
28 | public void addGroupBlock(FTSGroupBlock group) {
29 | groupList.add(group);
30 | }
31 |
32 | public FTSGroupBlock getGroupBlock(int index) {
33 |
34 | return groupList.get(index);
35 | }
36 |
37 | /**
38 | * Generate buffer of values in FTS header. <i>This method generates
39 | * specific size of bytes into the buffer.</i>
40 | *
41 | * @param resultArray -
42 | * memory bytes for generating buffer
43 | * @param startPos -
44 | * starting position in resultArray
45 | */
46 | @Override
47 | public int generate(byte[] resultArray, int startPos)
48 | throws PacketGenerateException {
49 | int length = super.generate(resultArray, startPos);
50 | length += generateRestFTS(resultArray, startPos + length);
51 | return length;
52 | }
53 |
54 | private int generateRestFTS(byte[] buffer, int offset) throws PacketGenerateException {
55 |
56 | assert PacketUtils.checkSize(this.getLMSseqNumber(), 32);
57 | assert PacketUtils.checkSize(this.getSessionSize(), 32);
58 | assert PacketUtils.checkSize(this.getIncreaseFactor(), 16);
59 | assert PacketUtils.checkSize(this.getReservedEnd(), 16);
60 |
61 | // adding LMS sequence number
62 | PacketUtils.setOctet4(buffer, offset, this.getLMSseqNumber());
63 | // adding session size
64 | PacketUtils.setOctet4(buffer, offset + 4, this.getSessionSize());
65 | // adding increase factor
66 | PacketUtils.setOctet2(buffer, offset + 8, this.getIncreaseFactor());
67 | // adding ReservedEnd
68 | PacketUtils.setOctet2(buffer, offset + 10, this.getReservedEnd());
69 | // adding Vector of IP addresses
70 |
71 | int len = 12;
72 | for (FTSGroupBlock group : groupList) {
73 | len += group.generate(buffer, offset+len);
74 | }
75 |
76 | // zbytek hlavicky zabere celkem ... bitu
77 | return len;
78 | }
79 |
80 | /**
81 | * Parsing FTS header values from buffer. <i>This method takes specific
82 | * number of bytes from buffer and parse them into FTS header values. </i>
83 | *
84 | * @param resultArray -
85 | * memory bytes for parsing the values
86 | * @param startPos -
87 | * starting position in resultArray
88 | * @param length -
89 | * length of header
90 | */
91 | @Override
92 | public int parse(byte[] resultArray, int startPos, int length)
93 | throws PacketParseException {
94 | int len = super.parse(resultArray, startPos, length);
95 | len += this.parseRestFTS(resultArray, startPos, length);
96 | return len;
97 | }
98 |
99 | private int parseRestFTS(byte[] buffer, int offset, int length)
100 | throws PacketParseException {
101 | this.setLMSseqNumber(PacketUtils.getOctet4(buffer, 4 + offset));
102 | this.setSessionSize(PacketUtils.getOctet4(buffer, 8 + offset));
103 | this.setIncreaseFactor(PacketUtils.getOctet2(buffer, 12 + offset));
104 | this.setReservedEnd(PacketUtils.getOctet2(buffer, 14 + offset));
105 | int len = 12;
106 | for (int i = 0; i < ((length - 12) / 16); i++) {
107 | FTSGroupBlock item = new FTSGroupBlock();
108 | len += item.parse(buffer, offset + len, length);
109 | this.addGroupBlock(item);
110 | }
111 | return len;
112 | }
113 |
114 | public long getLMSseqNumber() {
115 | return LMSseqNumber;
116 | }
117 |
118 | public void setLMSseqNumber(long sseqNumber) {
119 | LMSseqNumber = sseqNumber;
120 | }
121 |
122 | public long getSessionSize() {
123 | return sessionSize;
124 | }
125 |
126 | public void setSessionSize(long sessionSize) {
127 | this.sessionSize = sessionSize;
128 | }
129 |
130 | public long getIncreaseFactor() {
131 | return increaseFactor;
132 | }
133 |
134 | public void setIncreaseFactor(long increaseFactor) {
135 | this.increaseFactor = increaseFactor;
136 | }
137 |
138 | public long getReservedEnd() {
139 | return reservedEnd;
140 | }
141 |
142 | public void setReservedEnd(long reservedEnd) {
143 | this.reservedEnd = reservedEnd;
144 | }
145 |
146 | /**
147 | * @see java.lang.Object#toString()
148 | */
149 | public String toString() {
150 | return new ToStringBuilder(this).append("version", this.getVersion())
151 | .append("padding", this.getPadding()).append("reservedEnd",
152 | this.reservedEnd).append("sessionSize",
153 | this.sessionSize).append("packetType",
154 | this.getPacketType()).append("LMSseqNumber",
155 | this.LMSseqNumber).append("length", this.getLength())
156 | .append("increaseFactor", this.increaseFactor).append(
157 | "feedbackTreeId", this.getFeedbackTreeId()).toString();
158 | }
159 |
160 | /**
161 | * @see java.lang.Object#equals(Object)
162 | */
163 | public boolean equals(Object object) {
164 | if (!(object instanceof FTSPacket)) {
165 | return false;
166 | }
167 | FTSPacket rhs = (FTSPacket) object;
168 | return new EqualsBuilder().appendSuper(super.equals(object)).append(
169 | this.groupList, rhs.groupList).append(this.increaseFactor,
170 | rhs.increaseFactor).append(this.sessionSize, rhs.sessionSize)
171 | .append(this.LMSseqNumber, rhs.LMSseqNumber).append(
172 | this.reservedEnd, rhs.reservedEnd).isEquals();
173 | }
174 |
175 | /**
176 | * @see java.lang.Object#hashCode()
177 | */
178 | public int hashCode() {
179 | return new HashCodeBuilder(-1169663993, -969153201).append(this.groupList).append(
180 | this.increaseFactor).append(this.sessionSize).append(
181 | this.LMSseqNumber).append(this.reservedEnd).toHashCode();
182 | }
183 |
184 | }

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