gdbtrace: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / model / TraceEnablement.java
index 77e15c2b23fecb8c1645f521c8129cc28c841992..a9583e3f29d1bc2027f680d61f6e71e65593955f 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2012 Ericsson
+ * Copyright (c) 2012, 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
@@ -8,13 +8,14 @@
  *
  * Contributors:
  *   Bernd Hufmann - Initial API and implementation
+ *   Jonathan Rajotte - Machine interface support and utility function
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.control.core.model;
 
+import java.security.InvalidParameterException;
+
 /**
- * <p>
  * Enumeration for enabled/disabled states.
- * </p>
  *
  * @author Bernd Hufmann
  */
@@ -24,9 +25,9 @@ public enum TraceEnablement {
     // Enum definition
     // ------------------------------------------------------------------------
     /** Tracing is disabled */
-    DISABLED("disabled"), //$NON-NLS-1$
+    DISABLED("disabled", "false"), //$NON-NLS-1$ //$NON-NLS-2$
     /** Tracing is enabled */
-    ENABLED("enabled"); //$NON-NLS-1$
+    ENABLED("enabled", "true"); //$NON-NLS-1$ //$NON-NLS-2$
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -35,6 +36,7 @@ public enum TraceEnablement {
      * Name of enum
      */
     private final String fInName;
+    private final String fInMiName;
 
     // ------------------------------------------------------------------------
     // Constuctors
@@ -42,10 +44,13 @@ public enum TraceEnablement {
 
     /**
      * Private constructor
-     * @param name the name of state
+     *
+     * @param name
+     *            the name of state
      */
-    private TraceEnablement(String name) {
+    private TraceEnablement(String name, String miName) {
         fInName = name;
+        fInMiName = miName;
     }
 
     // ------------------------------------------------------------------------
@@ -57,4 +62,30 @@ public enum TraceEnablement {
     public String getInName() {
         return fInName;
     }
+
+    /**
+     * @return state name
+     */
+    public String getInMiName() {
+        return fInMiName;
+    }
+
+    /**
+     * @param name
+     *            name of the desired enum
+     * @return the corresponding {@link TraceEnablement} matching name
+     */
+    public static TraceEnablement valueOfString(String name) {
+        if (name == null) {
+            throw new InvalidParameterException();
+        }
+        for (TraceEnablement enablementType : TraceEnablement.values()) {
+            boolean exist = enablementType.fInName.equalsIgnoreCase(name) || enablementType.fInMiName.equalsIgnoreCase(name);
+            if (exist) {
+                return enablementType;
+            }
+        }
+        return DISABLED;
+    }
+
 }
This page took 0.025964 seconds and 5 git commands to generate.