segStore: Introduce IContentSegment
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 2 Dec 2016 22:28:31 +0000 (17:28 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 22 Feb 2017 00:33:17 +0000 (19:33 -0500)
Make TmfXmlSegment implement an IContentSegment

Change-Id: Ie6126f88fadc4c32c997b4d568b77e50ea39ec36
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/86294
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Reviewed-by: Hudson CI
statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/IContentSegment.java [new file with mode: 0644]
tmf/org.eclipse.tracecompass.tmf.analysis.xml.core/src/org/eclipse/tracecompass/internal/tmf/analysis/xml/core/segment/TmfXmlPatternSegment.java

diff --git a/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/IContentSegment.java b/statesystem/org.eclipse.tracecompass.segmentstore.core/src/org/eclipse/tracecompass/segmentstore/core/IContentSegment.java
new file mode 100644 (file)
index 0000000..c61d217
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.segmentstore.core;
+
+import java.util.Map;
+
+import org.eclipse.jdt.annotation.NonNull;
+
+/**
+ * A segment with fields
+ *
+ * @author Matthew Khouzam
+ * @since 1.2
+ */
+public interface IContentSegment extends ISegment {
+
+    /**
+     * Get the content, like an event
+     *
+     * @return a Map of key values
+     */
+    Map<@NonNull String, @NonNull ?> getContent();
+}
index 439b5ffb626f198ecb9a4d6de53d74c7705cc0e7..d73bf3afa0c90c0eff8ef76640172ee0f72f6a39 100644 (file)
@@ -16,6 +16,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.segmentstore.core.IContentSegment;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
 import org.eclipse.tracecompass.segmentstore.core.segment.interfaces.INamedSegment;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
@@ -29,7 +30,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
  *
  * @author Jean-Christian Kouame
  */
-public class TmfXmlPatternSegment implements INamedSegment {
+public class TmfXmlPatternSegment implements INamedSegment, IContentSegment {
 
     /**
      * The serial version UID
@@ -45,8 +46,8 @@ public class TmfXmlPatternSegment implements INamedSegment {
     private final int fScale;
     private final long fStart;
     private final long fEnd;
-    private final String fSegmentName;
-    private transient Map<@NonNull String, @NonNull ITmfStateValue> fContent;
+    private final @NonNull String fSegmentName;
+    private transient @NonNull Map<@NonNull String, @NonNull ITmfStateValue> fContent;
 
     /**
      * Constructs an XML pattern segment
@@ -66,7 +67,7 @@ public class TmfXmlPatternSegment implements INamedSegment {
         fStart = start;
         fEnd = end;
         fScale = scale;
-        fSegmentName = segmentName;
+        fSegmentName = String.valueOf(segmentName);
         fContent = Collections.unmodifiableMap(fields);
     }
 
@@ -90,8 +91,10 @@ public class TmfXmlPatternSegment implements INamedSegment {
 
     /**
      * Get the content of the pattern segment
+     *
      * @return The content
      */
+    @Override
     public Map<@NonNull String, @NonNull ITmfStateValue> getContent() {
         return fContent;
     }
@@ -103,6 +106,7 @@ public class TmfXmlPatternSegment implements INamedSegment {
 
     /**
      * Get the timestamp scale of the pattern segment
+     *
      * @return The timestamp scale
      */
     public int getScale() {
@@ -115,6 +119,10 @@ public class TmfXmlPatternSegment implements INamedSegment {
         if (ret != 0) {
             return ret;
         }
+        ret = IContentSegment.super.compareTo(o);
+        if (ret != 0) {
+            return ret;
+        }
         return toString().compareTo(o.toString());
     }
 
This page took 0.026972 seconds and 5 git commands to generate.