ctf: make CtfTmfEvent expose packet context attributes
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.tmf.ctf.core / src / org / eclipse / tracecompass / tmf / ctf / core / event / CtfTmfEvent.java
index 9d3048ba9da2592e4d27773c473b0fcd692ba286..29f0d6a14e430c5c7c02cf4abcc599f444afcda1 100644 (file)
@@ -16,8 +16,10 @@ package org.eclipse.tracecompass.tmf.ctf.core.event;
 import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -84,6 +86,7 @@ public class CtfTmfEvent extends TmfEvent
     private transient @Nullable CtfTmfEventType fEventType;
 
     private final @Nullable ICTFStream fStream;
+    private final Map<String, Object> fPacketAttributes;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -139,6 +142,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = eventDefinition;
         fChannel = channel;
         fStream = fEvent.getDeclaration().getStream();
+        fPacketAttributes = eventDefinition.getPacketAttributes();
     }
 
     /**
@@ -164,6 +168,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
         fStream = null;
+        fPacketAttributes = Collections.EMPTY_MAP;
     }
 
     /**
@@ -182,6 +187,7 @@ public class CtfTmfEvent extends TmfEvent
         fEvent = EventDefinition.NULL_EVENT;
         fChannel = ""; //$NON-NLS-1$
         fStream = null;
+        fPacketAttributes = Collections.EMPTY_MAP;
     }
 
     // ------------------------------------------------------------------------
@@ -333,6 +339,19 @@ public class CtfTmfEvent extends TmfEvent
         return getCustomAttribute(CtfConstants.MODEL_URI_KEY);
     }
 
+    /**
+     * Gets the packet attributes. The result is an instance of one of
+     * the following classes: <code>Entry<String, Long></code>, <code>Long</code>,
+     * <code>String</code> or <code>Double</code>. The map contains pairs of key and
+     * values where the key and value can never be null.
+     *
+     * @return gets the packet attributes
+     * @since 2.0
+     */
+    public Map<String, Object> getPacketAttributes() {
+        return fPacketAttributes;
+    }
+
     // ------------------------------------------------------------------------
     // Object
     // ------------------------------------------------------------------------
This page took 0.029548 seconds and 5 git commands to generate.