1 | /* | |
2 | * Copyright 2006 - 2013 | |
3 | * Stefan Balev <stefan.balev@graphstream-project.org> | |
4 | * Julien Baudry <julien.baudry@graphstream-project.org> | |
5 | * Antoine Dutot <antoine.dutot@graphstream-project.org> | |
6 | * Yoann Pign�� <yoann.pigne@graphstream-project.org> | |
7 | * Guilhelm Savin <guilhelm.savin@graphstream-project.org> | |
8 | * | |
9 | * This file is part of GraphStream <http://graphstream-project.org>. | |
10 | * | |
11 | * GraphStream is a library whose purpose is to handle static or dynamic | |
12 | * graph, create them from scratch, file or any source and display them. | |
13 | * | |
14 | * This program is free software distributed under the terms of two licenses, the | |
15 | * CeCILL-C license that fits European law, and the GNU Lesser General Public | |
16 | * License. You can use, modify and/ or redistribute the software under the terms | |
17 | * of the CeCILL-C license as circulated by CEA, CNRS and INRIA at the following | |
18 | * URL <http://www.cecill.info> or under the terms of the GNU LGPL as published by | |
19 | * the Free Software Foundation, either version 3 of the License, or (at your | |
20 | * option) any later version. | |
21 | * | |
22 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
23 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
24 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | |
25 | * | |
26 | * You should have received a copy of the GNU Lesser General Public License | |
27 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
28 | * | |
29 | * The fact that you are presently reading this means that you have had | |
30 | * knowledge of the CeCILL-C and LGPL licenses and that you accept their terms. | |
31 | */ | |
32 | package org.graphstream.stream.netstream; | |
33 | ||
34 | import java.io.BufferedOutputStream; | |
35 | import java.io.IOException; | |
36 | import java.net.Socket; | |
37 | import java.net.UnknownHostException; | |
38 | import java.nio.ByteBuffer; | |
39 | import java.nio.charset.Charset; | |
40 | ||
41 | import org.graphstream.stream.Sink; | |
42 | import org.graphstream.stream.netstream.packing.NetStreamPacker; | |
43 | ||
44 | import com.sun.org.apache.xalan.internal.xsltc.compiler.sym; | |
45 | ||
46 | /** | |
47 | * <p> | |
48 | * This class implements a sender according to specifications the NetStream | |
49 | * protocol. | |
50 | * </p> | |
51 | * | |
52 | * <p> | |
53 | * See {@link NetStreamConstants} for a full description of the protocol, the | |
54 | * sender and the receiver. | |
55 | * </p> | |
56 | * | |
57 | * @see NetStreamConstants | |
58 | * @see NetStreamReceiver | |
59 | * | |
60 | * | |
61 | * Copyright (c) 2010 University of Luxembourg | |
62 | * | |
63 | * NetStreamSender.java | |
64 | * @since Aug 10, 2011 | |
65 | * | |
66 | * @author Yoann Pign�� | |
67 | * | |
68 | */ | |
69 | public class NetStreamSender implements Sink { | |
70 | private static ByteBuffer NULL_BUFFER = ByteBuffer.allocate(0); | |
71 | | |
72 | protected String stream; | |
73 | protected ByteBuffer streamBuffer; | |
74 | byte[] streamIdArray; | |
75 | protected String host; | |
76 | protected int port; | |
77 | protected Socket socket; | |
78 | protected BufferedOutputStream out; | |
79 | ||
80 | protected String sourceId = ""; | |
81 | protected ByteBuffer sourceIdBuff; | |
82 | ||
83 | class DefaultPacker extends NetStreamPacker { | |
84 | ByteBuffer sizeBuffer = ByteBuffer.allocate(4); | |
85 | ||
86 | @Override | |
87 | public ByteBuffer packMessage(ByteBuffer buffer, int startIndex, | |
88 | int endIndex) { | |
89 |
1
1. packMessage : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender$DefaultPacker::packMessage to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return buffer; |
90 | } | |
91 | ||
92 | @Override | |
93 | public ByteBuffer packMessageSize(int capacity) { | |
94 | sizeBuffer.rewind(); | |
95 | sizeBuffer.putInt(capacity); | |
96 |
1
1. packMessageSize : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender$DefaultPacker::packMessageSize to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return sizeBuffer; |
97 | } | |
98 | ||
99 | }; | |
100 | ||
101 | protected NetStreamPacker packer = new DefaultPacker(); | |
102 | ||
103 | public NetStreamSender(String host, int port) throws UnknownHostException, | |
104 | IOException { | |
105 | this("default", host, port); | |
106 | } | |
107 | public NetStreamSender(int port) throws UnknownHostException, IOException { | |
108 | this("default", "localhost", port); | |
109 | } | |
110 | ||
111 | public NetStreamSender(String stream, String host, int port) | |
112 | throws UnknownHostException, IOException { | |
113 | this.stream = stream; | |
114 | this.host = host; | |
115 | this.port = port; | |
116 |
1
1. |
setStream(stream); |
117 | | |
118 |
1
1. |
connect(); |
119 | | |
120 | } | |
121 | | |
122 | /** | |
123 | * @param stream2 | |
124 | */ | |
125 | public void setStream(String stream) { | |
126 | streamIdArray = stream.getBytes(Charset.forName("UTF-8")); | |
127 | streamBuffer = encodeString(stream); | |
128 | | |
129 | | |
130 | } | |
131 | public NetStreamSender(Socket socket) throws IOException { | |
132 | this("default", socket); | |
133 | } | |
134 | | |
135 | public NetStreamSender(String stream, Socket socket) throws IOException { | |
136 | this.host = socket.getInetAddress().getHostName(); | |
137 | this.port = socket.getPort(); | |
138 | this.socket = socket; | |
139 | this.out = new BufferedOutputStream(socket.getOutputStream()); | |
140 | this.streamIdArray = stream.getBytes(Charset.forName("UTF-8")); | |
141 | } | |
142 | ||
143 | /** | |
144 | * Sets an optional NetStreamPaker whose "pack" method will be called on | |
145 | * each message. | |
146 | * | |
147 | * a Packer can do extra encoding on the all byte array message, it may also | |
148 | * crypt things. | |
149 | * | |
150 | * @param paker | |
151 | * The packer object | |
152 | */ | |
153 | public void setPacker(NetStreamPacker paker) { | |
154 | this.packer = paker; | |
155 | } | |
156 | public void removePacker() { | |
157 | packer = new DefaultPacker(); | |
158 | } | |
159 | ||
160 | protected void connect() throws UnknownHostException, IOException { | |
161 | ||
162 | socket = new Socket(host, port); | |
163 | out = new BufferedOutputStream(socket.getOutputStream()); | |
164 | ||
165 | } | |
166 | ||
167 | protected int getType(Object value) { | |
168 | int valueType = NetStreamConstants.TYPE_UNKNOWN; | |
169 | | |
170 |
1
1. getType : negated conditional → NO_COVERAGE |
if (value == null) |
171 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return NetStreamConstants.TYPE_NULL; |
172 | | |
173 | Class<?> valueClass = value.getClass(); | |
174 | boolean isArray = valueClass.isArray(); | |
175 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
176 | valueClass = ((Object[]) value)[0].getClass(); | |
177 | } | |
178 |
1
1. getType : negated conditional → NO_COVERAGE |
if (valueClass.equals(Boolean.class)) { |
179 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
180 | valueType = NetStreamConstants.TYPE_BOOLEAN_ARRAY; | |
181 | } else { | |
182 | valueType = NetStreamConstants.TYPE_BOOLEAN; | |
183 | } | |
184 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Byte.class)) { |
185 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
186 | valueType = NetStreamConstants.TYPE_BYTE_ARRAY; | |
187 | } else { | |
188 | valueType = NetStreamConstants.TYPE_BYTE; | |
189 | } | |
190 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Short.class)) { |
191 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
192 | valueType = NetStreamConstants.TYPE_SHORT_ARRAY; | |
193 | } else { | |
194 | valueType = NetStreamConstants.TYPE_SHORT; | |
195 | } | |
196 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Integer.class)) { |
197 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
198 | valueType = NetStreamConstants.TYPE_INT_ARRAY; | |
199 | } else { | |
200 | valueType = NetStreamConstants.TYPE_INT; | |
201 | } | |
202 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Long.class)) { |
203 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
204 | valueType = NetStreamConstants.TYPE_LONG_ARRAY; | |
205 | } else { | |
206 | valueType = NetStreamConstants.TYPE_LONG; | |
207 | } | |
208 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Float.class)) { |
209 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
210 | valueType = NetStreamConstants.TYPE_FLOAT_ARRAY; | |
211 | } else { | |
212 | valueType = NetStreamConstants.TYPE_FLOAT; | |
213 | } | |
214 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(Double.class)) { |
215 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
216 | valueType = NetStreamConstants.TYPE_DOUBLE_ARRAY; | |
217 | } else { | |
218 | valueType = NetStreamConstants.TYPE_DOUBLE; | |
219 | } | |
220 |
1
1. getType : negated conditional → NO_COVERAGE |
} else if (valueClass.equals(String.class)) { |
221 |
1
1. getType : negated conditional → NO_COVERAGE |
if (isArray) { |
222 | valueType = NetStreamConstants.TYPE_ARRAY; | |
223 | } else { | |
224 | valueType = NetStreamConstants.TYPE_STRING; | |
225 | } | |
226 | } else | |
227 | System.err.printf("[warning] can not find type of %s\n", valueClass); | |
228 | // System.out.println("ValueType="+valueType+" "+value.getClass()); | |
229 |
1
1. getType : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return valueType; |
230 | } | |
231 | | |
232 | protected ByteBuffer encodeValue(Object in, int valueType) { | |
233 | ||
234 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
if (NetStreamConstants.TYPE_BOOLEAN == valueType) { |
235 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeBoolean(in); |
236 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_BOOLEAN_ARRAY == valueType) { |
237 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeBooleanArray(in); |
238 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_BYTE == valueType) { |
239 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeByte(in); |
240 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_BYTE_ARRAY == valueType) { |
241 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeByteArray(in); |
242 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_SHORT == valueType) { |
243 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeShort(in); |
244 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_SHORT_ARRAY == valueType) { |
245 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeShortArray(in); |
246 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_INT == valueType) { |
247 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeInt(in); |
248 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_INT_ARRAY == valueType) { |
249 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeIntArray(in); |
250 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_LONG == valueType) { |
251 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeLong(in); |
252 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_LONG_ARRAY == valueType) { |
253 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeLongArray(in); |
254 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_FLOAT == valueType) { |
255 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeFloat(in); |
256 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_FLOAT_ARRAY == valueType) { |
257 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeFloatArray(in); |
258 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_DOUBLE == valueType) { |
259 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeDouble(in); |
260 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_DOUBLE_ARRAY == valueType) { |
261 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeDoubleArray(in); |
262 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_STRING == valueType) { |
263 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeString(in); |
264 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_ARRAY == valueType) { |
265 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeArray(in); |
266 |
1
1. encodeValue : negated conditional → NO_COVERAGE |
} else if (NetStreamConstants.TYPE_NULL == valueType) { |
267 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return NULL_BUFFER; |
268 | } | |
269 | | |
270 | System.err.printf("[warning] unknown value type %d\n", valueType); | |
271 | | |
272 |
1
1. encodeValue : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
273 | } | |
274 | ||
275 | /** | |
276 | * @param in | |
277 | * @return | |
278 | */ | |
279 | protected ByteBuffer encodeArray(Object in) { | |
280 | // TODO... | |
281 |
1
1. encodeArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return null; |
282 | } | |
283 | ||
284 | private void outBuffer(ByteBuffer buf){ | |
285 |
1
1. outBuffer : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println(buf.toString()); |
286 | int nbytes = buf.capacity(); | |
287 | int at = buf.position(); | |
288 |
3
1. outBuffer : changed conditional boundary → NO_COVERAGE 2. outBuffer : Changed increment from 1 to -1 → NO_COVERAGE 3. outBuffer : negated conditional → NO_COVERAGE |
for(int i=0; i< nbytes; i++){ |
289 |
1
1. outBuffer : Replaced integer addition with subtraction → NO_COVERAGE |
int bt = buf.get(at+i); |
290 |
5
1. outBuffer : changed conditional boundary → NO_COVERAGE 2. outBuffer : Replaced bitwise AND with OR → NO_COVERAGE 3. outBuffer : Replaced bitwise AND with OR → NO_COVERAGE 4. outBuffer : Replaced integer addition with subtraction → NO_COVERAGE 5. outBuffer : negated conditional → NO_COVERAGE |
if (bt < 0) bt = (bt & 127) + (bt & 128); |
291 | System.out.printf("%d ", bt); | |
292 | } | |
293 |
1
1. outBuffer : removed call to java/io/PrintStream::println → NO_COVERAGE |
System.out.println(); |
294 | } | |
295 | | |
296 | /** | |
297 | * @param in | |
298 | * @return | |
299 | */ | |
300 | protected ByteBuffer encodeString(Object in) { | |
301 | //System.out.println("They want me to encode this string: "+in); | |
302 | String s = (String) in; | |
303 | byte[] data = s.getBytes(Charset.forName("UTF-8")); | |
304 | | |
305 | ByteBuffer lenBuff = encodeUnsignedVarint(data.length); | |
306 | //outBuffer(lenBuff); | |
307 |
1
1. encodeString : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer bb = ByteBuffer.allocate(lenBuff.capacity() + data.length); |
308 | bb.put(lenBuff).put(data); | |
309 | bb.rewind(); | |
310 | //outBuffer(bb); | |
311 | | |
312 |
1
1. encodeString : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeString to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return bb; |
313 | } | |
314 | ||
315 | /** | |
316 | * @param in | |
317 | * @return | |
318 | */ | |
319 | protected ByteBuffer encodeDoubleArray(Object in) { | |
320 | Object[] data = (Object[]) in; | |
321 | ||
322 | int ssize = varintSize(data.length); | |
323 | | |
324 |
2
1. encodeDoubleArray : Replaced integer multiplication with division → NO_COVERAGE 2. encodeDoubleArray : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer b = ByteBuffer.allocate(ssize + data.length * 8); |
325 | ||
326 |
1
1. encodeDoubleArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, data.length, ssize); |
327 | ||
328 |
3
1. encodeDoubleArray : changed conditional boundary → NO_COVERAGE 2. encodeDoubleArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeDoubleArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
329 | b.putDouble((Double) data[i]); | |
330 | } | |
331 | b.rewind(); | |
332 |
1
1. encodeDoubleArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeDoubleArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
333 | } | |
334 | ||
335 | /** | |
336 | * @param in The double to encode | |
337 | * @return ByteBuffer with encoded double in it | |
338 | */ | |
339 | protected ByteBuffer encodeDouble(Object in) { | |
340 |
1
1. encodeDouble : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeDouble to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return ByteBuffer.allocate(8).putDouble((Double) in); |
341 | } | |
342 | ||
343 | /** | |
344 | * @param in The float array to encode | |
345 | * @return ByteBuffer with encoded float array in it | |
346 | */ | |
347 | protected ByteBuffer encodeFloatArray(Object in) { | |
348 | Object[] data = (Object[]) in; | |
349 | | |
350 | int ssize = varintSize(data.length); | |
351 | | |
352 |
2
1. encodeFloatArray : Replaced integer multiplication with division → NO_COVERAGE 2. encodeFloatArray : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer b = ByteBuffer.allocate(ssize + data.length * 4); |
353 | | |
354 |
1
1. encodeFloatArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, data.length, ssize); |
355 | ||
356 |
3
1. encodeFloatArray : changed conditional boundary → NO_COVERAGE 2. encodeFloatArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeFloatArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
357 | b.putFloat((Float) data[i]); | |
358 | } | |
359 | b.rewind(); | |
360 |
1
1. encodeFloatArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeFloatArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
361 | } | |
362 | ||
363 | /** | |
364 | * @param in The float to encode | |
365 | * @return ByteBuffer with encoded float in it | |
366 | */ | |
367 | protected ByteBuffer encodeFloat(Object in) { | |
368 | ByteBuffer b = ByteBuffer.allocate(4); | |
369 | b.putFloat(((Float) in)); | |
370 | b.rewind(); | |
371 |
1
1. encodeFloat : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeFloat to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
372 | } | |
373 | ||
374 | /** | |
375 | * @param in The long array to encode | |
376 | * @return ByteBuffer with encoded long array in it | |
377 | */ | |
378 | protected ByteBuffer encodeLongArray(Object in) { | |
379 |
1
1. encodeLongArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeLongArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarintArray(in); |
380 | } | |
381 | ||
382 | /** | |
383 | * @param in The long to encode | |
384 | * @return ByteBuffer with encoded long in it | |
385 | */ | |
386 | protected ByteBuffer encodeLong(Object in) { | |
387 |
1
1. encodeLong : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeLong to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarint(in); |
388 | } | |
389 | ||
390 | /** | |
391 | * @param in The integer array to encode | |
392 | * @return ByteBuffer with encoded integer array in it | |
393 | */ | |
394 | protected ByteBuffer encodeIntArray(Object in) { | |
395 |
1
1. encodeIntArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeIntArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarintArray(in); |
396 | } | |
397 | ||
398 | /** | |
399 | * @param in The integer to encode | |
400 | * @return ByteBuffer with encoded integer in it | |
401 | */ | |
402 | protected ByteBuffer encodeInt(Object in) { | |
403 |
1
1. encodeInt : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeInt to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarint(in); |
404 | } | |
405 | ||
406 | /** | |
407 | * @param in | |
408 | * @return | |
409 | */ | |
410 | protected ByteBuffer encodeShortArray(Object in) { | |
411 |
1
1. encodeShortArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeShortArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarintArray(in); |
412 | } | |
413 | ||
414 | /** | |
415 | * @param in | |
416 | * @return | |
417 | */ | |
418 | protected ByteBuffer encodeShort(Object in) { | |
419 |
1
1. encodeShort : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeShort to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeVarint(in); |
420 | } | |
421 | ||
422 | /** | |
423 | * @param in | |
424 | * @return | |
425 | */ | |
426 | protected ByteBuffer encodeByteArray(Object in) { | |
427 | Object[] data = (Object[]) in; | |
428 | ||
429 | int ssize = varintSize(data.length); | |
430 | | |
431 |
1
1. encodeByteArray : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer b = ByteBuffer.allocate(ssize + data.length); |
432 | | |
433 |
1
1. encodeByteArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, data.length, ssize); |
434 | ||
435 |
3
1. encodeByteArray : changed conditional boundary → NO_COVERAGE 2. encodeByteArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeByteArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
436 | b.put((Byte) data[i]); | |
437 | } | |
438 | b.rewind(); | |
439 |
1
1. encodeByteArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeByteArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
440 | } | |
441 | ||
442 | /** | |
443 | * @param in | |
444 | * @return | |
445 | */ | |
446 | protected ByteBuffer encodeByte(Object in) { | |
447 | ByteBuffer b = ByteBuffer.allocate(1); | |
448 | b.put(((Byte) in)); | |
449 | b.rewind(); | |
450 |
1
1. encodeByte : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeByte to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
451 | } | |
452 | ||
453 | /** | |
454 | * @param in | |
455 | * @return | |
456 | */ | |
457 | protected ByteBuffer encodeBooleanArray(Object in) { | |
458 | Object[] data = (Object[]) in; | |
459 | ||
460 | int ssize = varintSize(data.length); | |
461 | | |
462 |
1
1. encodeBooleanArray : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer b = ByteBuffer.allocate(ssize + data.length); |
463 | | |
464 |
1
1. encodeBooleanArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, data.length, ssize); |
465 | ||
466 |
3
1. encodeBooleanArray : changed conditional boundary → NO_COVERAGE 2. encodeBooleanArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeBooleanArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
467 |
1
1. encodeBooleanArray : negated conditional → NO_COVERAGE |
b.put((byte) ((Boolean) data[i] == false ? 0 : 1)); |
468 | } | |
469 | b.rewind(); | |
470 |
1
1. encodeBooleanArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeBooleanArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
471 | } | |
472 | ||
473 | /** | |
474 | * @param in | |
475 | * @return | |
476 | */ | |
477 | protected ByteBuffer encodeBoolean(Object in) { | |
478 | ByteBuffer b = ByteBuffer.allocate(1); | |
479 |
1
1. encodeBoolean : negated conditional → NO_COVERAGE |
b.put((byte) (((Boolean) in) == false ? 0 : 1)); |
480 | b.rewind(); | |
481 |
1
1. encodeBoolean : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeBoolean to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
482 | } | |
483 | ||
484 | private int varintSize(long data){ | |
485 | | |
486 | // 7 bits -> 127 | |
487 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 7)){ |
488 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 1; |
489 | } | |
490 | | |
491 | // 14 bits -> 16383 | |
492 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 14)){ |
493 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 2; |
494 | } | |
495 | | |
496 | // 21 bits -> 2097151 | |
497 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 21)){ |
498 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 3; |
499 | } | |
500 | | |
501 | // 28 bits -> 268435455 | |
502 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 28)){ |
503 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 4; |
504 | } | |
505 | ||
506 | // 35 bits -> 34359738367 | |
507 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 35)){ |
508 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 5; |
509 | } | |
510 | ||
511 | // 42 bits -> 4398046511103 | |
512 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 42)){ |
513 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 6; |
514 | } | |
515 | | |
516 | // 49 bits -> 562949953421311 | |
517 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 49)){ |
518 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 7; |
519 | } | |
520 | | |
521 | // 56 bits -> 72057594037927935 | |
522 |
2
1. varintSize : changed conditional boundary → NO_COVERAGE 2. varintSize : negated conditional → NO_COVERAGE |
if(data < (1L << 56)){ |
523 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 8; |
524 | } | |
525 | | |
526 |
1
1. varintSize : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return 9; |
527 | } | |
528 | /** | |
529 | * @param in | |
530 | * @return | |
531 | */ | |
532 | protected ByteBuffer encodeVarint(Object in) { | |
533 | long data = ((Number)in).longValue(); | |
534 | | |
535 | // signed integers encoding | |
536 | // (n << 1) ^ (n >> 31) | |
537 | // OK but java's negative values are two's complements... | |
538 | | |
539 |
6
1. encodeVarint : changed conditional boundary → NO_COVERAGE 2. encodeVarint : Replaced Shift Left with Shift Right → NO_COVERAGE 3. encodeVarint : Replaced Shift Left with Shift Right → NO_COVERAGE 4. encodeVarint : Replaced XOR with AND → NO_COVERAGE 5. encodeVarint : negated conditional → NO_COVERAGE 6. encodeVarint : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeVarint to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return encodeUnsignedVarint(data>=0?(data<<1):((Math.abs(data) << 1) ^ 1)); |
540 | } | |
541 | ||
542 | /** | |
543 | * @param in | |
544 | * @return | |
545 | */ | |
546 | protected ByteBuffer encodeVarintArray(Object in) { | |
547 | Object[] data = (Object[]) in; | |
548 | int[] sizes = new int[data.length]; | |
549 | long[] zigzags = new long[data.length]; | |
550 | int sumsizes=0; | |
551 |
3
1. encodeVarintArray : changed conditional boundary → NO_COVERAGE 2. encodeVarintArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeVarintArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
552 | long datum = ((Number)data[i]).longValue(); | |
553 | // signed integers encoding | |
554 | // (n << 1) ^ (n >> 31) | |
555 | // OK but java's negative values are two's complements... | |
556 |
5
1. encodeVarintArray : changed conditional boundary → NO_COVERAGE 2. encodeVarintArray : Replaced Shift Left with Shift Right → NO_COVERAGE 3. encodeVarintArray : Replaced Shift Left with Shift Right → NO_COVERAGE 4. encodeVarintArray : Replaced XOR with AND → NO_COVERAGE 5. encodeVarintArray : negated conditional → NO_COVERAGE |
zigzags[i] = datum>0?(datum<<1):((Math.abs(datum) << 1) ^ 1); |
557 | | |
558 | sizes[i] = varintSize(zigzags[i]); | |
559 |
1
1. encodeVarintArray : Replaced integer addition with subtraction → NO_COVERAGE |
sumsizes+=sizes[i]; |
560 | //System.out.printf("i=%d, zigzag=%d, size=%d\n",i, zigzags[i], sizes[i]); | |
561 | } | |
562 | | |
563 | // the size of the size! | |
564 | int ssize = varintSize(data.length); | |
565 | | |
566 |
1
1. encodeVarintArray : Replaced integer addition with subtraction → NO_COVERAGE |
ByteBuffer b = ByteBuffer.allocate(ssize + sumsizes); |
567 | | |
568 |
1
1. encodeVarintArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, data.length, ssize); |
569 | | |
570 |
3
1. encodeVarintArray : changed conditional boundary → NO_COVERAGE 2. encodeVarintArray : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeVarintArray : negated conditional → NO_COVERAGE |
for (int i = 0; i < data.length; i++) { |
571 |
1
1. encodeVarintArray : removed call to org/graphstream/stream/netstream/NetStreamSender::putVarint → NO_COVERAGE |
putVarint(b, zigzags[i], sizes[i]); |
572 | } | |
573 | b.rewind(); | |
574 | //outBuffer(b); | |
575 |
1
1. encodeVarintArray : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeVarintArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return b; |
576 | } | |
577 | | |
578 | /** | |
579 | * @param in | |
580 | * @return | |
581 | */ | |
582 | protected ByteBuffer encodeUnsignedVarint(Object in) { | |
583 | long data = ((Number)in).longValue(); | |
584 | | |
585 | int size = varintSize(data); | |
586 | | |
587 | ByteBuffer buff = ByteBuffer.allocate(size); | |
588 |
3
1. encodeUnsignedVarint : changed conditional boundary → NO_COVERAGE 2. encodeUnsignedVarint : Changed increment from 1 to -1 → NO_COVERAGE 3. encodeUnsignedVarint : negated conditional → NO_COVERAGE |
for(int i = 0; i < size; i++){ |
589 | int head=128; | |
590 |
2
1. encodeUnsignedVarint : Replaced integer subtraction with addition → NO_COVERAGE 2. encodeUnsignedVarint : negated conditional → NO_COVERAGE |
if(i==size-1) head = 0; |
591 |
4
1. encodeUnsignedVarint : Replaced integer multiplication with division → NO_COVERAGE 2. encodeUnsignedVarint : Replaced Shift Right with Shift Left → NO_COVERAGE 3. encodeUnsignedVarint : Replaced bitwise AND with OR → NO_COVERAGE 4. encodeUnsignedVarint : Replaced XOR with AND → NO_COVERAGE |
long b = ((data >> (7*i)) & 127) ^ head; |
592 |
1
1. encodeUnsignedVarint : Replaced bitwise AND with OR → NO_COVERAGE |
buff.put((byte)(b & 255 )); |
593 | } | |
594 | buff.rewind(); | |
595 |
1
1. encodeUnsignedVarint : mutated return of Object value for org/graphstream/stream/netstream/NetStreamSender::encodeUnsignedVarint to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return buff; |
596 | } | |
597 | ||
598 | | |
599 | /** | |
600 | * @param b | |
601 | * @param sumsizes | |
602 | * @param ssize | |
603 | */ | |
604 | private void putVarint(ByteBuffer buffer, long number, int byteSize) { | |
605 |
3
1. putVarint : changed conditional boundary → NO_COVERAGE 2. putVarint : Changed increment from 1 to -1 → NO_COVERAGE 3. putVarint : negated conditional → NO_COVERAGE |
for(int i = 0; i < byteSize; i++){ |
606 | int head=128; | |
607 |
2
1. putVarint : Replaced integer subtraction with addition → NO_COVERAGE 2. putVarint : negated conditional → NO_COVERAGE |
if(i==byteSize-1) head = 0; |
608 |
4
1. putVarint : Replaced integer multiplication with division → NO_COVERAGE 2. putVarint : Replaced Shift Right with Shift Left → NO_COVERAGE 3. putVarint : Replaced bitwise AND with OR → NO_COVERAGE 4. putVarint : Replaced XOR with AND → NO_COVERAGE |
long b = ((number >> (7*i)) & 127) ^ head; |
609 |
1
1. putVarint : Replaced bitwise AND with OR → NO_COVERAGE |
buffer.put((byte)(b & 255 )); |
610 | } | |
611 | } | |
612 | | |
613 | /** | |
614 | * @param buff | |
615 | */ | |
616 | private void doSend(ByteBuffer buff) { | |
617 | ||
618 |
1
1. doSend : negated conditional → NO_COVERAGE |
if (socket.isClosed()) { |
619 | System.err | |
620 |
1
1. doSend : removed call to java/io/PrintStream::println → NO_COVERAGE |
.println("NetStreamSender : can't send. The socket is closed."); |
621 | } else { | |
622 | buff.rewind(); | |
623 | //outBuffer(buff); | |
624 | ByteBuffer buffer = packer.packMessage(buff); | |
625 | ByteBuffer sizeBuffer = packer.packMessageSize(buffer.capacity()); | |
626 | | |
627 | // real sending | |
628 | try { | |
629 |
1
1. doSend : removed call to java/io/BufferedOutputStream::write → NO_COVERAGE |
out.write(sizeBuffer.array(), 0, sizeBuffer.capacity()); |
630 |
1
1. doSend : removed call to java/io/BufferedOutputStream::write → NO_COVERAGE |
out.write(buffer.array(), 0, buffer.capacity()); |
631 |
1
1. doSend : removed call to java/io/BufferedOutputStream::flush → NO_COVERAGE |
out.flush(); |
632 | } catch (IOException e) { | |
633 | try { | |
634 |
1
1. doSend : removed call to java/net/Socket::close → NO_COVERAGE |
socket.close(); |
635 | } catch (IOException e1) { | |
636 |
1
1. doSend : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e1.printStackTrace(); |
637 | } | |
638 | | |
639 | System.err.printf("socket error : %s\n", e.getMessage()); | |
640 | } | |
641 | } | |
642 | } | |
643 | ||
644 | /* | |
645 | * (non-Javadoc) | |
646 | * | |
647 | * @see | |
648 | * org.graphstream.stream.AttributeSink#graphAttributeAdded(java.lang.String | |
649 | * , long, java.lang.String, java.lang.Object) | |
650 | */ | |
651 | public void graphAttributeAdded(String sourceId, long timeId, | |
652 | String attribute, Object value) { | |
653 | ||
654 |
1
1. graphAttributeAdded : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
655 | this.sourceId = sourceId; | |
656 | sourceIdBuff = encodeString(sourceId); | |
657 | | |
658 | } | |
659 | ByteBuffer attrBuff = encodeString(attribute); | |
660 | int valueType = getType(value); | |
661 | ByteBuffer valueBuff = encodeValue(value, valueType); | |
662 | ByteBuffer buff = ByteBuffer.allocate( | |
663 |
6
1. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 2. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 3. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 4. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 5. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 6. graphAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
664 | 1 + // CMD | |
665 | sourceIdBuff.capacity() + // source id | |
666 | varintSize(timeId) + // timeId | |
667 | attrBuff.capacity() + // attribute id | |
668 | 1 + // attr type | |
669 | valueBuff.capacity()); // attr value | |
670 | | |
671 | streamBuffer.rewind(); | |
672 | sourceIdBuff.rewind(); | |
673 | buff | |
674 | .put(streamBuffer) | |
675 | .put((byte) NetStreamConstants.EVENT_ADD_GRAPH_ATTR) | |
676 | .put(sourceIdBuff) | |
677 | .put(encodeUnsignedVarint(timeId)) | |
678 | .put(attrBuff) | |
679 | .put((byte) valueType) | |
680 | .put(valueBuff); | |
681 | | |
682 |
1
1. graphAttributeAdded : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
683 | ||
684 | } | |
685 | ||
686 | /* | |
687 | * (non-Javadoc) | |
688 | * | |
689 | * @see | |
690 | * org.graphstream.stream.AttributeSink#graphAttributeChanged(java.lang. | |
691 | * String, long, java.lang.String, java.lang.Object, java.lang.Object) | |
692 | */ | |
693 | public void graphAttributeChanged(String sourceId, long timeId, | |
694 | String attribute, Object oldValue, Object newValue) { | |
695 | ||
696 |
1
1. graphAttributeChanged : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
697 | this.sourceId = sourceId; | |
698 | sourceIdBuff = encodeString(sourceId); | |
699 | } | |
700 | ByteBuffer attrBuff = encodeString(attribute); | |
701 | int oldValueType = getType(oldValue); | |
702 | int newValueType = getType(newValue); | |
703 | | |
704 | ByteBuffer oldValueBuff = encodeValue(oldValue, oldValueType); | |
705 | ByteBuffer newValueBuff = encodeValue(newValue, newValueType); | |
706 | | |
707 | | |
708 | ByteBuffer buff = ByteBuffer.allocate( | |
709 |
8
1. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 2. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 3. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 4. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 5. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 6. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 7. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 8. graphAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
710 | 1 + // CMD | |
711 | sourceIdBuff.capacity() + // source id | |
712 | varintSize(timeId) + // timeId | |
713 | attrBuff.capacity() + // attribute id | |
714 | 1 + // attr type | |
715 | oldValueBuff.capacity() + // attr value | |
716 | 1 + // attr type | |
717 | newValueBuff.capacity()); // attr value | |
718 | | |
719 | streamBuffer.rewind(); | |
720 | sourceIdBuff.rewind(); | |
721 | | |
722 | buff | |
723 | .put(streamBuffer) | |
724 | .put((byte) NetStreamConstants.EVENT_CHG_GRAPH_ATTR) | |
725 | .put(sourceIdBuff) | |
726 | .put(encodeUnsignedVarint(timeId)) | |
727 | .put(attrBuff) | |
728 | .put((byte) oldValueType) | |
729 | .put(oldValueBuff) | |
730 | .put((byte) newValueType) | |
731 | .put(newValueBuff); | |
732 | ||
733 |
1
1. graphAttributeChanged : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
734 | ||
735 | } | |
736 | ||
737 | /* | |
738 | * (non-Javadoc) | |
739 | * | |
740 | * @see | |
741 | * org.graphstream.stream.AttributeSink#graphAttributeRemoved(java.lang. | |
742 | * String, long, java.lang.String) | |
743 | */ | |
744 | public void graphAttributeRemoved(String sourceId, long timeId, | |
745 | String attribute) { | |
746 | ||
747 |
1
1. graphAttributeRemoved : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
748 | this.sourceId = sourceId; | |
749 | sourceIdBuff = encodeString(sourceId); | |
750 | } | |
751 | ByteBuffer attrBuff = encodeString(attribute); | |
752 | ||
753 | ByteBuffer buff = ByteBuffer.allocate( | |
754 |
4
1. graphAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 2. graphAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 3. graphAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 4. graphAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
755 | 1 + // CMD | |
756 | sourceIdBuff.capacity() + // source id | |
757 | varintSize(timeId) + // timeId | |
758 | attrBuff.capacity() | |
759 | ); // attribute id | |
760 | | |
761 | streamBuffer.rewind(); | |
762 | sourceIdBuff.rewind(); | |
763 | | |
764 | buff | |
765 | .put(streamBuffer) | |
766 | .put((byte) NetStreamConstants.EVENT_DEL_GRAPH_ATTR) | |
767 | .put(sourceIdBuff) | |
768 | .put(encodeUnsignedVarint(timeId)) | |
769 | .put(attrBuff); | |
770 | ||
771 |
1
1. graphAttributeRemoved : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
772 | ||
773 | } | |
774 | ||
775 | /* | |
776 | * (non-Javadoc) | |
777 | * | |
778 | * @see | |
779 | * org.graphstream.stream.AttributeSink#nodeAttributeAdded(java.lang.String, | |
780 | * long, java.lang.String, java.lang.String, java.lang.Object) | |
781 | */ | |
782 | public void nodeAttributeAdded(String sourceId, long timeId, String nodeId, | |
783 | String attribute, Object value) { | |
784 | ||
785 |
1
1. nodeAttributeAdded : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
786 | this.sourceId = sourceId; | |
787 | sourceIdBuff = encodeString(sourceId); | |
788 | } | |
789 | ByteBuffer nodeBuff = encodeString(nodeId); | |
790 | ByteBuffer attrBuff = encodeString(attribute); | |
791 | int valueType = getType(value); | |
792 | ByteBuffer valueBuff = encodeValue(value, valueType); | |
793 | | |
794 | ByteBuffer buff = ByteBuffer.allocate( | |
795 |
7
1. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 2. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 3. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 4. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 5. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 6. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 7. nodeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
796 | 1 + // CMD | |
797 | sourceIdBuff.capacity() + // source id | |
798 | varintSize(timeId) + // timeId | |
799 | nodeBuff.capacity() + // nodeId | |
800 | attrBuff.capacity() + // attribute | |
801 | 1 + // value type | |
802 | valueBuff.capacity() // value | |
803 | ); | |
804 | | |
805 | streamBuffer.rewind(); | |
806 | sourceIdBuff.rewind(); | |
807 | | |
808 | | |
809 | buff | |
810 | .put(streamBuffer) | |
811 | .put((byte) NetStreamConstants.EVENT_ADD_NODE_ATTR) | |
812 | .put(sourceIdBuff) | |
813 | .put(encodeUnsignedVarint(timeId)) | |
814 | .put(nodeBuff) | |
815 | .put(attrBuff) | |
816 | .put((byte) valueType) | |
817 | .put(valueBuff); | |
818 | ||
819 | | |
820 |
1
1. nodeAttributeAdded : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
821 | ||
822 | } | |
823 | ||
824 | /* | |
825 | * (non-Javadoc) | |
826 | * | |
827 | * @see | |
828 | * org.graphstream.stream.AttributeSink#nodeAttributeChanged(java.lang.String | |
829 | * , long, java.lang.String, java.lang.String, java.lang.Object, | |
830 | * java.lang.Object) | |
831 | */ | |
832 | public void nodeAttributeChanged(String sourceId, long timeId, | |
833 | String nodeId, String attribute, Object oldValue, Object newValue) { | |
834 |
1
1. nodeAttributeChanged : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
835 | this.sourceId = sourceId; | |
836 | sourceIdBuff = encodeString(sourceId); | |
837 | } | |
838 | | |
839 | ByteBuffer nodeBuff = encodeString(nodeId); | |
840 | ByteBuffer attrBuff = encodeString(attribute); | |
841 | | |
842 | int oldValueType = getType(oldValue); | |
843 | int newValueType = getType(newValue); | |
844 | | |
845 | ByteBuffer oldValueBuff = encodeValue(oldValue, oldValueType); | |
846 | ByteBuffer newValueBuff = encodeValue(newValue, newValueType); | |
847 | | |
848 | ByteBuffer buff = ByteBuffer.allocate( | |
849 |
9
1. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 2. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 3. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 4. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 5. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 6. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 7. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 8. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 9. nodeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
850 | 1 + // CMD | |
851 | sourceIdBuff.capacity() + // source id | |
852 | varintSize(timeId) + // timeId | |
853 | nodeBuff.capacity() + // nodeId | |
854 | attrBuff.capacity() + // attribute | |
855 | 1 + // value type | |
856 | oldValueBuff.capacity() + // value | |
857 | 1 + // value type | |
858 | newValueBuff.capacity() // value | |
859 | ); | |
860 | | |
861 | streamBuffer.rewind(); | |
862 | sourceIdBuff.rewind(); | |
863 | | |
864 | | |
865 | buff | |
866 | .put(streamBuffer) | |
867 | .put((byte) NetStreamConstants.EVENT_CHG_NODE_ATTR) | |
868 | .put(sourceIdBuff) | |
869 | .put(encodeUnsignedVarint(timeId)) | |
870 | .put(nodeBuff) | |
871 | .put(attrBuff) | |
872 | .put((byte) oldValueType) | |
873 | .put(oldValueBuff) | |
874 | .put((byte) newValueType) | |
875 | .put(newValueBuff); | |
876 | ||
877 |
1
1. nodeAttributeChanged : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
878 | } | |
879 | ||
880 | /* | |
881 | * (non-Javadoc) | |
882 | * | |
883 | * @see | |
884 | * org.graphstream.stream.AttributeSink#nodeAttributeRemoved(java.lang.String | |
885 | * , long, java.lang.String, java.lang.String) | |
886 | */ | |
887 | public void nodeAttributeRemoved(String sourceId, long timeId, | |
888 | String nodeId, String attribute) { | |
889 | ||
890 |
1
1. nodeAttributeRemoved : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
891 | this.sourceId = sourceId; | |
892 | sourceIdBuff = encodeString(sourceId); | |
893 | } | |
894 | ByteBuffer nodeBuff = encodeString(nodeId); | |
895 | ByteBuffer attrBuff = encodeString(attribute); | |
896 | ||
897 | ByteBuffer buff = ByteBuffer.allocate( | |
898 |
5
1. nodeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 2. nodeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 3. nodeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 4. nodeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 5. nodeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
899 | 1 + // CMD | |
900 | sourceIdBuff.capacity() + // source id | |
901 | varintSize(timeId) + // timeId | |
902 | nodeBuff.capacity() + // nodeId | |
903 | attrBuff.capacity() // attribute | |
904 | ); | |
905 | | |
906 | | |
907 | streamBuffer.rewind(); | |
908 | sourceIdBuff.rewind(); | |
909 | | |
910 | | |
911 | buff | |
912 | .put(streamBuffer) | |
913 | .put((byte) NetStreamConstants.EVENT_DEL_NODE_ATTR) | |
914 | .put(sourceIdBuff) | |
915 | .put(encodeUnsignedVarint(timeId)) | |
916 | .put(nodeBuff) | |
917 | .put(attrBuff); | |
918 | | |
919 |
1
1. nodeAttributeRemoved : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
920 | ||
921 | } | |
922 | ||
923 | /* | |
924 | * (non-Javadoc) | |
925 | * | |
926 | * @see | |
927 | * org.graphstream.stream.AttributeSink#edgeAttributeAdded(java.lang.String, | |
928 | * long, java.lang.String, java.lang.String, java.lang.Object) | |
929 | */ | |
930 | public void edgeAttributeAdded(String sourceId, long timeId, String edgeId, | |
931 | String attribute, Object value) { | |
932 | ||
933 |
1
1. edgeAttributeAdded : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
934 | this.sourceId = sourceId; | |
935 | sourceIdBuff = encodeString(sourceId); | |
936 | } | |
937 | ByteBuffer edgeBuff = encodeString(edgeId); | |
938 | ByteBuffer attrBuff = encodeString(attribute); | |
939 | ||
940 | int valueType = getType(value); | |
941 | | |
942 | ByteBuffer valueBuff = encodeValue(value, valueType); | |
943 | | |
944 | ByteBuffer buff = ByteBuffer.allocate( | |
945 |
7
1. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 2. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 3. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 4. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 5. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 6. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE 7. edgeAttributeAdded : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
946 | 1 + // CMD | |
947 | sourceIdBuff.capacity() + // source id | |
948 | varintSize(timeId) + // timeId | |
949 | edgeBuff.capacity() + // nodeId | |
950 | attrBuff.capacity() + // attribute | |
951 | 1 + // value type | |
952 | valueBuff.capacity() // value | |
953 | ); | |
954 | | |
955 | streamBuffer.rewind(); | |
956 | sourceIdBuff.rewind(); | |
957 | | |
958 | | |
959 | buff | |
960 | .put(streamBuffer) | |
961 | .put((byte) NetStreamConstants.EVENT_ADD_EDGE_ATTR) | |
962 | .put(sourceIdBuff) | |
963 | .put(encodeUnsignedVarint(timeId)) | |
964 | .put(edgeBuff) | |
965 | .put(attrBuff) | |
966 | .put((byte) valueType) // value type | |
967 | .put(valueBuff); | |
968 | ||
969 |
1
1. edgeAttributeAdded : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
970 | } | |
971 | ||
972 | /* | |
973 | * (non-Javadoc) | |
974 | * | |
975 | * @see | |
976 | * org.graphstream.stream.AttributeSink#edgeAttributeChanged(java.lang.String | |
977 | * , long, java.lang.String, java.lang.String, java.lang.Object, | |
978 | * java.lang.Object) | |
979 | */ | |
980 | public void edgeAttributeChanged(String sourceId, long timeId, | |
981 | String edgeId, String attribute, Object oldValue, Object newValue) { | |
982 | ||
983 |
1
1. edgeAttributeChanged : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
984 | this.sourceId = sourceId; | |
985 | sourceIdBuff = encodeString(sourceId); | |
986 | } | |
987 | ByteBuffer edgeBuff = encodeString(edgeId); | |
988 | ByteBuffer attrBuff = encodeString(attribute); | |
989 | int oldValueType = getType(oldValue); | |
990 | int newValueType = getType(newValue); | |
991 | ||
992 | ByteBuffer oldValueBuff = encodeValue(oldValue, oldValueType); | |
993 | ByteBuffer newValueBuff = encodeValue(newValue, newValueType); | |
994 | | |
995 | ByteBuffer buff = ByteBuffer.allocate( | |
996 |
9
1. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 2. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 3. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 4. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 5. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 6. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 7. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 8. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE 9. edgeAttributeChanged : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
997 | 1 + // CMD | |
998 | sourceIdBuff.capacity() + // source id | |
999 | varintSize(timeId) + // timeId | |
1000 | edgeBuff.capacity() + // nodeId | |
1001 | attrBuff.capacity() + // attribute | |
1002 | 1 + // value type | |
1003 | oldValueBuff.capacity() + // value | |
1004 | 1 + // value type | |
1005 | newValueBuff.capacity() // value | |
1006 | ); | |
1007 | ||
1008 | | |
1009 | streamBuffer.rewind(); | |
1010 | sourceIdBuff.rewind(); | |
1011 | | |
1012 | | |
1013 | buff | |
1014 | .put(streamBuffer) | |
1015 | .put((byte) NetStreamConstants.EVENT_CHG_EDGE_ATTR) | |
1016 | .put(sourceIdBuff) | |
1017 | .put(encodeUnsignedVarint(timeId)) | |
1018 | .put(edgeBuff) | |
1019 | .put(attrBuff) | |
1020 | .put((byte) oldValueType) | |
1021 | .put(oldValueBuff) | |
1022 | .put((byte) newValueType) | |
1023 | .put(newValueBuff); | |
1024 | ||
1025 |
1
1. edgeAttributeChanged : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1026 | ||
1027 | } | |
1028 | ||
1029 | /* | |
1030 | * (non-Javadoc) | |
1031 | * | |
1032 | * @see | |
1033 | * org.graphstream.stream.AttributeSink#edgeAttributeRemoved(java.lang.String | |
1034 | * , long, java.lang.String, java.lang.String) | |
1035 | */ | |
1036 | public void edgeAttributeRemoved(String sourceId, long timeId, | |
1037 | String edgeId, String attribute) { | |
1038 | ||
1039 |
1
1. edgeAttributeRemoved : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1040 | this.sourceId = sourceId; | |
1041 | sourceIdBuff = encodeString(sourceId); | |
1042 | } | |
1043 | ByteBuffer edgeBuff = encodeString(edgeId); | |
1044 | ByteBuffer attrBuff = encodeString(attribute); | |
1045 | | |
1046 | ByteBuffer buff = ByteBuffer.allocate( | |
1047 |
5
1. edgeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 2. edgeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 3. edgeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 4. edgeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 5. edgeAttributeRemoved : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1048 | 1 + // CMD | |
1049 | sourceIdBuff.capacity() + // source id | |
1050 | varintSize(timeId) + // timeId | |
1051 | edgeBuff.capacity() + // nodeId | |
1052 | attrBuff.capacity() // attribute | |
1053 | ); | |
1054 | | |
1055 | | |
1056 | streamBuffer.rewind(); | |
1057 | sourceIdBuff.rewind(); | |
1058 | | |
1059 | ||
1060 | buff | |
1061 | .put(streamBuffer) | |
1062 | .put((byte) NetStreamConstants.EVENT_DEL_EDGE_ATTR) | |
1063 | .put(sourceIdBuff) | |
1064 | .put(encodeUnsignedVarint(timeId)) | |
1065 | .put(edgeBuff) | |
1066 | .put(attrBuff); | |
1067 | | |
1068 | ||
1069 |
1
1. edgeAttributeRemoved : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1070 | ||
1071 | } | |
1072 | ||
1073 | /* | |
1074 | * (non-Javadoc) | |
1075 | * | |
1076 | * @see org.graphstream.stream.ElementSink#nodeAdded(java.lang.String, long, | |
1077 | * java.lang.String) | |
1078 | */ | |
1079 | public void nodeAdded(String sourceId, long timeId, String nodeId) { | |
1080 | ||
1081 |
1
1. nodeAdded : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1082 | this.sourceId = sourceId; | |
1083 | sourceIdBuff = encodeString(sourceId); | |
1084 | } | |
1085 | ByteBuffer nodeBuff = encodeString(nodeId); | |
1086 | | |
1087 | | |
1088 | ByteBuffer buff = ByteBuffer.allocate( | |
1089 |
4
1. nodeAdded : Replaced integer addition with subtraction → NO_COVERAGE 2. nodeAdded : Replaced integer addition with subtraction → NO_COVERAGE 3. nodeAdded : Replaced integer addition with subtraction → NO_COVERAGE 4. nodeAdded : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1090 | 1 + // CMD | |
1091 | sourceIdBuff.capacity() + // source id | |
1092 | varintSize(timeId) + // timeId | |
1093 | nodeBuff.capacity() // nodeId | |
1094 | ); | |
1095 | | |
1096 | streamBuffer.rewind(); | |
1097 | sourceIdBuff.rewind(); | |
1098 | | |
1099 | | |
1100 | buff | |
1101 | .put(streamBuffer) | |
1102 | .put((byte) NetStreamConstants.EVENT_ADD_NODE) | |
1103 | .put(sourceIdBuff) | |
1104 | .put(encodeUnsignedVarint(timeId)) | |
1105 | .put(nodeBuff); | |
1106 | | |
1107 | | |
1108 |
1
1. nodeAdded : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1109 | ||
1110 | } | |
1111 | ||
1112 | /* | |
1113 | * (non-Javadoc) | |
1114 | * | |
1115 | * @see org.graphstream.stream.ElementSink#nodeRemoved(java.lang.String, | |
1116 | * long, java.lang.String) | |
1117 | */ | |
1118 | public void nodeRemoved(String sourceId, long timeId, String nodeId) { | |
1119 |
1
1. nodeRemoved : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1120 | this.sourceId = sourceId; | |
1121 | sourceIdBuff = encodeString(sourceId); | |
1122 | } | |
1123 | ByteBuffer nodeBuff = encodeString(nodeId); | |
1124 | | |
1125 | ByteBuffer buff = ByteBuffer.allocate( | |
1126 |
4
1. nodeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 2. nodeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 3. nodeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 4. nodeRemoved : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1127 | 1 + // CMD | |
1128 | sourceIdBuff.capacity() + // source id | |
1129 | varintSize(timeId) + // timeId | |
1130 | nodeBuff.capacity() // nodeId | |
1131 | ); | |
1132 | | |
1133 | streamBuffer.rewind(); | |
1134 | sourceIdBuff.rewind(); | |
1135 | | |
1136 | | |
1137 | buff | |
1138 | .put(streamBuffer) | |
1139 | .put((byte) NetStreamConstants.EVENT_DEL_NODE) | |
1140 | .put(sourceIdBuff) | |
1141 | .put(encodeUnsignedVarint(timeId)) | |
1142 | .put(nodeBuff); | |
1143 | | |
1144 |
1
1. nodeRemoved : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1145 | } | |
1146 | ||
1147 | /* | |
1148 | * (non-Javadoc) | |
1149 | * | |
1150 | * @see org.graphstream.stream.ElementSink#edgeAdded(java.lang.String, long, | |
1151 | * java.lang.String, java.lang.String, java.lang.String, boolean) | |
1152 | */ | |
1153 | public void edgeAdded(String sourceId, long timeId, String edgeId, | |
1154 | String fromNodeId, String toNodeId, boolean directed) { | |
1155 | ||
1156 |
1
1. edgeAdded : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1157 | this.sourceId = sourceId; | |
1158 | sourceIdBuff = encodeString(sourceId); | |
1159 | } | |
1160 | ByteBuffer edgeBuff = encodeString(edgeId); | |
1161 | ByteBuffer fromNodeBuff = encodeString(fromNodeId); | |
1162 | ByteBuffer toNodeBuff = encodeString(toNodeId); | |
1163 | | |
1164 | ByteBuffer buff = ByteBuffer.allocate( | |
1165 |
7
1. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 2. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 3. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 4. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 5. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 6. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE 7. edgeAdded : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1166 | 1 + // CMD | |
1167 | sourceIdBuff.capacity() + // source id | |
1168 | varintSize(timeId) + // timeId | |
1169 | edgeBuff.capacity() + // edge | |
1170 | fromNodeBuff.capacity() + // from nodeId | |
1171 | toNodeBuff.capacity() + // to nodeId | |
1172 | 1 // direction | |
1173 | ); | |
1174 | | |
1175 | streamBuffer.rewind(); | |
1176 | sourceIdBuff.rewind(); | |
1177 | | |
1178 | | |
1179 | buff | |
1180 | .put(streamBuffer) | |
1181 | .put((byte) NetStreamConstants.EVENT_ADD_EDGE) | |
1182 | .put(sourceIdBuff) | |
1183 | .put(encodeUnsignedVarint(timeId)) | |
1184 | .put(edgeBuff) | |
1185 | .put(fromNodeBuff) | |
1186 | .put(toNodeBuff) | |
1187 |
1
1. edgeAdded : negated conditional → NO_COVERAGE |
.put((byte) (!directed ? 0 : 1)); |
1188 | | |
1189 | ||
1190 |
1
1. edgeAdded : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1191 | ||
1192 | } | |
1193 | ||
1194 | /* | |
1195 | * (non-Javadoc) | |
1196 | * | |
1197 | * @see org.graphstream.stream.ElementSink#edgeRemoved(java.lang.String, | |
1198 | * long, java.lang.String) | |
1199 | */ | |
1200 | public void edgeRemoved(String sourceId, long timeId, String edgeId) { | |
1201 | ||
1202 |
1
1. edgeRemoved : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1203 | this.sourceId = sourceId; | |
1204 | sourceIdBuff = encodeString(sourceId); | |
1205 | } | |
1206 | ByteBuffer edgeBuff = encodeString(edgeId); | |
1207 | | |
1208 | ByteBuffer buff = ByteBuffer.allocate( | |
1209 |
4
1. edgeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 2. edgeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 3. edgeRemoved : Replaced integer addition with subtraction → NO_COVERAGE 4. edgeRemoved : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1210 | 1 + // CMD | |
1211 | sourceIdBuff.capacity() + // source id | |
1212 | varintSize(timeId) + // timeId | |
1213 | edgeBuff.capacity() // edge | |
1214 | ); | |
1215 | | |
1216 | streamBuffer.rewind(); | |
1217 | sourceIdBuff.rewind(); | |
1218 | | |
1219 | | |
1220 | buff | |
1221 | .put(streamBuffer) | |
1222 | .put((byte) NetStreamConstants.EVENT_DEL_EDGE) | |
1223 | .put(sourceIdBuff) | |
1224 | .put(encodeUnsignedVarint(timeId)) | |
1225 | .put(edgeBuff); | |
1226 | ||
1227 |
1
1. edgeRemoved : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1228 | ||
1229 | } | |
1230 | ||
1231 | /* | |
1232 | * (non-Javadoc) | |
1233 | * | |
1234 | * @see org.graphstream.stream.ElementSink#graphCleared(java.lang.String, | |
1235 | * long) | |
1236 | */ | |
1237 | public void graphCleared(String sourceId, long timeId) { | |
1238 | ||
1239 |
1
1. graphCleared : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1240 | this.sourceId = sourceId; | |
1241 | sourceIdBuff = encodeString(sourceId); | |
1242 | } | |
1243 | ByteBuffer buff = ByteBuffer.allocate( | |
1244 |
3
1. graphCleared : Replaced integer addition with subtraction → NO_COVERAGE 2. graphCleared : Replaced integer addition with subtraction → NO_COVERAGE 3. graphCleared : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1245 | 1 + // CMD | |
1246 | sourceIdBuff.capacity() + // source id | |
1247 | varintSize(timeId) | |
1248 | ); | |
1249 | | |
1250 | streamBuffer.rewind(); | |
1251 | sourceIdBuff.rewind(); | |
1252 | | |
1253 | | |
1254 | buff | |
1255 | .put(streamBuffer) | |
1256 | .put((byte) NetStreamConstants.EVENT_CLEARED) | |
1257 | .put(sourceIdBuff) | |
1258 | .put(encodeUnsignedVarint(timeId)); | |
1259 | ||
1260 |
1
1. graphCleared : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1261 | ||
1262 | } | |
1263 | ||
1264 | /* | |
1265 | * (non-Javadoc) | |
1266 | * | |
1267 | * @see org.graphstream.stream.ElementSink#stepBegins(java.lang.String, | |
1268 | * long, double) | |
1269 | */ | |
1270 | public void stepBegins(String sourceId, long timeId, double step) { | |
1271 | ||
1272 |
1
1. stepBegins : negated conditional → NO_COVERAGE |
if (!sourceId.equals(this.sourceId)) { |
1273 | this.sourceId = sourceId; | |
1274 | sourceIdBuff = encodeString(sourceId); | |
1275 | } | |
1276 | | |
1277 | ByteBuffer buff = ByteBuffer.allocate( | |
1278 |
4
1. stepBegins : Replaced integer addition with subtraction → NO_COVERAGE 2. stepBegins : Replaced integer addition with subtraction → NO_COVERAGE 3. stepBegins : Replaced integer addition with subtraction → NO_COVERAGE 4. stepBegins : Replaced integer addition with subtraction → NO_COVERAGE |
streamBuffer.capacity() + // stream |
1279 | 1 + // CMD | |
1280 | sourceIdBuff.capacity() + // source id | |
1281 | varintSize(timeId) + | |
1282 | 8 // time | |
1283 | ); | |
1284 | | |
1285 | streamBuffer.rewind(); | |
1286 | sourceIdBuff.rewind(); | |
1287 | | |
1288 | buff | |
1289 | .put(streamBuffer) | |
1290 | .put((byte) NetStreamConstants.EVENT_STEP) | |
1291 | .put(sourceIdBuff) | |
1292 | .put(encodeUnsignedVarint(timeId)) | |
1293 | .putDouble(step); | |
1294 | | |
1295 | | |
1296 |
1
1. stepBegins : removed call to org/graphstream/stream/netstream/NetStreamSender::doSend → NO_COVERAGE |
doSend(buff); |
1297 | } | |
1298 | ||
1299 | /** | |
1300 | * Force the connection to close (properly) with the server | |
1301 | * | |
1302 | * @throws IOException | |
1303 | */ | |
1304 | public void close() throws IOException { | |
1305 |
1
1. close : removed call to java/net/Socket::close → NO_COVERAGE |
socket.close(); |
1306 | } | |
1307 | ||
1308 | } | |
Mutations | ||
89 |
1.1 |
|
96 |
1.1 |
|
116 |
1.1 |
|
118 |
1.1 |
|
170 |
1.1 |
|
171 |
1.1 |
|
175 |
1.1 |
|
178 |
1.1 |
|
179 |
1.1 |
|
184 |
1.1 |
|
185 |
1.1 |
|
190 |
1.1 |
|
191 |
1.1 |
|
196 |
1.1 |
|
197 |
1.1 |
|
202 |
1.1 |
|
203 |
1.1 |
|
208 |
1.1 |
|
209 |
1.1 |
|
214 |
1.1 |
|
215 |
1.1 |
|
220 |
1.1 |
|
221 |
1.1 |
|
229 |
1.1 |
|
234 |
1.1 |
|
235 |
1.1 |
|
236 |
1.1 |
|
237 |
1.1 |
|
238 |
1.1 |
|
239 |
1.1 |
|
240 |
1.1 |
|
241 |
1.1 |
|
242 |
1.1 |
|
243 |
1.1 |
|
244 |
1.1 |
|
245 |
1.1 |
|
246 |
1.1 |
|
247 |
1.1 |
|
248 |
1.1 |
|
249 |
1.1 |
|
250 |
1.1 |
|
251 |
1.1 |
|
252 |
1.1 |
|
253 |
1.1 |
|
254 |
1.1 |
|
255 |
1.1 |
|
256 |
1.1 |
|
257 |
1.1 |
|
258 |
1.1 |
|
259 |
1.1 |
|
260 |
1.1 |
|
261 |
1.1 |
|
262 |
1.1 |
|
263 |
1.1 |
|
264 |
1.1 |
|
265 |
1.1 |
|
266 |
1.1 |
|
267 |
1.1 |
|
272 |
1.1 |
|
281 |
1.1 |
|
285 |
1.1 |
|
288 |
1.1 2.2 3.3 |
|
289 |
1.1 |
|
290 |
1.1 2.2 3.3 4.4 5.5 |
|
293 |
1.1 |
|
307 |
1.1 |
|
312 |
1.1 |
|
324 |
1.1 2.2 |
|
326 |
1.1 |
|
328 |
1.1 2.2 3.3 |
|
332 |
1.1 |
|
340 |
1.1 |
|
352 |
1.1 2.2 |
|
354 |
1.1 |
|
356 |
1.1 2.2 3.3 |
|
360 |
1.1 |
|
371 |
1.1 |
|
379 |
1.1 |
|
387 |
1.1 |
|
395 |
1.1 |
|
403 |
1.1 |
|
411 |
1.1 |
|
419 |
1.1 |
|
431 |
1.1 |
|
433 |
1.1 |
|
435 |
1.1 2.2 3.3 |
|
439 |
1.1 |
|
450 |
1.1 |
|
462 |
1.1 |
|
464 |
1.1 |
|
466 |
1.1 2.2 3.3 |
|
467 |
1.1 |
|
470 |
1.1 |
|
479 |
1.1 |
|
481 |
1.1 |
|
487 |
1.1 2.2 |
|
488 |
1.1 |
|
492 |
1.1 2.2 |
|
493 |
1.1 |
|
497 |
1.1 2.2 |
|
498 |
1.1 |
|
502 |
1.1 2.2 |
|
503 |
1.1 |
|
507 |
1.1 2.2 |
|
508 |
1.1 |
|
512 |
1.1 2.2 |
|
513 |
1.1 |
|
517 |
1.1 2.2 |
|
518 |
1.1 |
|
522 |
1.1 2.2 |
|
523 |
1.1 |
|
526 |
1.1 |
|
539 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
551 |
1.1 2.2 3.3 |
|
556 |
1.1 2.2 3.3 4.4 5.5 |
|
559 |
1.1 |
|
566 |
1.1 |
|
568 |
1.1 |
|
570 |
1.1 2.2 3.3 |
|
571 |
1.1 |
|
575 |
1.1 |
|
588 |
1.1 2.2 3.3 |
|
590 |
1.1 2.2 |
|
591 |
1.1 2.2 3.3 4.4 |
|
592 |
1.1 |
|
595 |
1.1 |
|
605 |
1.1 2.2 3.3 |
|
607 |
1.1 2.2 |
|
608 |
1.1 2.2 3.3 4.4 |
|
609 |
1.1 |
|
618 |
1.1 |
|
620 |
1.1 |
|
629 |
1.1 |
|
630 |
1.1 |
|
631 |
1.1 |
|
634 |
1.1 |
|
636 |
1.1 |
|
654 |
1.1 |
|
663 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
682 |
1.1 |
|
696 |
1.1 |
|
709 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 |
|
733 |
1.1 |
|
747 |
1.1 |
|
754 |
1.1 2.2 3.3 4.4 |
|
771 |
1.1 |
|
785 |
1.1 |
|
795 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
820 |
1.1 |
|
834 |
1.1 |
|
849 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
877 |
1.1 |
|
890 |
1.1 |
|
898 |
1.1 2.2 3.3 4.4 5.5 |
|
919 |
1.1 |
|
933 |
1.1 |
|
945 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
969 |
1.1 |
|
983 |
1.1 |
|
996 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
1025 |
1.1 |
|
1039 |
1.1 |
|
1047 |
1.1 2.2 3.3 4.4 5.5 |
|
1069 |
1.1 |
|
1081 |
1.1 |
|
1089 |
1.1 2.2 3.3 4.4 |
|
1108 |
1.1 |
|
1119 |
1.1 |
|
1126 |
1.1 2.2 3.3 4.4 |
|
1144 |
1.1 |
|
1156 |
1.1 |
|
1165 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 |
|
1187 |
1.1 |
|
1190 |
1.1 |
|
1202 |
1.1 |
|
1209 |
1.1 2.2 3.3 4.4 |
|
1227 |
1.1 |
|
1239 |
1.1 |
|
1244 |
1.1 2.2 3.3 |
|
1260 |
1.1 |
|
1272 |
1.1 |
|
1278 |
1.1 2.2 3.3 4.4 |
|
1296 |
1.1 |
|
1305 |
1.1 |