tmf: lttngControl: BufferType: mi support + utility function
authorJonathan Rajotte Julien <jonathan.rajotte-julien@ericsson.com>
Mon, 4 Aug 2014 15:20:46 +0000 (11:20 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Wed, 27 Aug 2014 15:31:50 +0000 (11:31 -0400)
Change-Id: I26f2f965067f9da8aebdca3c4d841956751fc0a8
Signed-off-by: Jonathan Rajotte Julien <jonathan.rajotte-julien@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/30977
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BufferType.java

index 06f6cd118fab054448351b01b8231f23fbae9525..6f67292274b475a684c1877c46346d7cc32a80c4 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2013 Ericsson
+ * Copyright (c) 2013, 2014 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -9,6 +9,7 @@
  * Contributors:
  *   Simon Delisle - Initial API and implementation
  *   Bernd Hufmann - Updated to enum definition
+ *   Jonathan Rajotte - Updated enum definition for lttng machine interface
  **********************************************************************/
 
 package org.eclipse.linuxtools.internal.lttng2.control.core.model.impl;
@@ -27,11 +28,11 @@ public enum BufferType {
     /**
      * Buffer type : per UID
      */
-    BUFFER_PER_UID("per UID"), //$NON-NLS-1$
+    BUFFER_PER_UID("per UID", "PER_UID"), //$NON-NLS-1$ //$NON-NLS-2$
     /**
      * Buffer type : per PID
      */
-    BUFFER_PER_PID("per PID"), //$NON-NLS-1$
+    BUFFER_PER_PID("per PID", "PER_PID"), //$NON-NLS-1$ //$NON-NLS-2$
     /**
      * Buffer type : shared
      */
@@ -49,16 +50,29 @@ public enum BufferType {
      */
     private final String fInName;
 
+    /**
+     * Name of the machine interface enum
+     */
+    private final String fInMiName;
+
     // ------------------------------------------------------------------------
     // Constuctors
     // ------------------------------------------------------------------------
 
     /**
      * Private constructor
-     * @param name the name of state
+     *
+     * @param name
+     *            the name of state
      */
+    private BufferType(String name, String miName) {
+        fInName = name;
+        fInMiName = miName;
+    }
+
     private BufferType(String name) {
         fInName = name;
+        fInMiName = ""; //$NON-NLS-1$
     }
 
     // ------------------------------------------------------------------------
@@ -70,4 +84,33 @@ public enum BufferType {
     public String getInName() {
         return fInName;
     }
+
+    /**
+     * @return machine interface buffer name
+     */
+    public String getInMiName() {
+        return fInMiName;
+    }
+
+    // /
+    // ------------------------------------------------------------------------
+    // Utility function
+    // -------------------------------------------------------------------------
+    /**
+     * @param name
+     *            the string representation of the type
+     * @return enum BufferType of the corresponding type
+     */
+    public static BufferType valueOfString(String name) {
+        if (name == null) {
+            throw new IllegalArgumentException();
+        }
+        for (BufferType bufferType : BufferType.values()) {
+            boolean isEqual = bufferType.getInName().equalsIgnoreCase(name) || bufferType.getInMiName().equalsIgnoreCase(name);
+            if (isEqual) {
+                return bufferType;
+            }
+        }
+        return BUFFER_TYPE_UNKNOWN;
+    }
 }
This page took 0.02845 seconds and 5 git commands to generate.