lttng.ust: Add the build-ID to the key of cache of addr2line calls
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.analysis.xml.core / src / org / eclipse / tracecompass / tmf / analysis / xml / core / segment / TmfXmlPatternSegment.java
index 300e73098cb51e91e409293fac9d3475508957c4..f32406ab594b09dbda6a852a8f29c1353134e53c 100644 (file)
@@ -12,21 +12,16 @@ import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.segmentstore.core.ISegment;
-import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
 import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
 import org.eclipse.tracecompass.statesystem.core.statevalue.TmfStateValue;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 
-import com.google.common.collect.Ordering;
-
 /**
  * This class implements an XML Pattern Segment. This type of segment has
  * content and a default timestamp, which is the start time of the segment.
@@ -48,12 +43,6 @@ public class TmfXmlPatternSegment implements ISegment {
     private static final byte TYPE_STRING = 1;
     private static final byte TYPE_LONG = 2;
 
-    private static final @NonNull Comparator<ISegment> COMPARATOR = Ordering
-            .from(SegmentComparators.INTERVAL_START_COMPARATOR)
-            .compound(SegmentComparators.INTERVAL_END_COMPARATOR)
-             /* Kind of lazy, but should work! */
-            .compound(Ordering.usingToString());
-
     private final int fScale;
     private final long fStart;
     private final long fEnd;
@@ -88,7 +77,7 @@ public class TmfXmlPatternSegment implements ISegment {
      * @return The start timestamp
      */
     public @NonNull ITmfTimestamp getTimestampStart() {
-        return new TmfTimestamp(fStart, fScale);
+        return TmfTimestamp.create(fStart, fScale);
     }
 
     /**
@@ -97,7 +86,7 @@ public class TmfXmlPatternSegment implements ISegment {
      * @return The end timestamp
      */
     public @NonNull ITmfTimestamp getTimestampEnd() {
-        return new TmfTimestamp(fEnd, fScale);
+        return TmfTimestamp.create(fEnd, fScale);
     }
 
     /**
@@ -125,11 +114,12 @@ public class TmfXmlPatternSegment implements ISegment {
     }
 
     @Override
-    public int compareTo(@Nullable ISegment o) {
-        if (o == null) {
-            throw new IllegalArgumentException("Cannot compare to null"); //$NON-NLS-1$
+    public int compareTo(@NonNull ISegment o) {
+        int ret = ISegment.super.compareTo(o);
+        if (ret != 0) {
+            return ret;
         }
-        return COMPARATOR.compare(this, o);
+        return toString().compareTo(o.toString());
     }
 
     @Override
@@ -195,7 +185,7 @@ public class TmfXmlPatternSegment implements ISegment {
             int length = in.readInt();
             byte[] bytes = new byte[length];
             in.read(bytes, 0, length);
-            String name = new String(bytes);
+            String name = new String(bytes).intern();
 
             Byte type = in.readByte();
             ITmfStateValue value;
@@ -213,7 +203,7 @@ public class TmfXmlPatternSegment implements ISegment {
                 length = in.readInt();
                 bytes = new byte[length];
                 in.read(bytes, 0, length);
-                value = TmfStateValue.newValueString(new String(bytes));
+                value = TmfStateValue.newValueString(new String(bytes).intern());
                 break;
             default:
                 throw new IOException("Read object failed : Invalid data"); //$NON-NLS-1$
This page took 0.026295 seconds and 5 git commands to generate.