}
/**
- * Run the String[] getEnvNames() method test.
- */
- @Test
- public void testGetEnvNames() {
- String[] result = fixture.getEnvNames();
- assertNotNull(result);
- }
-
- /**
- * Run the String getEnvValue(String) method test.
+ * Run the String getEnvironment method test.
*/
@Test
public void testGetEnvValue() {
String key = "tracer_name";
- String result = fixture.getEnvValue(key);
+ String result = fixture.getEnvironment().get(key);
assertEquals("\"lttng-modules\"",result);
}
*/
@Test
public void testGetNbEnvVars() {
- int result = fixture.getNbEnvVars();
+ int result = fixture.getEnvironment().size();
assertEquals(8, result);
}
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
+import java.util.Collections;
+import java.util.Map;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
// -------------------------------------------
// Environment Parameters
// -------------------------------------------
- /**
- * Method getNbEnvVars.
- *
- * @return int
- */
- public int getNbEnvVars() {
- return this.fTrace.getEnvironment().size();
- }
-
- /**
- * Method getEnvNames.
- *
- * @return String[]
- */
- public String[] getEnvNames() {
- final String[] s = new String[getNbEnvVars()];
- return this.fTrace.getEnvironment().keySet().toArray(s);
- }
/**
- * Method getEnvValue.
+ * Get the map of environment variables of this trace.
*
- * @param key
- * String
- * @return String
+ * @return The map of env vars
+ * @since 2.0
*/
- public String getEnvValue(final String key) {
- return this.fTrace.getEnvironment().get(key);
+ public Map<String, String> getEnvironment() {
+ return Collections.unmodifiableMap(fTrace.getEnvironment());
}
// -------------------------------------------
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.environment;
+import java.util.Map;
+
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
}
for (ITmfTrace trace : TmfTraceManager.getTraceSet(fTrace)) {
+ // FIXME This should be replaced with a method in ITmfTrace maybe?
+ // Other trace types might want to supply environment variables.
if (trace instanceof CtfTmfTrace) {
TreeItem item = new TreeItem(fTree, SWT.NONE);
item.setText(0, trace.getName());
+
CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
- for (String varName : ctfTrace.getEnvNames()) {
+ Map <String, String> env = ctfTrace.getEnvironment();
+ for (Map.Entry<String, String> entry : env.entrySet()) {
TreeItem subItem = new TreeItem(item, SWT.NONE);
- subItem.setText(0, varName);
- subItem.setText(1, ctfTrace.getEnvValue(varName));
+ subItem.setText(0, entry.getKey()); // Variable name
+ subItem.setText(1, entry.getValue()); // Variable value
}
}
}