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.IOException; | |
37 | import java.io.InputStream; | |
38 | import java.io.InputStreamReader; | |
39 | import java.io.Reader; | |
40 | import java.util.zip.GZIPInputStream; | |
41 | ||
42 | import org.graphstream.stream.file.dgs.DGSParser; | |
43 | import org.graphstream.util.parser.ParseException; | |
44 | import org.graphstream.util.parser.Parser; | |
45 | import org.graphstream.util.parser.ParserFactory; | |
46 | ||
47 | /** | |
48 | * Class responsible for parsing files in the DGS format. | |
49 | * | |
50 | * <p> | |
51 | * The DGS file format is especially designed for storing dynamic graph | |
52 | * definitions into a file. More information about the DGS file format will be | |
53 | * found on the GraphStream web site: <a | |
54 | * href="http://graphstream-project.org/">http://graphstream-project.org/</a> | |
55 | * </p> | |
56 | * | |
57 | * The usual file name extension used for this format is ".dgs". | |
58 | * | |
59 | * @see FileSource | |
60 | */ | |
61 | public class FileSourceDGS extends FileSourceParser { | |
62 | /* | |
63 | * (non-Javadoc) | |
64 | * | |
65 | * @see org.graphstream.stream.file.FileSourceParser#getNewParserFactory() | |
66 | */ | |
67 | public ParserFactory getNewParserFactory() { | |
68 |
1
1. getNewParserFactory : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS::getNewParserFactory to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new ParserFactory() { |
69 | public Parser newParser(Reader reader) { | |
70 |
1
1. newParser : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS$1::newParser to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new DGSParser(FileSourceDGS.this, reader); |
71 | } | |
72 | }; | |
73 | } | |
74 | ||
75 | @Override | |
76 | public boolean nextStep() throws IOException { | |
77 | try { | |
78 |
1
1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE |
return ((DGSParser) parser).nextStep(); |
79 | } catch (ParseException e) { | |
80 | throw new IOException(e); | |
81 | } | |
82 | } | |
83 | ||
84 | @Override | |
85 | protected Reader createReaderForFile(String filename) throws IOException { | |
86 | InputStream is = null; | |
87 | ||
88 | is = new FileInputStream(filename); | |
89 | ||
90 |
1
1. createReaderForFile : negated conditional → NO_COVERAGE |
if (is.markSupported()) |
91 |
1
1. createReaderForFile : removed call to java/io/InputStream::mark → NO_COVERAGE |
is.mark(128); |
92 | ||
93 | try { | |
94 | is = new GZIPInputStream(is); | |
95 | } catch (IOException e1) { | |
96 | // | |
97 | // This is not a gzip input. | |
98 | // But gzip has eat some bytes so we reset the stream | |
99 | // or close and open it again. | |
100 | // | |
101 |
1
1. createReaderForFile : negated conditional → NO_COVERAGE |
if (is.markSupported()) { |
102 | try { | |
103 |
1
1. createReaderForFile : removed call to java/io/InputStream::reset → NO_COVERAGE |
is.reset(); |
104 | } catch (IOException e2) { | |
105 | // | |
106 | // Dirty but we hope do not get there | |
107 | // | |
108 |
1
1. createReaderForFile : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e2.printStackTrace(); |
109 | } | |
110 | } else { | |
111 | try { | |
112 |
1
1. createReaderForFile : removed call to java/io/InputStream::close → NO_COVERAGE |
is.close(); |
113 | } catch (IOException e2) { | |
114 | // | |
115 | // Dirty but we hope do not get there | |
116 | // | |
117 |
1
1. createReaderForFile : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e2.printStackTrace(); |
118 | } | |
119 | | |
120 | is = new FileInputStream(filename); | |
121 | } | |
122 | } | |
123 | ||
124 |
1
1. createReaderForFile : mutated return of Object value for org/graphstream/stream/file/FileSourceDGS::createReaderForFile to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return new BufferedReader(new InputStreamReader(is)); |
125 | } | |
126 | } | |
Mutations | ||
68 |
1.1 |
|
70 |
1.1 |
|
78 |
1.1 |
|
90 |
1.1 |
|
91 |
1.1 |
|
101 |
1.1 |
|
103 |
1.1 |
|
108 |
1.1 |
|
112 |
1.1 |
|
117 |
1.1 |
|
124 |
1.1 |