FileSourceGML.java

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.io.Reader;
36
37
import org.graphstream.stream.file.gml.GMLParser;
38
39
import org.graphstream.util.parser.ParseException;
40
import org.graphstream.util.parser.Parser;
41
import org.graphstream.util.parser.ParserFactory;
42
43
/**
44
 * A GML parser.
45
 * 
46
 * This parser should understand the whole GML syntax. It transforms any
47
 * unknown tag into an attribute. Depending on the location of the unknown
48
 * tag, the attribute is added to the graph, to nodes or to the edges.
49
 * 
50
 * The "graphics" attributes are, as far as possible, transformed into
51
 * "ui.style" attributes that are merged with the style sheet. The understood
52
 * graphics tags are "x", "y", "z", "w", "h", "d" for position and size,
53
 * "fill" for the background color (becomes "fill-color"), "outline" (becomes
54
 * "stroke-color"), "type" (becomes "shape", the known shapes being
55
 * the ones of the GraphStream CSS, plus the "ellipse" tag wich maps
56
 * to "circle" and the "rectangle" tag that maps to "box"), "outline_width" (becomes
57
 * "stroke-width", in pixels).
58
 * 
59
 * If edges have no "id" tag, the id is the concatenation of the source
60
 * and target node identifiers separated by a "_" character and a random
61
 * number.
62
 * 
63
 * You can declare nodes either with the full declaration:
64
 * <pre>
65
 * 		node [ Id "foo" ]
66
 * </pre>
67
 * Which is useful when adding attributes to it. Or you can use a lighter
68
 * declaration with:
69
 * <pre>
70
 *      node "foo"
71
 * </pre> 
72
 * 
73
 * You can also remove nodes and edges by using:
74
 * <pre>
75
 *      -node "foo"
76
 *      del-node "foo"
77
 *      -node [ Id "foo" ]
78
 *      del-node [ Id "foo" ]
79
 * </pre>
80
 * And the same for edges with "-edge" or "del-edge".
81
 * 
82
 * All the dynamic events of GraphStream are supported as an extension.
83
 * 
84
 * You can add or remove attributes to or from a node or edge using a
85
 * minus sign in front of the attribute name and following the attribute
86
 * name by [].
87
 * 
88
 * You can remove a node or edge using a minus sign in front of the
89
 * node and edge tags:
90
 * <pre>
91
 *     -node [ id "foo"��]
92
 * </pre>
93
 * Or
94
 * <pre>
95
 *     -node "foo"
96
 * </pre>
97
 * 
98
 * You can change the attributes of a node or edge using a plus sign
99
 * in front of the node and edge tags:
100
 * <pre>
101
 *     +node [ id "foo" someAttribute "added" -removedAttribute [] ]
102
 * </pre>
103
 * 
104
 * Be careful, that files exported with the dynamic extensions will not
105
 * be compatible with most GML readers of other programs.
106
 * 
107
 * The standard extension for GML files is ".gml". If your file contains
108
 * dynamic additions, you can use the ".dgml" (Dynamic GML) extensions.
109
 * The parser will handle both dynamic and non dynamic files with the
110
 * extension ".gml".
111
 */
112
public class FileSourceGML extends FileSourceParser {
113
	
114
	/*
115
	 * (non-Javadoc)
116
	 * @see org.graphstream.stream.file.FileSourceParser#nextStep()
117
	 */
118
	public boolean nextStep() throws IOException {
119
		try {
120 1 1. nextStep : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
			return ((GMLParser) parser).step();
121
		} catch(ParseException e) {
122
			throw new IOException(e);
123
		}
124
	}
125
126
	/*
127
	 * (non-Javadoc)
128
	 * @see org.graphstream.stream.file.FileSourceParser#getNewParserFactory()
129
	 */
130
	public ParserFactory getNewParserFactory() { 
131 1 1. getNewParserFactory : mutated return of Object value for org/graphstream/stream/file/FileSourceGML::getNewParserFactory to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
		return new ParserFactory() {
132
			public Parser newParser(Reader reader) {
133 1 1. newParser : mutated return of Object value for org/graphstream/stream/file/FileSourceGML$1::newParser to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
				return new GMLParser(FileSourceGML.this, reader);
134
			}
135
		};
136
	}
137
}

Mutations

120

1.1
Location : nextStep
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

131

1.1
Location : getNewParserFactory
Killed by : none
mutated return of Object value for org/graphstream/stream/file/FileSourceGML::getNewParserFactory to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

133

1.1
Location : newParser
Killed by : none
mutated return of Object value for org/graphstream/stream/file/FileSourceGML$1::newParser to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.33