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

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

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
LMSPacket.java | 100% (1/1) | 84% (16/19) | 69% (245/357) | 73% (49,6/68)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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