ctf.core: making some classes final
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / ctf / core / event / types / EnumDeclaration.java
index 763ca6ae8f51b5f69a5c746d1ee09eb86a8531bd..5fe01bbfb01b670de563839735b6196cc2123354 100644 (file)
@@ -12,6 +12,7 @@
 
 package org.eclipse.tracecompass.ctf.core.event.types;
 
+import java.nio.ByteOrder;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -43,7 +44,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
      *
      * @since 1.1
      */
-    public static class Pair {
+    public static final class Pair {
         private final long fFirst;
         private final long fSecond;
 
@@ -114,6 +115,22 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         return fContainerType.getMaximumSize();
     }
 
+    /**
+     * @since 2.0
+     */
+    @Override
+    public boolean isByteOrderSet() {
+        return fContainerType.isByteOrderSet();
+    }
+
+    /**
+     * @since 2.0
+     */
+    @Override
+    public ByteOrder getByteOrder() {
+        return fContainerType.getByteOrder();
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -144,6 +161,20 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         return fTable.add(low, high, label);
     }
 
+    /**
+     * Add a value. Do not overlap, this is <em><strong>not</strong></em> an
+     * interval tree. This could be seen more as a collection of segments.
+     *
+     * @param label
+     *            the name of the value.
+     * @return was the value be added? true == success
+     * @since 2.0
+     */
+    public boolean add(@Nullable String label) {
+        fLabels.add(label);
+        return fTable.add(label);
+    }
+
     /**
      * Check if the label for a value (enum a{day=0,night=1} would return "day"
      * for query(0)
@@ -191,6 +222,11 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         public EnumTable() {
         }
 
+        public synchronized boolean add(@Nullable String label) {
+            LabelAndRange lastAdded = ranges.isEmpty() ? new LabelAndRange(-1, -1, "") : ranges.get(ranges.size() - 1); //$NON-NLS-1$
+            return add(lastAdded.low + 1, lastAdded.high + 1, label);
+        }
+
         public synchronized boolean add(long low, long high, @Nullable String label) {
             LabelAndRange newRange = new LabelAndRange(low, high, label);
 
@@ -336,11 +372,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         }
         sb.append("type:").append(fContainerType.toString()); //$NON-NLS-1$
         sb.append(']');
-        String string = sb.toString();
-        if (string == null) {
-            throw new IllegalStateException();
-        }
-        return string;
+        return sb.toString();
     }
 
     @Override
This page took 0.027652 seconds and 5 git commands to generate.