tmf: keep event fields ordering as per ctf metadata
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Tue, 12 Mar 2013 20:21:00 +0000 (16:21 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 15 Mar 2013 20:42:00 +0000 (16:42 -0400)
* While there, change the HashMap type of the fields to interface
  type map
* Change unit tests with new field ordering

Change-Id: I4fb1fec8b922f01e62573c415ca6f23826ec072a
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/11090
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDefinitionTest.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/EventDefinition.java
org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfEventTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventFactory.java

index 0e58b4674e04a18505f30848741a263e11811520..6d3813e01e8c8e609bb9848292ed30773ed83376 100644 (file)
@@ -17,7 +17,7 @@ import static org.junit.Assert.assertNull;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
-import java.util.HashMap;
+import java.util.Map;
 
 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
 import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition;
@@ -148,7 +148,7 @@ public class StructDefinitionTest {
      */
     @Test
     public void testGetDefinitions_1() {
-        HashMap<String, Definition> result = fixture.getDefinitions();
+        Map<String, Definition> result = fixture.getDefinitions();
         assertNotNull(result);
     }
 
index f4df158bb364b6573d9ad47a8138cf0ab0005289..6008a4891e7e17b69567c027d3f29b464704a366 100644 (file)
@@ -12,8 +12,8 @@
 
 package org.eclipse.linuxtools.ctf.core.event;
 
-import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import org.eclipse.linuxtools.ctf.core.event.types.Definition;
@@ -136,7 +136,7 @@ public class EventDefinition implements IDefinitionScope {
         StructDeclaration mergedDeclaration = new StructDeclaration(1);
 
         /* Add fields from the stream */
-        HashMap<String, Definition> defs = streamContext.getDefinitions();
+        Map<String, Definition> defs = streamContext.getDefinitions();
         for (Entry<String, Definition> entry : defs.entrySet()) {
             mergedDeclaration.addField(entry.getKey(), entry.getValue().getDeclaration());
         }
@@ -239,7 +239,7 @@ public class EventDefinition implements IDefinitionScope {
 
     @Override
     public String toString() {
-        HashMap<String, Definition> definitions;
+        Map<String, Definition> definitions;
         List<String> list;
         StringBuilder retString = new StringBuilder();
         final String cr = System.getProperty("line.separator");//$NON-NLS-1$
index cf2c7d8d19e0c329b74217c83e98b0a3a48f4ec5..b7603497b473c06ab4ee7b00a0b90cc3b61c3b7d 100644 (file)
 
 package org.eclipse.linuxtools.ctf.core.event.types;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Map;
 
 import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer;
 
@@ -36,7 +37,7 @@ public class StructDefinition extends Definition implements IDefinitionScope {
     // ------------------------------------------------------------------------
 
     private final StructDeclaration declaration;
-    private final HashMap<String, Definition> definitions = new HashMap<String, Definition>();
+    private final Map<String, Definition> definitions = new LinkedHashMap<String, Definition>();
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -78,8 +79,9 @@ public class StructDefinition extends Definition implements IDefinitionScope {
 
     /**
      * @return The definitions of all the fields
+     * @since 2.0
      */
-    public HashMap<String, Definition> getDefinitions() {
+    public Map<String, Definition> getDefinitions() {
         return definitions;
     }
 
index 1e55fedaf1426eedd12b6fe0d6c138f1cbd401a8..9a11af0b123ddf9f38b44e978fe86e15c630f2ec 100644 (file)
@@ -179,7 +179,7 @@ public class CtfTmfEventTest {
     @Test
     public void testToString() {
         String s = fixture.getContent().toString();
-        assertEquals("pid=1922, inode=917738, flags=0x8000075, end=0xb73ec000, start=0xb73ea000, pgoff=0", s); //$NON-NLS-1$
+        assertEquals("pid=1922, start=0xb73ea000, end=0xb73ec000, flags=0x8000075, inode=917738, pgoff=0", s); //$NON-NLS-1$
     }
 
     /**
index 95a4e06d6fb2fc41c2691ea2027bd16cece0eebc..b2974d24f84e755b32dbb09af8eb7d313d469944 100644 (file)
@@ -13,9 +13,9 @@
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import org.eclipse.linuxtools.ctf.core.event.EventDefinition;
@@ -103,7 +103,7 @@ public final class CtfTmfEventFactory {
         List<CtfTmfEventField> fields = new ArrayList<CtfTmfEventField>();
 
         StructDefinition structFields = eventDef.getFields();
-        HashMap<String, Definition> definitions = structFields.getDefinitions();
+        Map<String, Definition> definitions = structFields.getDefinitions();
         String curFieldName = null;
         Definition curFieldDef;
         CtfTmfEventField curField;
This page took 0.029576 seconds and 5 git commands to generate.