aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Bergeron2013-12-10 16:37:12 (EST)
committerAlexandre Montplaisir2013-12-17 14:00:39 (EST)
commitfa3ab98af5c02cb7fe42f824322fa3e51ce25b14 (patch)
tree1b497baf1ba00e87eb044378f3015a5847846462
parent46735312266cb4a1754fcb0b8c200c45873f539b (diff)
downloadorg.eclipse.linuxtools-fa3ab98af5c02cb7fe42f824322fa3e51ce25b14.zip
org.eclipse.linuxtools-fa3ab98af5c02cb7fe42f824322fa3e51ce25b14.tar.gz
org.eclipse.linuxtools-fa3ab98af5c02cb7fe42f824322fa3e51ce25b14.tar.bz2
ctf: simplify trace environment lookuprefs/changes/22/19622/3
Environment is an immutable data structure. Wrap it into an unmodifiable collection. Change-Id: I29ab6d4671eae2c9efd59412f80186a10b9b4952 Signed-off-by: Etienne Bergeron <etienne.bergeron@gmail.com> Reviewed-on: https://git.eclipse.org/r/19622 Tested-by: Hudson CI Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java8
-rw-r--r--lttng/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java17
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java3
3 files changed, 9 insertions, 19 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 5f78810..04bd2ee 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
@@ -357,7 +357,7 @@ public class CTFTraceTest {
@Test
public void testLookupEnvironment_1() {
String key = "";
- String result = fixture.lookupEnvironment(key);
+ String result = fixture.getEnvironment().get(key);
assertNull(result);
}
@@ -367,7 +367,7 @@ public class CTFTraceTest {
@Test
public void testLookupEnvironment_2() {
String key = "otherTest";
- String result = fixture.lookupEnvironment(key);
+ String result = fixture.getEnvironment().get(key);
assertNull(result);
}
@@ -378,7 +378,7 @@ public class CTFTraceTest {
public void testLookupEnvironment_3() {
String key = "test";
fixture.addEnvironmentVar(key, key);
- String result = fixture.lookupEnvironment(key);
+ String result = fixture.getEnvironment().get(key);
assertTrue(result.equals(key));
}
@@ -390,7 +390,7 @@ public class CTFTraceTest {
String key = "test";
fixture.addEnvironmentVar(key, "bozo");
fixture.addEnvironmentVar(key, "the clown");
- String result = fixture.lookupEnvironment(key);
+ String result = fixture.getEnvironment().get(key);
assertNotNull(result);
}
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 fbc8203..9f6af8c 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
@@ -24,6 +24,7 @@ import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -634,22 +635,12 @@ public class CTFTrace implements IDefinitionScope {
/**
* Gets the Environment variables from the trace metadata (See CTF spec)
*
- * @return the environment variables in a map form (key value)
+ * @return The environment variables in the form of an unmodifiable map
+ * (key, value)
* @since 2.0
*/
public Map<String, String> getEnvironment() {
- return environment;
- }
-
- /**
- * Look up a specific environment variable
- *
- * @param key
- * the key to look for
- * @return the value of the variable, can be null.
- */
- public String lookupEnvironment(String key) {
- return environment.get(key);
+ return Collections.unmodifiableMap(environment);
}
/**
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
index 8f8a457..9596a03 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
@@ -16,7 +16,6 @@ package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
-import java.util.Collections;
import java.util.Map;
import org.eclipse.core.resources.IProject;
@@ -327,7 +326,7 @@ public class CtfTmfTrace extends TmfTrace
*/
@Override
public Map<String, String> getTraceProperties() {
- return Collections.unmodifiableMap(fTrace.getEnvironment());
+ return fTrace.getEnvironment();
}
// -------------------------------------------