aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-17 22:18:31 (EST)
committerMatthew Khouzam2014-01-02 14:01:25 (EST)
commit55dba6bb8194045a142cc62656a20edae588df09 (patch)
treea2c20d22dd5c73789b39a26b7e279dd168b8f1e5
parentca9ab0c021c75babc5440a816eb5548f51670307 (diff)
downloadorg.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.zip
org.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.tar.gz
org.eclipse.linuxtools-55dba6bb8194045a142cc62656a20edae588df09.tar.bz2
ctf: move getStreams to an iterable.refs/changes/33/19933/4
This is an example of how to break the internals access. Keep separate the "get/set/iterate" over an internals data-structure. Change-Id: Id79b4eeedd3636de142d3317cbb1b1ae6fe2f50a Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Reviewed-on: https://git.eclipse.org/r/19933 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java10
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java12
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java5
3 files changed, 7 insertions, 20 deletions
diff --git a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java
index 04bd2ee..b69ce43 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.nio.ByteOrder;
-import java.util.Map;
import java.util.UUID;
import org.eclipse.linuxtools.ctf.core.event.CTFClock;
@@ -193,15 +192,6 @@ public class CTFTraceTest {
}
/**
- * Run the Map<Long, Stream> getStreams() method test.
- */
- @Test
- public void testGetStreams() {
- Map<Long, Stream> result = fixture.getStreams();
- assertNotNull(result);
- }
-
- /**
* Run the File getTraceDirectory() method test.
*/
@Test
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
index 9f6af8c..c97e1b6 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java
@@ -200,8 +200,8 @@ public class CTFTrace implements IDefinitionScope {
}
/* Create their index */
- for (Map.Entry<Long, Stream> stream : streams.entrySet()) {
- Set<StreamInput> inputs = stream.getValue().getStreamInputs();
+ for (Stream stream : getStreams()) {
+ Set<StreamInput> inputs = stream.getStreamInputs();
for (StreamInput s : inputs) {
/*
* Copy the events
@@ -460,12 +460,12 @@ public class CTFTrace implements IDefinitionScope {
}
/**
- * Method getStreams get all the streams in a map format.
+ * Get all the streams as an iterable.
*
- * @return Map<Long,Stream> a map of all the streams.
+ * @return Iterable<Stream> an iterable over streams.
*/
- public Map<Long, Stream> getStreams() {
- return streams;
+ public Iterable<Stream> getStreams() {
+ return streams.values();
}
/**
diff --git a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
index 6110129..d8e24cd 100644
--- a/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
+++ b/lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java
@@ -14,7 +14,6 @@
package org.eclipse.linuxtools.ctf.core.trace;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
@@ -176,12 +175,10 @@ public class CTFTraceReader {
* if an error occurs
*/
private void createStreamInputReaders() throws CTFReaderException {
- Collection<Stream> streams = this.trace.getStreams().values();
-
/*
* For each stream.
*/
- for (Stream stream : streams) {
+ for (Stream stream : this.trace.getStreams()) {
Set<StreamInput> streamInputs = stream.getStreamInputs();
/*