StepCounter.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.util;
33
34
import java.io.IOException;
35
36
import org.graphstream.stream.SinkAdapter;
37
import org.graphstream.stream.file.FileSource;
38
import org.graphstream.stream.file.FileSourceFactory;
39
40
/**
41
 * Count the step of a stream.
42
 */
43
public class StepCounter extends SinkAdapter {
44
	/**
45
	 * Count step contains in a file.
46
	 * 
47
	 * @param path
48
	 *            path to the file
49
	 * @return count of step event in the file
50
	 * @throws IOException
51
	 * @see org.graphstream.stream.file.FileSourceFactory
52
	 */
53
	public static int countStepInFile(String path) throws IOException {
54
		StepCounter counter = new StepCounter();
55
		FileSource source = FileSourceFactory.sourceFor(path);
56
57 1 1. countStepInFile : removed call to org/graphstream/stream/file/FileSource::addElementSink → NO_COVERAGE
		source.addElementSink(counter);
58 1 1. countStepInFile : removed call to org/graphstream/stream/file/FileSource::readAll → NO_COVERAGE
		source.readAll(path);
59
60 1 1. countStepInFile : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return counter.getStepCount();
61
	}
62
	
63
	protected int step;
64
65
	/**
66
	 * Default constructor. Count is set to zero.
67
	 */
68
	public StepCounter() {
69 1 1. : removed call to org/graphstream/util/StepCounter::reset → NO_COVERAGE
		reset();
70
	}
71
72
	/**
73
	 * Reset the step count to zero.
74
	 */
75
	public void reset() {
76
		step = 0;
77
	}
78
79
	/**
80
	 * Get the step count.
81
	 * 
82
	 * @return the count of step
83
	 */
84
	public int getStepCount() {
85 1 1. getStepCount : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
		return step;
86
	}
87
88
	/*
89
	 * (non-Javadoc)
90
	 * 
91
	 * @see org.graphstream.stream.SinkAdapter#stepBegins(java.lang.String,
92
	 * long, double)
93
	 */
94
	public void stepBegins(String sourceId, long timeId, double time) {
95 1 1. stepBegins : Replaced integer addition with subtraction → NO_COVERAGE
		step++;
96
	}
97
}

Mutations

57

1.1
Location : countStepInFile
Killed by : none
removed call to org/graphstream/stream/file/FileSource::addElementSink → NO_COVERAGE

58

1.1
Location : countStepInFile
Killed by : none
removed call to org/graphstream/stream/file/FileSource::readAll → NO_COVERAGE

60

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

69

1.1
Location :
Killed by : none
removed call to org/graphstream/util/StepCounter::reset → NO_COVERAGE

85

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

95

1.1
Location : stepBegins
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 0.33