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.IOException; | |
35 | import java.util.HashMap; | |
36 | ||
37 | import org.graphstream.graph.Edge; | |
38 | import org.graphstream.graph.Graph; | |
39 | import org.graphstream.graph.Node; | |
40 | ||
41 | public class FileSinkGraphML extends FileSinkBase { | |
42 | ||
43 | protected void outputEndOfFile() throws IOException { | |
44 |
1
1. outputEndOfFile : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("</graphml>\n"); |
45 | } | |
46 | ||
47 | protected void outputHeader() throws IOException { | |
48 |
1
1. outputHeader : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
49 |
1
1. outputHeader : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("<graphml xmlns=\"http://graphml.graphdrawing.org/xmlns\"\n"); |
50 |
1
1. outputHeader : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"); |
51 |
1
1. outputHeader : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns\n"); |
52 |
1
1. outputHeader : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\">\n"); |
53 | } | |
54 | ||
55 | private void print(String format, Object... args) throws IOException { | |
56 |
1
1. print : removed call to java/io/Writer::write → NO_COVERAGE |
output.write(String.format(format, args)); |
57 | } | |
58 | ||
59 | @Override | |
60 | protected void exportGraph(Graph g) { | |
61 | try { | |
62 | int attribute = 0; | |
63 | HashMap<String, String> nodeAttributes = new HashMap<String, String>(); | |
64 | HashMap<String, String> edgeAttributes = new HashMap<String, String>(); | |
65 | ||
66 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (Node n : g.getEachNode()) { |
67 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (String k : n.getAttributeKeySet()) { |
68 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (!nodeAttributes.containsKey(k)) { |
69 | Object value = n.getAttribute(k); | |
70 | String type; | |
71 | ||
72 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (value == null) |
73 | continue; | |
74 | ||
75 |
1
1. exportGraph : Changed increment from 1 to -1 → NO_COVERAGE |
String id = String.format("attr%04X", attribute++); |
76 | ||
77 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (value instanceof Boolean) |
78 | type = "boolean"; | |
79 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Long) |
80 | type = "long"; | |
81 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Integer) |
82 | type = "int"; | |
83 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Double) |
84 | type = "double"; | |
85 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Float) |
86 | type = "float"; | |
87 | else | |
88 | type = "string"; | |
89 | ||
90 | nodeAttributes.put(k, id); | |
91 | ||
92 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print( |
93 | "\t<key id=\"%s\" for=\"node\" attr.name=\"%s\" attr.type=\"%s\"/>\n", | |
94 | id, k, type); | |
95 | } | |
96 | } | |
97 | } | |
98 | ||
99 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (Edge n : g.getEachEdge()) { |
100 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (String k : n.getAttributeKeySet()) { |
101 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (!edgeAttributes.containsKey(k)) { |
102 | Object value = n.getAttribute(k); | |
103 | String type; | |
104 | ||
105 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (value == null) |
106 | continue; | |
107 | ||
108 |
1
1. exportGraph : Changed increment from 1 to -1 → NO_COVERAGE |
String id = String.format("attr%04X", attribute++); |
109 | ||
110 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
if (value instanceof Boolean) |
111 | type = "boolean"; | |
112 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Long) |
113 | type = "long"; | |
114 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Integer) |
115 | type = "int"; | |
116 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Double) |
117 | type = "double"; | |
118 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
else if (value instanceof Float) |
119 | type = "float"; | |
120 | else | |
121 | type = "string"; | |
122 | ||
123 | edgeAttributes.put(k, id); | |
124 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print( |
125 | "\t<key id=\"%s\" for=\"edge\" attr.name=\"%s\" attr.type=\"%s\"/>\n", | |
126 | id, k, type); | |
127 | } | |
128 | } | |
129 | } | |
130 | ||
131 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t<graph id=\"%s\" edgedefault=\"undirected\">\n", g.getId()); |
132 | ||
133 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (Node n : g.getEachNode()) { |
134 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t\t<node id=\"%s\">\n", n.getId()); |
135 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (String k : n.getAttributeKeySet()) { |
136 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t\t\t<data key=\"%s\">%s</data>\n", nodeAttributes |
137 | .get(k), n.getAttribute(k).toString()); | |
138 | } | |
139 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t\t</node>\n"); |
140 | } | |
141 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (Edge e : g.getEachEdge()) { |
142 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print( |
143 | "\t\t<edge id=\"%s\" source=\"%s\" target=\"%s\" directed=\"%s\">\n", | |
144 | e.getId(), e.getSourceNode().getId(), e.getTargetNode() | |
145 | .getId(), e.isDirected()); | |
146 |
1
1. exportGraph : negated conditional → NO_COVERAGE |
for (String k : e.getAttributeKeySet()) { |
147 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t\t\t<data key=\"%s\">%s</data>\n", edgeAttributes |
148 | .get(k), e.getAttribute(k).toString()); | |
149 | } | |
150 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t\t</edge>\n"); |
151 | } | |
152 |
1
1. exportGraph : removed call to org/graphstream/stream/file/FileSinkGraphML::print → NO_COVERAGE |
print("\t</graph>\n"); |
153 | } catch (IOException e) { | |
154 |
1
1. exportGraph : removed call to java/io/IOException::printStackTrace → NO_COVERAGE |
e.printStackTrace(); |
155 | } | |
156 | } | |
157 | ||
158 | public void edgeAttributeAdded(String sourceId, long timeId, String edgeId, | |
159 | String attribute, Object value) { | |
160 | throw new UnsupportedOperationException(); | |
161 | } | |
162 | ||
163 | public void edgeAttributeChanged(String sourceId, long timeId, | |
164 | String edgeId, String attribute, Object oldValue, Object newValue) { | |
165 | throw new UnsupportedOperationException(); | |
166 | } | |
167 | ||
168 | public void edgeAttributeRemoved(String sourceId, long timeId, | |
169 | String edgeId, String attribute) { | |
170 | throw new UnsupportedOperationException(); | |
171 | } | |
172 | ||
173 | public void graphAttributeAdded(String sourceId, long timeId, | |
174 | String attribute, Object value) { | |
175 | throw new UnsupportedOperationException(); | |
176 | } | |
177 | ||
178 | public void graphAttributeChanged(String sourceId, long timeId, | |
179 | String attribute, Object oldValue, Object newValue) { | |
180 | throw new UnsupportedOperationException(); | |
181 | } | |
182 | ||
183 | public void graphAttributeRemoved(String sourceId, long timeId, | |
184 | String attribute) { | |
185 | throw new UnsupportedOperationException(); | |
186 | } | |
187 | ||
188 | public void nodeAttributeAdded(String sourceId, long timeId, String nodeId, | |
189 | String attribute, Object value) { | |
190 | throw new UnsupportedOperationException(); | |
191 | } | |
192 | ||
193 | public void nodeAttributeChanged(String sourceId, long timeId, | |
194 | String nodeId, String attribute, Object oldValue, Object newValue) { | |
195 | throw new UnsupportedOperationException(); | |
196 | } | |
197 | ||
198 | public void nodeAttributeRemoved(String sourceId, long timeId, | |
199 | String nodeId, String attribute) { | |
200 | throw new UnsupportedOperationException(); | |
201 | } | |
202 | ||
203 | public void edgeAdded(String sourceId, long timeId, String edgeId, | |
204 | String fromNodeId, String toNodeId, boolean directed) { | |
205 | throw new UnsupportedOperationException(); | |
206 | } | |
207 | ||
208 | public void edgeRemoved(String sourceId, long timeId, String edgeId) { | |
209 | throw new UnsupportedOperationException(); | |
210 | } | |
211 | ||
212 | public void graphCleared(String sourceId, long timeId) { | |
213 | throw new UnsupportedOperationException(); | |
214 | } | |
215 | ||
216 | public void nodeAdded(String sourceId, long timeId, String nodeId) { | |
217 | throw new UnsupportedOperationException(); | |
218 | } | |
219 | ||
220 | public void nodeRemoved(String sourceId, long timeId, String nodeId) { | |
221 | throw new UnsupportedOperationException(); | |
222 | } | |
223 | ||
224 | public void stepBegins(String sourceId, long timeId, double step) { | |
225 | throw new UnsupportedOperationException(); | |
226 | } | |
227 | ||
228 | } | |
Mutations | ||
44 |
1.1 |
|
48 |
1.1 |
|
49 |
1.1 |
|
50 |
1.1 |
|
51 |
1.1 |
|
52 |
1.1 |
|
56 |
1.1 |
|
66 |
1.1 |
|
67 |
1.1 |
|
68 |
1.1 |
|
72 |
1.1 |
|
75 |
1.1 |
|
77 |
1.1 |
|
79 |
1.1 |
|
81 |
1.1 |
|
83 |
1.1 |
|
85 |
1.1 |
|
92 |
1.1 |
|
99 |
1.1 |
|
100 |
1.1 |
|
101 |
1.1 |
|
105 |
1.1 |
|
108 |
1.1 |
|
110 |
1.1 |
|
112 |
1.1 |
|
114 |
1.1 |
|
116 |
1.1 |
|
118 |
1.1 |
|
124 |
1.1 |
|
131 |
1.1 |
|
133 |
1.1 |
|
134 |
1.1 |
|
135 |
1.1 |
|
136 |
1.1 |
|
139 |
1.1 |
|
141 |
1.1 |
|
142 |
1.1 |
|
146 |
1.1 |
|
147 |
1.1 |
|
150 |
1.1 |
|
152 |
1.1 |
|
154 |
1.1 |