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.file; | |
33 | ||
34 | import java.io.BufferedReader; | |
35 | import java.io.FileInputStream; | |
36 | import java.io.FileNotFoundException; | |
37 | import java.io.IOException; | |
38 | import java.io.InputStream; | |
39 | import java.io.InputStreamReader; | |
40 | import java.io.Reader; | |
41 | import java.io.StreamTokenizer; | |
42 | import java.net.URL; | |
43 | import java.util.ArrayList; | |
44 | import java.util.HashMap; | |
45 | import java.util.zip.GZIPInputStream; | |
46 | ||
47 | /** | |
48 | * Class responsible for parsing files in the DGS format (old versions of the | |
49 | * format). | |
50 | * | |
51 | * <p> | |
52 | * The DGS file format is especially designed for storing dynamic graph | |
53 | * definitions into a file. More information about the DGS file format will be | |
54 | * found on the GraphStream web site: <a | |
55 | * href="http://graphstream-project.org/">http://graphstream-project.org/</a> | |
56 | * </p> | |
57 | * | |
58 | * @see OldFileSourceDGS | |
59 | * @see FileSource | |
60 | */ | |
61 | public class FileSourceDGS1And2 extends FileSourceBase { | |
62 | // Constants | |
63 | ||
64 | /** | |
65 | * Types of attributes. | |
66 | */ | |
67 | protected enum AttributeType { | |
68 | NUMBER, VECTOR, STRING | |
69 | }; | |
70 | ||
71 | /** | |
72 | * Pair <name,type> defining an attribute. | |
73 | */ | |
74 | protected static class AttributeFormat { | |
75 | /** | |
76 | * Name of the attribute. | |
77 | */ | |
78 | public String name; | |
79 | ||
80 | /** | |
81 | * Type of the attribute. | |
82 | */ | |
83 | public AttributeType type; | |
84 | ||
85 | /** | |
86 | * New format descriptor for an attribute. | |
87 | * | |
88 | * @param name | |
89 | * The attribute name. | |
90 | * @param type | |
91 | * The attribute type. | |
92 | */ | |
93 | public AttributeFormat(String name, AttributeType type) { | |
94 | this.name = name; | |
95 | this.type = type; | |
96 | } | |
97 | ||
98 | /** | |
99 | * Attribute name. | |
100 | * | |
101 | * @return The name. | |
102 | */ | |
103 | public String getName() { | |
104 |
1
1. getName : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS1And2$AttributeFormat::getName to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return name; |
105 | } | |
106 | ||
107 | /** | |
108 | * Attribute format. | |
109 | * | |
110 | * @return The format. | |
111 | */ | |
112 | public AttributeType getType() { | |
113 |
1
1. getType : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS1And2$AttributeFormat::getType to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return type; |
114 | } | |
115 | } | |
116 | ||
117 | // Attributes | |
118 | ||
119 | /** | |
120 | * Format version. | |
121 | */ | |
122 | protected int version; | |
123 | ||
124 | /** | |
125 | * Name of the graph. | |
126 | */ | |
127 | protected String graphName; | |
128 | ||
129 | /** | |
130 | * Number of step given in the header. | |
131 | */ | |
132 | protected int stepCountAnnounced; | |
133 | ||
134 | /** | |
135 | * Number of events given in the header. | |
136 | */ | |
137 | protected int eventCountAnnounced; | |
138 | ||
139 | /** | |
140 | * Real number of step at current time. | |
141 | */ | |
142 | protected int stepCount; | |
143 | ||
144 | /** | |
145 | * Real number of events at current time. | |
146 | */ | |
147 | protected int eventCount; | |
148 | ||
149 | /** | |
150 | * Attribute count and type expected for each node add and modify command. | |
151 | */ | |
152 | protected ArrayList<AttributeFormat> nodesFormat = new ArrayList<AttributeFormat>(); | |
153 | ||
154 | /** | |
155 | * Attribute count and type expected for each edges add and modify command. | |
156 | */ | |
157 | protected ArrayList<AttributeFormat> edgesFormat = new ArrayList<AttributeFormat>(); | |
158 | ||
159 | /** | |
160 | * An attribute set. | |
161 | */ | |
162 | protected HashMap<String, Object> attributes = new HashMap<String, Object>(); | |
163 | ||
164 | // Constructors | |
165 | ||
166 | /** | |
167 | * New reader for the DGS graph file format versions 1 and 2. | |
168 | */ | |
169 | public FileSourceDGS1And2() { | |
170 | super(true /* EOL is significant */); | |
171 | } | |
172 | ||
173 | // Access | |
174 | ||
175 | // Command | |
176 | ||
177 | @Override | |
178 | public boolean nextEvents() throws IOException { | |
179 | String key = getWordOrSymbolOrStringOrEolOrEof(); | |
180 | String tag = null; | |
181 | ||
182 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (key.equals("ce")) { |
183 | tag = getStringOrWordOrNumber(); | |
184 | ||
185 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(edgesFormat); |
186 | ||
187 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
188 | Object value = attributes.get(k); | |
189 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeAttributeChanged → NO_COVERAGE |
sendEdgeAttributeChanged(graphName, tag, k, null, value); |
190 | } | |
191 | ||
192 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
193 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
194 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("cn")) { |
195 | tag = getStringOrWordOrNumber(); | |
196 | ||
197 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(nodesFormat); |
198 | ||
199 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
200 | Object value = attributes.get(k); | |
201 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAttributeChanged → NO_COVERAGE |
sendNodeAttributeChanged(graphName, tag, k, null, value); |
202 | } | |
203 | ||
204 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
205 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
206 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("ae")) { |
207 | tag = getStringOrWordOrNumber(); | |
208 | String fromTag = getStringOrWordOrNumber(); | |
209 | String toTag = getStringOrWordOrNumber(); | |
210 | ||
211 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(edgesFormat); |
212 | ||
213 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeAdded → NO_COVERAGE |
sendEdgeAdded(graphName, tag, fromTag, toTag, false); |
214 | ||
215 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (attributes != null) { |
216 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
217 | Object value = attributes.get(k); | |
218 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeAttributeAdded → NO_COVERAGE |
sendEdgeAttributeAdded(graphName, tag, k, value); |
219 | } | |
220 | } | |
221 | ||
222 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
223 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
224 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("an")) { |
225 | tag = getStringOrWordOrNumber(); | |
226 | ||
227 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(nodesFormat); |
228 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAdded → NO_COVERAGE |
sendNodeAdded(graphName, tag); |
229 | ||
230 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (attributes != null) { |
231 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
232 | Object value = attributes.get(k); | |
233 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAttributeAdded → NO_COVERAGE |
sendNodeAttributeAdded(graphName, tag, k, value); |
234 | } | |
235 | } | |
236 | ||
237 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
238 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
239 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("de")) { |
240 | tag = getStringOrWordOrNumber(); | |
241 | ||
242 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeRemoved → NO_COVERAGE |
sendEdgeRemoved(graphName, tag); |
243 | ||
244 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
245 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
246 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("dn")) { |
247 | tag = getStringOrWordOrNumber(); | |
248 | ||
249 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeRemoved → NO_COVERAGE |
sendNodeRemoved(graphName, tag); |
250 | ||
251 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
252 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
253 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key.equals("st")) { |
254 | String w = getWordOrNumber(); | |
255 | ||
256 | try { | |
257 | double time = Double.parseDouble(w); | |
258 | ||
259 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendStepBegins → NO_COVERAGE |
sendStepBegins(graphName, time); |
260 | } catch (NumberFormatException e) { | |
261 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("expecting a number after `st', got `" + w + "'"); |
262 | } | |
263 | ||
264 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
265 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
266 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key == "#") { |
267 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::eatAllUntilEol → NO_COVERAGE |
eatAllUntilEol(); |
268 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key == "EOL") { |
269 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
270 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
} else if (key == "EOF") { |
271 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
272 | } else { | |
273 |
1
1. nextEvents : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("found an unknown key in file '" + key |
274 | + "' (expecting an,ae,cn,ce,dn,de or st)"); | |
275 | } | |
276 | ||
277 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
278 | } | |
279 | ||
280 | /** | |
281 | * tries to read all the events between 2 steps | |
282 | */ | |
283 | public boolean nextStep() throws IOException { | |
284 | String key = ""; | |
285 | String tag = null; | |
286 | ||
287 |
2
1. nextStep : negated conditional → NO_COVERAGE 2. nextStep : negated conditional → NO_COVERAGE |
while (!key.equals("st") && !key.equals("EOF")) { |
288 | key = getWordOrSymbolOrStringOrEolOrEof(); | |
289 | ||
290 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (key.equals("ce")) { |
291 | tag = getStringOrWordOrNumber(); | |
292 | ||
293 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(edgesFormat); |
294 | ||
295 |
1
1. nextStep : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
296 | Object value = attributes.get(k); | |
297 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeAttributeChanged → NO_COVERAGE |
sendEdgeAttributeChanged(graphName, tag, k, null, value); |
298 | } | |
299 | ||
300 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
301 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
302 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("cn")) { |
303 | tag = getStringOrWordOrNumber(); | |
304 | ||
305 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(nodesFormat); |
306 | ||
307 |
1
1. nextStep : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
308 | Object value = attributes.get(k); | |
309 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAttributeChanged → NO_COVERAGE |
sendNodeAttributeChanged(graphName, tag, k, null, value); |
310 | } | |
311 | ||
312 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
313 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
314 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("ae")) { |
315 | tag = getStringOrWordOrNumber(); | |
316 | String fromTag = getStringOrWordOrNumber(); | |
317 | String toTag = getStringOrWordOrNumber(); | |
318 | ||
319 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(edgesFormat); |
320 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeAdded → NO_COVERAGE |
sendEdgeAdded(graphName, tag, fromTag, toTag, false); |
321 | ||
322 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (attributes != null) { |
323 |
1
1. nextStep : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
324 | Object value = attributes.get(k); | |
325 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAttributeAdded → NO_COVERAGE |
sendNodeAttributeAdded(graphName, tag, k, value); |
326 | } | |
327 | } | |
328 | ||
329 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
330 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
331 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("an")) { |
332 | tag = getStringOrWordOrNumber(); | |
333 | ||
334 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributes → NO_COVERAGE |
readAttributes(nodesFormat); |
335 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAdded → NO_COVERAGE |
sendNodeAdded(graphName, tag); |
336 | ||
337 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (attributes != null) { |
338 |
1
1. nextStep : negated conditional → NO_COVERAGE |
for (String k : attributes.keySet()) { |
339 | Object value = attributes.get(k); | |
340 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeAttributeAdded → NO_COVERAGE |
sendNodeAttributeAdded(graphName, tag, k, value); |
341 | } | |
342 | } | |
343 | ||
344 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
345 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
346 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("de")) { |
347 | tag = getStringOrWordOrNumber(); | |
348 | ||
349 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendEdgeRemoved → NO_COVERAGE |
sendEdgeRemoved(graphName, tag); |
350 | ||
351 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
352 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
353 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("dn")) { |
354 | tag = getStringOrWordOrNumber(); | |
355 | ||
356 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendNodeRemoved → NO_COVERAGE |
sendNodeRemoved(graphName, tag); |
357 | ||
358 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
359 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
360 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key.equals("st")) { |
361 | String w = getWordOrNumber(); | |
362 | ||
363 | try { | |
364 | double time = Double.parseDouble(w); | |
365 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendStepBegins → NO_COVERAGE |
sendStepBegins(graphName, time); |
366 | } catch (NumberFormatException e) { | |
367 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("expecting a number after `st', got `" + w + "'"); |
368 | } | |
369 | ||
370 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
371 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
372 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key == "#") { |
373 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::eatAllUntilEol → NO_COVERAGE |
eatAllUntilEol(); |
374 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key == "EOL") { |
375 | // NOP | |
376 |
1
1. nextStep : negated conditional → NO_COVERAGE |
} else if (key == "EOF") { |
377 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
378 | } else { | |
379 |
1
1. nextStep : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("found an unknown key in file '" + key |
380 | + "' (expecting an,ae,cn,ce,dn,de or st)"); | |
381 | } | |
382 | } | |
383 | ||
384 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
385 | } | |
386 | ||
387 | protected void readAttributes(ArrayList<AttributeFormat> formats) | |
388 | throws IOException { | |
389 |
1
1. readAttributes : removed call to java/util/HashMap::clear → NO_COVERAGE |
attributes.clear(); |
390 | ||
391 |
2
1. readAttributes : changed conditional boundary → NO_COVERAGE 2. readAttributes : negated conditional → NO_COVERAGE |
if (formats.size() > 0) { |
392 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
for (AttributeFormat format : formats) { |
393 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (format.type == AttributeType.NUMBER) { |
394 |
1
1. readAttributes : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readNumberAttribute → NO_COVERAGE |
readNumberAttribute(format.name); |
395 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
} else if (format.type == AttributeType.VECTOR) { |
396 |
1
1. readAttributes : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readVectorAttribute → NO_COVERAGE |
readVectorAttribute(format.name); |
397 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
} else if (format.type == AttributeType.STRING) { |
398 |
1
1. readAttributes : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readStringAttribute → NO_COVERAGE |
readStringAttribute(format.name); |
399 | } | |
400 | } | |
401 | } | |
402 | } | |
403 | ||
404 | protected void readNumberAttribute(String name) throws IOException { | |
405 | int tok = st.nextToken(); | |
406 | ||
407 |
1
1. readNumberAttribute : negated conditional → NO_COVERAGE |
if (isNull(tok)) { |
408 | attributes.put(name, new Double(0)); | |
409 | } else { | |
410 |
1
1. readNumberAttribute : removed call to java/io/StreamTokenizer::pushBack → NO_COVERAGE |
st.pushBack(); |
411 | ||
412 | double n = getNumber(); | |
413 | ||
414 | attributes.put(name, new Double(n)); | |
415 | } | |
416 | } | |
417 | ||
418 | protected void readVectorAttribute(String name) throws IOException { | |
419 | int tok = st.nextToken(); | |
420 | ||
421 |
1
1. readVectorAttribute : negated conditional → NO_COVERAGE |
if (isNull(tok)) { |
422 | attributes.put(name, new ArrayList<Double>()); | |
423 | } else { | |
424 | ||
425 | boolean loop = true; | |
426 | ||
427 | ArrayList<Double> vector = new ArrayList<Double>(); | |
428 | ||
429 |
1
1. readVectorAttribute : negated conditional → NO_COVERAGE |
while (loop) { |
430 |
1
1. readVectorAttribute : negated conditional → NO_COVERAGE |
if (tok != StreamTokenizer.TT_NUMBER) |
431 |
1
1. readVectorAttribute : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("expecting a number, " + gotWhat(tok)); |
432 | ||
433 | vector.add(st.nval); | |
434 | ||
435 | tok = st.nextToken(); | |
436 | ||
437 |
1
1. readVectorAttribute : negated conditional → NO_COVERAGE |
if (tok != ',') { |
438 | loop = false; | |
439 |
1
1. readVectorAttribute : removed call to java/io/StreamTokenizer::pushBack → NO_COVERAGE |
st.pushBack(); |
440 | } else { | |
441 | tok = st.nextToken(); | |
442 | } | |
443 | } | |
444 | ||
445 | attributes.put(name, vector); | |
446 | } | |
447 | } | |
448 | ||
449 | protected void readStringAttribute(String name) throws IOException { | |
450 | String s = getStringOrWordOrNumber(); | |
451 | ||
452 | attributes.put(name, s); | |
453 | } | |
454 | ||
455 | protected boolean isNull(int tok) { | |
456 |
1
1. isNull : negated conditional → NO_COVERAGE |
if (tok == StreamTokenizer.TT_WORD) |
457 |
1
1. isNull : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return (st.sval.equals("null")); |
458 | ||
459 |
1
1. isNull : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
460 | } | |
461 | ||
462 | @Override | |
463 | public void begin(String filename) throws IOException { | |
464 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(filename); |
465 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceDGS1And2::init → NO_COVERAGE |
init(); |
466 | } | |
467 | ||
468 | @Override | |
469 | public void begin(InputStream stream) throws IOException { | |
470 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(stream); |
471 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceDGS1And2::init → NO_COVERAGE |
init(); |
472 | } | |
473 | ||
474 | @Override | |
475 | public void begin(Reader reader) throws IOException { | |
476 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(reader); |
477 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceDGS1And2::init → NO_COVERAGE |
init(); |
478 | } | |
479 | ||
480 | @Override | |
481 | public void begin(URL url) throws IOException { | |
482 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(url); |
483 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceDGS1And2::init → NO_COVERAGE |
init(); |
484 | } | |
485 | ||
486 | protected void init() throws IOException { | |
487 |
1
1. init : removed call to java/io/StreamTokenizer::parseNumbers → NO_COVERAGE |
st.parseNumbers(); |
488 | ||
489 | String magic = eatOneOfTwoWords("DGS001", "DGS002"); | |
490 | ||
491 |
1
1. init : negated conditional → NO_COVERAGE |
if (magic.equals("DGS001")) |
492 | version = 1; | |
493 | else | |
494 | version = 2; | |
495 | ||
496 |
1
1. init : removed call to org/graphstream/stream/file/FileSourceDGS1And2::eatEol → NO_COVERAGE |
eatEol(); |
497 | graphName = getWord(); | |
498 | stepCountAnnounced = (int) getNumber();// Integer.parseInt( getWord() ); | |
499 | eventCountAnnounced = (int) getNumber();// Integer.parseInt( getWord() | |
500 | // ); | |
501 |
1
1. init : removed call to org/graphstream/stream/file/FileSourceDGS1And2::eatEol → NO_COVERAGE |
eatEol(); |
502 | ||
503 |
1
1. init : negated conditional → NO_COVERAGE |
if (graphName != null) { |
504 |
1
1. init : removed call to java/util/HashMap::clear → NO_COVERAGE |
attributes.clear(); |
505 | attributes.put("label", graphName); | |
506 |
1
1. init : removed call to org/graphstream/stream/file/FileSourceDGS1And2::sendGraphAttributeAdded → NO_COVERAGE |
sendGraphAttributeAdded(graphName, "label", graphName); |
507 | } else { | |
508 | graphName = "DGS_"; | |
509 | } | |
510 | ||
511 | graphName = String.format("%s_%d", graphName, | |
512 |
2
1. init : Replaced long multiplication with division → NO_COVERAGE 2. init : Replaced long addition with subtraction → NO_COVERAGE |
System.currentTimeMillis() + ((long) Math.random() * 10)); |
513 | ||
514 |
1
1. init : removed call to org/graphstream/stream/file/FileSourceDGS1And2::readAttributeFormat → NO_COVERAGE |
readAttributeFormat(); |
515 | } | |
516 | ||
517 | protected void readAttributeFormat() throws IOException { | |
518 | int tok = st.nextToken(); | |
519 | ||
520 |
2
1. readAttributeFormat : negated conditional → NO_COVERAGE 2. readAttributeFormat : negated conditional → NO_COVERAGE |
if (tok == StreamTokenizer.TT_WORD && st.sval.equals("nodes")) { |
521 |
1
1. readAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseAttributeFormat → NO_COVERAGE |
parseAttributeFormat(nodesFormat); |
522 | tok = st.nextToken(); | |
523 | } | |
524 | ||
525 |
2
1. readAttributeFormat : negated conditional → NO_COVERAGE 2. readAttributeFormat : negated conditional → NO_COVERAGE |
if (tok == StreamTokenizer.TT_WORD && st.sval.equals("edges")) { |
526 |
1
1. readAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseAttributeFormat → NO_COVERAGE |
parseAttributeFormat(edgesFormat); |
527 | } else { | |
528 |
1
1. readAttributeFormat : removed call to java/io/StreamTokenizer::pushBack → NO_COVERAGE |
st.pushBack(); |
529 | } | |
530 | } | |
531 | ||
532 | protected void parseAttributeFormat(ArrayList<AttributeFormat> format) | |
533 | throws IOException { | |
534 | int tok = st.nextToken(); | |
535 | ||
536 |
1
1. parseAttributeFormat : negated conditional → NO_COVERAGE |
while (tok != StreamTokenizer.TT_EOL) { |
537 |
1
1. parseAttributeFormat : negated conditional → NO_COVERAGE |
if (tok == StreamTokenizer.TT_WORD) { |
538 | String name = st.sval; | |
539 | ||
540 |
1
1. parseAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::eatSymbol → NO_COVERAGE |
eatSymbol(':'); |
541 | ||
542 | tok = st.nextToken(); | |
543 | ||
544 |
1
1. parseAttributeFormat : negated conditional → NO_COVERAGE |
if (tok == StreamTokenizer.TT_WORD) { |
545 | String type = st.sval.toLowerCase(); | |
546 | ||
547 |
2
1. parseAttributeFormat : negated conditional → NO_COVERAGE 2. parseAttributeFormat : negated conditional → NO_COVERAGE |
if (type.equals("number") || type.equals("n")) { |
548 | format.add(new AttributeFormat(name, | |
549 | AttributeType.NUMBER)); | |
550 |
2
1. parseAttributeFormat : negated conditional → NO_COVERAGE 2. parseAttributeFormat : negated conditional → NO_COVERAGE |
} else if (type.equals("string") || type.equals("s")) { |
551 | format.add(new AttributeFormat(name, | |
552 | AttributeType.STRING)); | |
553 |
2
1. parseAttributeFormat : negated conditional → NO_COVERAGE 2. parseAttributeFormat : negated conditional → NO_COVERAGE |
} else if (type.equals("vector") || type.equals("v")) { |
554 | format.add(new AttributeFormat(name, | |
555 | AttributeType.VECTOR)); | |
556 | } else { | |
557 |
1
1. parseAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("unknown attribute type `" |
558 | + type | |
559 | + "' (only `number', `vector' and `string' are accepted)"); | |
560 | } | |
561 | } else { | |
562 |
1
1. parseAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("expecting an attribute type, got `" |
563 | + gotWhat(tok) + "'"); | |
564 | } | |
565 | } else { | |
566 |
1
1. parseAttributeFormat : removed call to org/graphstream/stream/file/FileSourceDGS1And2::parseError → NO_COVERAGE |
parseError("expecting an attribute name, got `" + gotWhat(tok) |
567 | + "'"); | |
568 | } | |
569 | ||
570 | tok = st.nextToken(); | |
571 | } | |
572 | } | |
573 | ||
574 | @Override | |
575 | protected void continueParsingInInclude() throws IOException { | |
576 | } | |
577 | ||
578 | @Override | |
579 | protected Reader createReaderFrom(String file) throws FileNotFoundException { | |
580 | InputStream is = null; | |
581 | ||
582 | try { | |
583 | is = new GZIPInputStream(new FileInputStream(file)); | |
584 | } catch (IOException e) { | |
585 | is = new FileInputStream(file); | |
586 | } | |
587 | ||
588 |
1
1. createReaderFrom : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS1And2::createReaderFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new BufferedReader(new InputStreamReader(is)); |
589 | } | |
590 | ||
591 | @Override | |
592 | protected Reader createReaderFrom(InputStream stream) { | |
593 | ||
594 |
1
1. createReaderFrom : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS1And2::createReaderFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new BufferedReader(new InputStreamReader(stream)); |
595 | } | |
596 | ||
597 | @Override | |
598 | protected void configureTokenizer(StreamTokenizer tok) throws IOException { | |
599 |
2
1. configureTokenizer : changed conditional boundary → NO_COVERAGE 2. configureTokenizer : negated conditional → NO_COVERAGE |
if (COMMENT_CHAR > 0) |
600 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::commentChar → NO_COVERAGE |
tok.commentChar(COMMENT_CHAR); |
601 | // tok.quoteChar( QUOTE_CHAR ); | |
602 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::eolIsSignificant → NO_COVERAGE |
tok.eolIsSignificant(eol_is_significant); |
603 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('_', '_'); |
604 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('1'); |
605 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('2'); |
606 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('3'); |
607 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('4'); |
608 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('5'); |
609 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('6'); |
610 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('7'); |
611 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('8'); |
612 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('9'); |
613 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('0'); |
614 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('.'); |
615 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::ordinaryChar → NO_COVERAGE |
tok.ordinaryChar('-'); |
616 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('1', '1'); |
617 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('2', '2'); |
618 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('3', '3'); |
619 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('4', '4'); |
620 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('5', '5'); |
621 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('6', '6'); |
622 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('7', '7'); |
623 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('8', '8'); |
624 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('9', '9'); |
625 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('0', '0'); |
626 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('.', '.'); |
627 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('-', '-'); |
628 | // tok.parseNumbers(); | |
629 | } | |
630 | } | |
Mutations | ||
104 |
1.1 |
|
113 |
1.1 |
|
182 |
1.1 |
|
185 |
1.1 |
|
187 |
1.1 |
|
189 |
1.1 |
|
192 |
1.1 |
|
193 |
1.1 |
|
194 |
1.1 |
|
197 |
1.1 |
|
199 |
1.1 |
|
201 |
1.1 |
|
204 |
1.1 |
|
205 |
1.1 |
|
206 |
1.1 |
|
211 |
1.1 |
|
213 |
1.1 |
|
215 |
1.1 |
|
216 |
1.1 |
|
218 |
1.1 |
|
222 |
1.1 |
|
223 |
1.1 |
|
224 |
1.1 |
|
227 |
1.1 |
|
228 |
1.1 |
|
230 |
1.1 |
|
231 |
1.1 |
|
233 |
1.1 |
|
237 |
1.1 |
|
238 |
1.1 |
|
239 |
1.1 |
|
242 |
1.1 |
|
244 |
1.1 |
|
245 |
1.1 |
|
246 |
1.1 |
|
249 |
1.1 |
|
251 |
1.1 |
|
252 |
1.1 |
|
253 |
1.1 |
|
259 |
1.1 |
|
261 |
1.1 |
|
264 |
1.1 |
|
265 |
1.1 |
|
266 |
1.1 |
|
267 |
1.1 |
|
268 |
1.1 |
|
269 |
1.1 |
|
270 |
1.1 |
|
271 |
1.1 |
|
273 |
1.1 |
|
277 |
1.1 |
|
287 |
1.1 2.2 |
|
290 |
1.1 |
|
293 |
1.1 |
|
295 |
1.1 |
|
297 |
1.1 |
|
300 |
1.1 |
|
301 |
1.1 |
|
302 |
1.1 |
|
305 |
1.1 |
|
307 |
1.1 |
|
309 |
1.1 |
|
312 |
1.1 |
|
313 |
1.1 |
|
314 |
1.1 |
|
319 |
1.1 |
|
320 |
1.1 |
|
322 |
1.1 |
|
323 |
1.1 |
|
325 |
1.1 |
|
329 |
1.1 |
|
330 |
1.1 |
|
331 |
1.1 |
|
334 |
1.1 |
|
335 |
1.1 |
|
337 |
1.1 |
|
338 |
1.1 |
|
340 |
1.1 |
|
344 |
1.1 |
|
345 |
1.1 |
|
346 |
1.1 |
|
349 |
1.1 |
|
351 |
1.1 |
|
352 |
1.1 |
|
353 |
1.1 |
|
356 |
1.1 |
|
358 |
1.1 |
|
359 |
1.1 |
|
360 |
1.1 |
|
365 |
1.1 |
|
367 |
1.1 |
|
370 |
1.1 |
|
371 |
1.1 |
|
372 |
1.1 |
|
373 |
1.1 |
|
374 |
1.1 |
|
376 |
1.1 |
|
377 |
1.1 |
|
379 |
1.1 |
|
384 |
1.1 |
|
389 |
1.1 |
|
391 |
1.1 2.2 |
|
392 |
1.1 |
|
393 |
1.1 |
|
394 |
1.1 |
|
395 |
1.1 |
|
396 |
1.1 |
|
397 |
1.1 |
|
398 |
1.1 |
|
407 |
1.1 |
|
410 |
1.1 |
|
421 |
1.1 |
|
429 |
1.1 |
|
430 |
1.1 |
|
431 |
1.1 |
|
437 |
1.1 |
|
439 |
1.1 |
|
456 |
1.1 |
|
457 |
1.1 |
|
459 |
1.1 |
|
464 |
1.1 |
|
465 |
1.1 |
|
470 |
1.1 |
|
471 |
1.1 |
|
476 |
1.1 |
|
477 |
1.1 |
|
482 |
1.1 |
|
483 |
1.1 |
|
487 |
1.1 |
|
491 |
1.1 |
|
496 |
1.1 |
|
501 |
1.1 |
|
503 |
1.1 |
|
504 |
1.1 |
|
506 |
1.1 |
|
512 |
1.1 2.2 |
|
514 |
1.1 |
|
520 |
1.1 2.2 |
|
521 |
1.1 |
|
525 |
1.1 2.2 |
|
526 |
1.1 |
|
528 |
1.1 |
|
536 |
1.1 |
|
537 |
1.1 |
|
540 |
1.1 |
|
544 |
1.1 |
|
547 |
1.1 2.2 |
|
550 |
1.1 2.2 |
|
553 |
1.1 2.2 |
|
557 |
1.1 |
|
562 |
1.1 |
|
566 |
1.1 |
|
588 |
1.1 |
|
594 |
1.1 |
|
599 |
1.1 2.2 |
|
600 |
1.1 |
|
602 |
1.1 |
|
603 |
1.1 |
|
604 |
1.1 |
|
605 |
1.1 |
|
606 |
1.1 |
|
607 |
1.1 |
|
608 |
1.1 |
|
609 |
1.1 |
|
610 |
1.1 |
|
611 |
1.1 |
|
612 |
1.1 |
|
613 |
1.1 |
|
614 |
1.1 |
|
615 |
1.1 |
|
616 |
1.1 |
|
617 |
1.1 |
|
618 |
1.1 |
|
619 |
1.1 |
|
620 |
1.1 |
|
621 |
1.1 |
|
622 |
1.1 |
|
623 |
1.1 |
|
624 |
1.1 |
|
625 |
1.1 |
|
626 |
1.1 |
|
627 |
1.1 |