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

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

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
FTAPacket.java | 100% (1/1) | 96% (22/23) | 65% (249/385) | 74% (54,2/73)

### COVERAGE BREAKDOWN BY CLASS AND METHOD

name | class, % | method, % | block, % | line, %
--- | --- | --- | --- | ---
class FTAPacket | 100% (1/1) | 96% (22/23) | 65% (249/385) | 74% (54,2/73)
toString (): String |  | 0% (0/1) | 0% (0/58) | 0% (0/12)
generateRestFTA (byte [], int): int |  | 100% (1/1) | 52% (82/159) | 61% (10,3/17)
<static initializer> |  | 100% (1/1) | 88% (7/8) | 87% (0,9/1)
FTAPacket (): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
generate (byte [], int): int |  | 100% (1/1) | 100% (16/16) | 100% (3/3)
getFeedBackSize (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getFeedbackGroupSize (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getParameters (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getPriority (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getReserved (): int |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getReservedEnd (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getSessionInformationIP (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
getSessionPort (): long |  | 100% (1/1) | 100% (3/3) | 100% (1/1)
parse (byte [], int, int): int |  | 100% (1/1) | 100% (16/16) | 100% (3/3)
parseRestFTA (byte [], int, int): int |  | 100% (1/1) | 100% (68/68) | 100% (11/11)
setFeedBackSize (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setFeedbackGroupSize (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setParameters (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setPriority (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setReserved (int): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setReservedEnd (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setSessionInformationIP (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)
setSessionPort (long): void |  | 100% (1/1) | 100% (4/4) | 100% (2/2)

1 | package cz.vutbr.feec.packets.ttp;
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 FTAPacket extends GeneralTTPHeader {
9 |
10 | private int feedbackGroupSize;
11 | private int priority;
12 | private int feedbackSize;
13 | private int parameters;
14 | private int reserved;
15 | private long sessionInformationIP;
16 | private long sessionPort;
17 | private long reservedEnd;
18 |
19 |
20 | public FTAPacket() {
21 | super(1);
22 | }
23 | /**
24 | * Generate buffer of values in FTA header. <i>This method generates
25 | * specific size of bytes into the buffer.</i>
26 | * @param resultArray - memory bytes for generating buffer
27 | * @param startPos - starting position in resultArray
28 | */
29 | @Override
30 | public int generate(byte[] resultArray, int startPos)
31 | throws PacketGenerateException {
32 | int length = super.generate(resultArray, startPos);
33 | length += generateRestFTA(resultArray, startPos+length);
34 | return length;
35 | }
36 |
37 | private int generateRestFTA(byte[] buffer, int offset){
38 | assert PacketUtils.checkSize(this.getFeedbackGroupSize(), 16);
39 | assert PacketUtils.checkSize(this.getPriority(), 3);
40 | assert PacketUtils.checkSize(this.getFeedBackSize(), 5);
41 | assert PacketUtils.checkSize(this.getParameters(), 4);
42 | assert PacketUtils.checkSize(this.getReserved(), 4);
43 | assert PacketUtils.checkSize(this.getSessionInformationIP(), 32);
44 | assert PacketUtils.checkSize(this.getSessionInformationIP(), 16);
45 | assert PacketUtils.checkSize(this.getReservedEnd(), 16);
46 |
47 | //adding Feedback group size to buffer
48 |
49 | PacketUtils.setOctet2(buffer, offset, this.getFeedbackGroupSize());
50 | //adding Priority and Feedback size
51 | byte Pri_Fsize = (byte) ( ((this.getPriority() << 5) & 0xE0) | (this.getFeedBackSize() & 0x1F) );
52 |
53 | buffer[offset+2] = Pri_Fsize;
54 |
55 | //adding Priority and Feedback size
56 | byte Par_Res = (byte) (((this.getParameters() << 4) & 0xF0 )| (this.getReserved() & 0x0F));
57 |
58 | buffer[offset+3] = Par_Res;
59 |
60 | PacketUtils.setOctet4(buffer, offset + 4, this.getSessionInformationIP());
61 |
62 | PacketUtils.setOctet2(buffer, offset+8, this.getSessionPort());
63 |
64 | PacketUtils.setOctet2(buffer, offset+10, this.getReservedEnd());
65 | // zbytek hlavicky zabere celkem 96 bitu
66 | // rest of the header takes 96 bits
67 | return 3*4;
68 | }
69 | /**
70 | * Parsing FTA header values from buffer. <i>This method takes specific
71 | * number of bytes from buffer and parse them into FTA header values. </i>
72 | * @param resultArray - memory bytes for parsing the values
73 | * @param startPos - starting position in resultArray
74 | * @param length - length of header
75 | */
76 | @Override
77 | public int parse(byte[] resultArray, int startPos, int length)
78 | throws PacketParseException {
79 | int len = super.parse(resultArray, startPos, length);
80 | len += this.parseRestFTA(resultArray, startPos, length);
81 | return len;
82 | }
83 |
84 |
85 | private int parseRestFTA(byte[] resultArray, int startPos, int length) throws PacketParseException{
86 |
87 | this.setFeedbackGroupSize(PacketUtils.getOctet2(resultArray, 4 + startPos));
88 | int second = PacketUtils.getOctet1(resultArray, 6 + startPos);
89 | this.setPriority((second & 0xE0)>>5);
90 | this.setFeedBackSize(second & 0x1F);
91 | second = PacketUtils.getOctet1(resultArray, 7 + startPos);
92 | this.setParameters((second & 0xF0)>>4);
93 | this.setReserved(second & 0x0F);
94 |
95 | this.setSessionInformationIP(PacketUtils.getOctet4(resultArray, 8 + startPos));
96 |
97 | this.setSessionPort(PacketUtils.getOctet2(resultArray, 12 + startPos));
98 | this.setReservedEnd(PacketUtils.getOctet2(resultArray, 14 + startPos));
99 |
100 | return 3*4;
101 | }
102 |
103 | public void setFeedbackGroupSize (int fbgs){
104 | this.feedbackGroupSize = fbgs;
105 | }
106 |
107 | public int getFeedbackGroupSize (){
108 | return this.feedbackGroupSize;
109 | }
110 |
111 | public void setPriority (int prior) {
112 | this.priority = prior;
113 | }
114 |
115 | public int getPriority () {
116 | return this.priority;
117 | }
118 |
119 | public void setFeedBackSize (int fbs) {
120 | this.feedbackSize = fbs;
121 | }
122 |
123 | public int getFeedBackSize () {
124 | return this.feedbackSize;
125 | }
126 |
127 | public void setParameters (int param) {
128 | this.parameters = param;
129 | }
130 |
131 | public int getParameters () {
132 | return this.parameters;
133 | }
134 |
135 | public void setReserved (int rsrvd) {
136 | this.reserved = rsrvd;
137 | }
138 |
139 | public int getReserved () {
140 | return this.reserved;
141 | }
142 |
143 | public void setSessionInformationIP (long siip){
144 | this.sessionInformationIP = siip;
145 | }
146 |
147 | public long getSessionInformationIP (){
148 | return this.sessionInformationIP;
149 | }
150 |
151 | public void setSessionPort (long sprt){
152 | this.sessionPort = sprt;
153 | }
154 |
155 | public long getSessionPort (){
156 | return this.sessionPort;
157 | }
158 |
159 | public void setReservedEnd (long rsrvdend){
160 | this.reservedEnd = rsrvdend;
161 | }
162 |
163 | public long getReservedEnd (){
164 | return this.reservedEnd;
165 | }
166 | /**
167 | * @see java.lang.Object#toString()
168 | */
169 | public String toString() {
170 | return new ToStringBuilder(this).append("sessionInformationIP",
171 | this.sessionInformationIP).append("padding", this.getPadding())
172 | .append("reservedEnd", this.reservedEnd).append("sessionPort",
173 | this.sessionPort).append("feedbackTreeId",
174 | this.getFeedbackTreeId()).append("parameters",
175 | this.parameters).append("feedBackSize",
176 | this.getFeedBackSize()).append("version",
177 | this.getVersion()).append("priority", this.priority)
178 | .append("reserved", this.reserved).append("packetType",
179 | this.getPacketType())
180 | .append("length", this.getLength()).append("feedbackGroupSize",
181 | this.feedbackGroupSize).toString();
182 | }
183 |
184 | }

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