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.dgs; | |
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 | import org.graphstream.stream.file.FileSource; | |
48 | import org.graphstream.stream.file.FileSourceBase; | |
49 | ||
50 | /** | |
51 | * Class responsible for parsing files in the DGS format. | |
52 | * | |
53 | * <p> | |
54 | * The DGS file format is especially designed for storing dynamic graph | |
55 | * definitions into a file. More information about the DGS file format will be | |
56 | * found on the GraphStream web site: <a | |
57 | * href="http://graphstream-project.org/">http://graphstream-project.org/</a> | |
58 | * </p> | |
59 | * | |
60 | * The usual file name extension used for this format is ".dgs". | |
61 | * | |
62 | * @see FileSource | |
63 | */ | |
64 | public class OldFileSourceDGS extends FileSourceBase { | |
65 | // Attribute | |
66 | ||
67 | /** | |
68 | * Format version. | |
69 | */ | |
70 | protected int version; | |
71 | ||
72 | /** | |
73 | * Name of the graph. | |
74 | */ | |
75 | protected String graphName; | |
76 | ||
77 | /** | |
78 | * Number of step given in the header. | |
79 | */ | |
80 | protected int stepCountAnnounced; | |
81 | ||
82 | /** | |
83 | * Number of events given in the header. | |
84 | */ | |
85 | protected int eventCountAnnounced; | |
86 | ||
87 | /** | |
88 | * Real number of step at current time. | |
89 | */ | |
90 | protected int stepCount; | |
91 | ||
92 | /** | |
93 | * Real number of events at current time. | |
94 | */ | |
95 | protected int eventCount; | |
96 | ||
97 | /** | |
98 | * An attribute set used everywhere. | |
99 | */ | |
100 | protected HashMap<String, Object> attributes = new HashMap<String, Object>(); | |
101 | ||
102 | /** | |
103 | * True as soon as the end of file is reached. | |
104 | */ | |
105 | protected boolean finished; | |
106 | ||
107 | // Construction | |
108 | ||
109 | /** | |
110 | * New reader for the DGS graph file format version 3. | |
111 | */ | |
112 | public OldFileSourceDGS() { | |
113 | super(true /* EOL is significant */); | |
114 | } | |
115 | ||
116 | // Command -- Parsing | |
117 | ||
118 | @Override | |
119 | public boolean nextEvents() throws IOException { | |
120 |
1
1. nextEvents : negated conditional → NO_COVERAGE |
if (finished) |
121 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
122 | ||
123 |
1
1. nextEvents : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return next(false, false); |
124 | } | |
125 | ||
126 | public boolean nextStep() throws IOException { | |
127 |
1
1. nextStep : negated conditional → NO_COVERAGE |
if (finished) |
128 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
129 | ||
130 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return next(true, false); |
131 | } | |
132 | ||
133 | /** | |
134 | * Read either one event or several. | |
135 | * | |
136 | * @param readSteps | |
137 | * If true, read several events (usually starting with a step | |
138 | * event, but it may be preceded by other events), until another | |
139 | * step is encountered. | |
140 | * @param stop | |
141 | * If true stop at the next step encountered (and push it back so | |
142 | * that is is readable at the next call to this method). | |
143 | * @return True if it remains things to read. | |
144 | */ | |
145 | protected boolean next(boolean readSteps, boolean stop) throws IOException { | |
146 | String key = null; | |
147 | boolean loop = readSteps; | |
148 | ||
149 | // Sorted in probability of appearance ... | |
150 | ||
151 | do { | |
152 | key = getWordOrSymbolOrStringOrEolOrEof(); | |
153 | ||
154 |
1
1. next : negated conditional → NO_COVERAGE |
if (key.equals("ce")) { |
155 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readCE → NO_COVERAGE |
readCE(); |
156 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("cn")) { |
157 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readCN → NO_COVERAGE |
readCN(); |
158 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("ae")) { |
159 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAE → NO_COVERAGE |
readAE(); |
160 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("an")) { |
161 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAN → NO_COVERAGE |
readAN(); |
162 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("de")) { |
163 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readDE → NO_COVERAGE |
readDE(); |
164 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("dn")) { |
165 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readDN → NO_COVERAGE |
readDN(); |
166 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("cg")) { |
167 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readCG → NO_COVERAGE |
readCG(); |
168 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("st")) { |
169 |
1
1. next : negated conditional → NO_COVERAGE |
if (readSteps) { |
170 |
1
1. next : negated conditional → NO_COVERAGE |
if (stop) { |
171 | loop = false; | |
172 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
173 | } else { | |
174 | stop = true; | |
175 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readST → NO_COVERAGE |
readST(); |
176 | } | |
177 | } else { | |
178 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readST → NO_COVERAGE |
readST(); |
179 | } | |
180 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("#")) { |
181 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatAllUntilEol → NO_COVERAGE |
eatAllUntilEol(); |
182 |
1
1. next : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return next(readSteps, stop); |
183 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("EOL")) { |
184 | // Probably an empty line. | |
185 | // NOP | |
186 |
1
1. next : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return next(readSteps, stop); |
187 |
1
1. next : negated conditional → NO_COVERAGE |
} else if (key.equals("EOF")) { |
188 | finished = true; | |
189 |
1
1. next : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return false; |
190 | } else { | |
191 |
1
1. next : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::parseError → NO_COVERAGE |
parseError("unknown token '" + key + "'"); |
192 | } | |
193 |
1
1. next : negated conditional → NO_COVERAGE |
} while (loop); |
194 | ||
195 |
1
1. next : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return true; |
196 | } | |
197 | ||
198 | protected void readCE() throws IOException { | |
199 | String tag = getStringOrWordOrNumber(); | |
200 | ||
201 |
1
1. readCE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(attributes); |
202 | ||
203 |
1
1. readCE : negated conditional → NO_COVERAGE |
for (String key : attributes.keySet()) { |
204 | Object value = attributes.get(key); | |
205 | ||
206 |
1
1. readCE : negated conditional → NO_COVERAGE |
if (value == null) |
207 |
1
1. readCE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendEdgeAttributeRemoved → NO_COVERAGE |
sendEdgeAttributeRemoved(graphName, tag, key); |
208 | else | |
209 |
1
1. readCE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendEdgeAttributeChanged → NO_COVERAGE |
sendEdgeAttributeChanged(graphName, tag, key, null, value); |
210 | } | |
211 | ||
212 |
1
1. readCE : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
213 |
1
1. readCE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
214 | } | |
215 | ||
216 | protected void readCN() throws IOException { | |
217 | String tag = getStringOrWordOrNumber(); | |
218 | ||
219 |
1
1. readCN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(attributes); |
220 | ||
221 |
1
1. readCN : negated conditional → NO_COVERAGE |
for (String key : attributes.keySet()) { |
222 | Object value = attributes.get(key); | |
223 | ||
224 |
1
1. readCN : negated conditional → NO_COVERAGE |
if (value == null) |
225 |
1
1. readCN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendNodeAttributeRemoved → NO_COVERAGE |
sendNodeAttributeRemoved(graphName, tag, key); |
226 | else | |
227 |
1
1. readCN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendNodeAttributeChanged → NO_COVERAGE |
sendNodeAttributeChanged(graphName, tag, key, null, value); |
228 | } | |
229 | ||
230 |
1
1. readCN : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
231 |
1
1. readCN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
232 | } | |
233 | ||
234 | protected void readCG() throws IOException { | |
235 |
1
1. readCG : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(attributes); |
236 | ||
237 |
1
1. readCG : negated conditional → NO_COVERAGE |
for (String key : attributes.keySet()) { |
238 | Object value = attributes.get(key); | |
239 | ||
240 |
1
1. readCG : negated conditional → NO_COVERAGE |
if (value == null) |
241 |
1
1. readCG : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendGraphAttributeRemoved → NO_COVERAGE |
sendGraphAttributeRemoved(graphName, key); |
242 | else | |
243 |
1
1. readCG : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendGraphAttributeChanged → NO_COVERAGE |
sendGraphAttributeChanged(graphName, key, null, value); |
244 | } | |
245 | ||
246 |
1
1. readCG : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
247 |
1
1. readCG : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
248 | } | |
249 | ||
250 | protected void readAE() throws IOException { | |
251 | int dir = 0; | |
252 | boolean directed = false; | |
253 | String dirc = null; | |
254 | String tag = null; | |
255 | String fromTag = null; | |
256 | String toTag = null; | |
257 | ||
258 | tag = getStringOrWordOrNumber(); | |
259 | fromTag = getStringOrWordOrNumber(); | |
260 | dirc = getWordOrSymbolOrNumberOrStringOrEolOrEof(); | |
261 | ||
262 |
1
1. readAE : negated conditional → NO_COVERAGE |
if (dirc.equals(">")) { |
263 | directed = true; | |
264 | dir = 1; | |
265 |
1
1. readAE : negated conditional → NO_COVERAGE |
} else if (dirc.equals("<")) { |
266 | directed = true; | |
267 | dir = 2; | |
268 | } else { | |
269 |
1
1. readAE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
270 | } | |
271 | ||
272 | toTag = getStringOrWordOrNumber(); | |
273 | ||
274 |
1
1. readAE : negated conditional → NO_COVERAGE |
if (dir == 2) { |
275 | String tmp = toTag; | |
276 | toTag = fromTag; | |
277 | fromTag = tmp; | |
278 | } | |
279 | ||
280 |
1
1. readAE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(attributes); |
281 |
1
1. readAE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendEdgeAdded → NO_COVERAGE |
sendEdgeAdded(graphName, tag, fromTag, toTag, directed); |
282 | ||
283 |
1
1. readAE : negated conditional → NO_COVERAGE |
for (String key : attributes.keySet()) { |
284 | Object value = attributes.get(key); | |
285 |
1
1. readAE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendEdgeAttributeAdded → NO_COVERAGE |
sendEdgeAttributeAdded(graphName, tag, key, value); |
286 | } | |
287 | ||
288 |
1
1. readAE : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
289 |
1
1. readAE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
290 | } | |
291 | ||
292 | protected void readAN() throws IOException { | |
293 | String tag = getStringOrWordOrNumber(); | |
294 | ||
295 |
1
1. readAN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(attributes); |
296 | ||
297 |
1
1. readAN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendNodeAdded → NO_COVERAGE |
sendNodeAdded(graphName, tag); |
298 | ||
299 |
1
1. readAN : negated conditional → NO_COVERAGE |
for (String key : attributes.keySet()) { |
300 | Object value = attributes.get(key); | |
301 |
1
1. readAN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendNodeAttributeAdded → NO_COVERAGE |
sendNodeAttributeAdded(graphName, tag, key, value); |
302 | } | |
303 | ||
304 |
1
1. readAN : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
305 |
1
1. readAN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
306 | } | |
307 | ||
308 | protected void readDE() throws IOException { | |
309 | String tag = getStringOrWordOrNumber(); | |
310 | ||
311 |
1
1. readDE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendEdgeRemoved → NO_COVERAGE |
sendEdgeRemoved(graphName, tag); |
312 | ||
313 |
1
1. readDE : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
314 |
1
1. readDE : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
315 | } | |
316 | ||
317 | protected void readDN() throws IOException { | |
318 | String tag = getStringOrWordOrNumber(); | |
319 | ||
320 |
1
1. readDN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendNodeRemoved → NO_COVERAGE |
sendNodeRemoved(graphName, tag); |
321 | ||
322 |
1
1. readDN : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
323 |
1
1. readDN : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
324 | } | |
325 | ||
326 | protected void readST() throws IOException { | |
327 | String w = getWordOrNumber(); | |
328 | ||
329 | try { | |
330 | double time = Double.parseDouble(w); | |
331 | ||
332 |
1
1. readST : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendStepBegins → NO_COVERAGE |
sendStepBegins(graphName, time); |
333 | } catch (NumberFormatException e) { | |
334 |
1
1. readST : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::parseError → NO_COVERAGE |
parseError("expecting a number after `st', got `" + w + "'"); |
335 | } | |
336 | ||
337 |
1
1. readST : negated conditional → NO_COVERAGE |
if (eatEolOrEof() == StreamTokenizer.TT_EOF) |
338 |
1
1. readST : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
339 | } | |
340 | ||
341 | protected void readAttributes(HashMap<String, Object> attributes) | |
342 | throws IOException { | |
343 | boolean del = false; | |
344 | String key = getWordOrSymbolOrStringOrEolOrEof(); | |
345 | ||
346 |
1
1. readAttributes : removed call to java/util/HashMap::clear → NO_COVERAGE |
attributes.clear(); |
347 | ||
348 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (key.equals("-")) { |
349 | key = getWordOrSymbolOrStringOrEolOrEof(); | |
350 | del = true; | |
351 | } | |
352 | ||
353 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (key.equals("+")) |
354 | key = getWordOrSymbolOrStringOrEolOrEof(); | |
355 | ||
356 |
3
1. readAttributes : negated conditional → NO_COVERAGE 2. readAttributes : negated conditional → NO_COVERAGE 3. readAttributes : negated conditional → NO_COVERAGE |
while (!key.equals("EOF") && !key.equals("EOL") && !key.equals("]")) { |
357 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (del) |
358 | attributes.put(key, null); | |
359 | else | |
360 | attributes.put(key, readAttributeValue(key)); | |
361 | ||
362 | key = getWordOrSymbolOrStringOrEolOrEof(); | |
363 | ||
364 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (key.equals("-")) { |
365 | key = getWordOrStringOrEolOrEof(); | |
366 | del = true; | |
367 | } | |
368 | ||
369 |
1
1. readAttributes : negated conditional → NO_COVERAGE |
if (key.equals("+")) { |
370 | key = getWordOrStringOrEolOrEof(); | |
371 | del = false; | |
372 | } | |
373 | } | |
374 | ||
375 |
1
1. readAttributes : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
376 | } | |
377 | ||
378 | /** | |
379 | * Read an attribute. The "key" (attribute name) is already read. | |
380 | * | |
381 | * @param key | |
382 | * The attribute name, already read. | |
383 | */ | |
384 | protected Object readAttributeValue(String key) throws IOException { | |
385 | ArrayList<Object> vector = null; | |
386 | Object value = null; | |
387 | Object value2 = null; | |
388 | String next = null; | |
389 | ||
390 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
if (key != null) |
391 | eatSymbols(":="); | |
392 | ||
393 | value = getStringOrWordOrSymbolOrNumberO(); | |
394 | ||
395 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
if (value.equals("[")) { |
396 | HashMap<String, Object> map = new HashMap<String, Object>(); | |
397 | ||
398 |
1
1. readAttributeValue : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributes → NO_COVERAGE |
readAttributes(map); |
399 | ; | |
400 |
1
1. readAttributeValue : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatSymbol → NO_COVERAGE |
eatSymbol(']'); |
401 | ||
402 | value = map; | |
403 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
} else if (value.equals("{")) { |
404 | vector = readAttributeArray(key); | |
405 |
1
1. readAttributeValue : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatSymbol → NO_COVERAGE |
eatSymbol('}'); |
406 | } else { | |
407 |
1
1. readAttributeValue : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
408 | ||
409 | value = getStringOrWordOrNumberO(); | |
410 | ||
411 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
if (key != null) { |
412 | next = getWordOrSymbolOrNumberOrStringOrEolOrEof(); | |
413 | ||
414 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
while (next.equals(",")) { |
415 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
if (vector == null) { |
416 | vector = new ArrayList<Object>(); | |
417 | vector.add(value); | |
418 | } | |
419 | ||
420 | value2 = getStringOrWordOrNumberO(); | |
421 | next = getWordOrSymbolOrNumberOrStringOrEolOrEof(); | |
422 | ||
423 | vector.add(value2); | |
424 | } | |
425 | ||
426 |
1
1. readAttributeValue : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
427 | } | |
428 | } | |
429 | ||
430 |
1
1. readAttributeValue : negated conditional → NO_COVERAGE |
if (vector != null) |
431 |
1
1. readAttributeValue : mutated return of Object value for org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return vector.toArray(); |
432 | else | |
433 |
1
1. readAttributeValue : mutated return of Object value for org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributeValue to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return value; |
434 | } | |
435 | ||
436 | /** | |
437 | * Read a list of values. | |
438 | * | |
439 | * @param key | |
440 | * attribute key | |
441 | * @return a vector | |
442 | * @throws IOException | |
443 | */ | |
444 | protected ArrayList<Object> readAttributeArray(String key) | |
445 | throws IOException { | |
446 | ArrayList<Object> list = new ArrayList<Object>(); | |
447 | ||
448 | Object value; | |
449 | String next; | |
450 | ||
451 | do { | |
452 | value = readAttributeValue(null); | |
453 | next = getWordOrSymbolOrNumberOrStringOrEolOrEof(); | |
454 | ||
455 | list.add(value); | |
456 |
1
1. readAttributeArray : negated conditional → NO_COVERAGE |
} while (next.equals(",")); |
457 | ||
458 |
1
1. readAttributeArray : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::pushBack → NO_COVERAGE |
pushBack(); |
459 | ||
460 |
1
1. readAttributeArray : mutated return of Object value for org/graphstream/stream/file/dgs/OldFileSourceDGS::readAttributeArray to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return list; |
461 | } | |
462 | ||
463 | // Command -- Basic parsing | |
464 | ||
465 | @Override | |
466 | public void begin(String filename) throws IOException { | |
467 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(filename); |
468 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::begin → NO_COVERAGE |
begin(); |
469 | } | |
470 | ||
471 | @Override | |
472 | public void begin(URL url) throws IOException { | |
473 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(url); |
474 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::begin → NO_COVERAGE |
begin(); |
475 | } | |
476 | ||
477 | @Override | |
478 | public void begin(InputStream stream) throws IOException { | |
479 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(stream); |
480 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::begin → NO_COVERAGE |
begin(); |
481 | } | |
482 | ||
483 | @Override | |
484 | public void begin(Reader reader) throws IOException { | |
485 |
1
1. begin : removed call to org/graphstream/stream/file/FileSourceBase::begin → NO_COVERAGE |
super.begin(reader); |
486 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::begin → NO_COVERAGE |
begin(); |
487 | } | |
488 | ||
489 | protected void begin() throws IOException { | |
490 |
1
1. begin : removed call to java/io/StreamTokenizer::parseNumbers → NO_COVERAGE |
st.parseNumbers(); |
491 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatWords → NO_COVERAGE |
eatWords("DGS003", "DGS004"); |
492 | ||
493 | version = 3; | |
494 | ||
495 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatEol → NO_COVERAGE |
eatEol(); |
496 | graphName = getWordOrString(); | |
497 | stepCountAnnounced = (int) getNumber();// Integer.parseInt( getWord() ); | |
498 | eventCountAnnounced = (int) getNumber();// Integer.parseInt( getWord() | |
499 | // ); | |
500 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::eatEol → NO_COVERAGE |
eatEol(); |
501 | ||
502 |
1
1. begin : negated conditional → NO_COVERAGE |
if (graphName != null) |
503 |
1
1. begin : removed call to org/graphstream/stream/file/dgs/OldFileSourceDGS::sendGraphAttributeAdded → NO_COVERAGE |
sendGraphAttributeAdded(graphName, "label", graphName); |
504 | else | |
505 | graphName = "DGS_"; | |
506 | ||
507 | graphName = String.format("%s_%d", graphName, | |
508 |
2
1. begin : Replaced long multiplication with division → NO_COVERAGE 2. begin : Replaced long addition with subtraction → NO_COVERAGE |
System.currentTimeMillis() + ((long) Math.random() * 10)); |
509 | } | |
510 | ||
511 | @Override | |
512 | protected void continueParsingInInclude() throws IOException { | |
513 | } | |
514 | ||
515 | @Override | |
516 | protected Reader createReaderFrom(String file) throws FileNotFoundException { | |
517 | InputStream is = null; | |
518 | ||
519 | is = new FileInputStream(file); | |
520 | ||
521 |
1
1. createReaderFrom : negated conditional → NO_COVERAGE |
if (is.markSupported()) |
522 |
1
1. createReaderFrom : removed call to java/io/InputStream::mark → NO_COVERAGE |
is.mark(128); |
523 | ||
524 | try { | |
525 | is = new GZIPInputStream(is); | |
526 | } catch (IOException e1) { | |
527 | // | |
528 | // This is not a gzip input. | |
529 | // But gzip has eat some bytes so we reset the stream | |
530 | // or close and open it again. | |
531 | // | |
532 |
1
1. createReaderFrom : negated conditional → NO_COVERAGE |
if (is.markSupported()) { |
533 | try { | |
534 |
1
1. createReaderFrom : removed call to java/io/InputStream::reset → NO_COVERAGE |
is.reset(); |
535 | } catch (IOException e2) { | |
536 | // | |
537 | // Dirty but we hope do not get there | |
538 | // | |
539 |
1
1. createReaderFrom : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e2.printStackTrace(); |
540 | } | |
541 | } else { | |
542 | try { | |
543 |
1
1. createReaderFrom : removed call to java/io/InputStream::close → NO_COVERAGE |
is.close(); |
544 | } catch (IOException e2) { | |
545 | // | |
546 | // Dirty but we hope do not get there | |
547 | // | |
548 |
1
1. createReaderFrom : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e2.printStackTrace(); |
549 | } | |
550 | | |
551 | is = new FileInputStream(file); | |
552 | } | |
553 | } | |
554 | ||
555 |
1
1. createReaderFrom : mutated return of Object value for org/graphstream/stream/file/dgs/OldFileSourceDGS::createReaderFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new BufferedReader(new InputStreamReader(is)); |
556 | } | |
557 | ||
558 | @Override | |
559 | protected Reader createReaderFrom(InputStream stream) { | |
560 |
1
1. createReaderFrom : mutated return of Object value for org/graphstream/stream/file/dgs/OldFileSourceDGS::createReaderFrom to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new BufferedReader(new InputStreamReader(stream)); |
561 | } | |
562 | ||
563 | @Override | |
564 | protected void configureTokenizer(StreamTokenizer tok) throws IOException { | |
565 |
2
1. configureTokenizer : changed conditional boundary → NO_COVERAGE 2. configureTokenizer : negated conditional → NO_COVERAGE |
if (COMMENT_CHAR > 0) |
566 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::commentChar → NO_COVERAGE |
tok.commentChar(COMMENT_CHAR); |
567 | // tok.quoteChar( QUOTE_CHAR ); | |
568 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::eolIsSignificant → NO_COVERAGE |
tok.eolIsSignificant(eol_is_significant); |
569 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::parseNumbers → NO_COVERAGE |
tok.parseNumbers(); |
570 |
1
1. configureTokenizer : removed call to java/io/StreamTokenizer::wordChars → NO_COVERAGE |
tok.wordChars('_', '_'); |
571 | } | |
572 | } | |
Mutations | ||
120 |
1.1 |
|
121 |
1.1 |
|
123 |
1.1 |
|
127 |
1.1 |
|
128 |
1.1 |
|
130 |
1.1 |
|
154 |
1.1 |
|
155 |
1.1 |
|
156 |
1.1 |
|
157 |
1.1 |
|
158 |
1.1 |
|
159 |
1.1 |
|
160 |
1.1 |
|
161 |
1.1 |
|
162 |
1.1 |
|
163 |
1.1 |
|
164 |
1.1 |
|
165 |
1.1 |
|
166 |
1.1 |
|
167 |
1.1 |
|
168 |
1.1 |
|
169 |
1.1 |
|
170 |
1.1 |
|
172 |
1.1 |
|
175 |
1.1 |
|
178 |
1.1 |
|
180 |
1.1 |
|
181 |
1.1 |
|
182 |
1.1 |
|
183 |
1.1 |
|
186 |
1.1 |
|
187 |
1.1 |
|
189 |
1.1 |
|
191 |
1.1 |
|
193 |
1.1 |
|
195 |
1.1 |
|
201 |
1.1 |
|
203 |
1.1 |
|
206 |
1.1 |
|
207 |
1.1 |
|
209 |
1.1 |
|
212 |
1.1 |
|
213 |
1.1 |
|
219 |
1.1 |
|
221 |
1.1 |
|
224 |
1.1 |
|
225 |
1.1 |
|
227 |
1.1 |
|
230 |
1.1 |
|
231 |
1.1 |
|
235 |
1.1 |
|
237 |
1.1 |
|
240 |
1.1 |
|
241 |
1.1 |
|
243 |
1.1 |
|
246 |
1.1 |
|
247 |
1.1 |
|
262 |
1.1 |
|
265 |
1.1 |
|
269 |
1.1 |
|
274 |
1.1 |
|
280 |
1.1 |
|
281 |
1.1 |
|
283 |
1.1 |
|
285 |
1.1 |
|
288 |
1.1 |
|
289 |
1.1 |
|
295 |
1.1 |
|
297 |
1.1 |
|
299 |
1.1 |
|
301 |
1.1 |
|
304 |
1.1 |
|
305 |
1.1 |
|
311 |
1.1 |
|
313 |
1.1 |
|
314 |
1.1 |
|
320 |
1.1 |
|
322 |
1.1 |
|
323 |
1.1 |
|
332 |
1.1 |
|
334 |
1.1 |
|
337 |
1.1 |
|
338 |
1.1 |
|
346 |
1.1 |
|
348 |
1.1 |
|
353 |
1.1 |
|
356 |
1.1 2.2 3.3 |
|
357 |
1.1 |
|
364 |
1.1 |
|
369 |
1.1 |
|
375 |
1.1 |
|
390 |
1.1 |
|
395 |
1.1 |
|
398 |
1.1 |
|
400 |
1.1 |
|
403 |
1.1 |
|
405 |
1.1 |
|
407 |
1.1 |
|
411 |
1.1 |
|
414 |
1.1 |
|
415 |
1.1 |
|
426 |
1.1 |
|
430 |
1.1 |
|
431 |
1.1 |
|
433 |
1.1 |
|
456 |
1.1 |
|
458 |
1.1 |
|
460 |
1.1 |
|
467 |
1.1 |
|
468 |
1.1 |
|
473 |
1.1 |
|
474 |
1.1 |
|
479 |
1.1 |
|
480 |
1.1 |
|
485 |
1.1 |
|
486 |
1.1 |
|
490 |
1.1 |
|
491 |
1.1 |
|
495 |
1.1 |
|
500 |
1.1 |
|
502 |
1.1 |
|
503 |
1.1 |
|
508 |
1.1 2.2 |
|
521 |
1.1 |
|
522 |
1.1 |
|
532 |
1.1 |
|
534 |
1.1 |
|
539 |
1.1 |
|
543 |
1.1 |
|
548 |
1.1 |
|
555 |
1.1 |
|
560 |
1.1 |
|
565 |
1.1 2.2 |
|
566 |
1.1 |
|
568 |
1.1 |
|
569 |
1.1 |
|
570 |
1.1 |