From 55846ac56ea088dc63f7858b6d55e2b4c2038bb1 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Julien Date: Mon, 4 Aug 2014 11:20:46 -0400 Subject: [PATCH] tmf: lttngControl: BufferType: mi support + utility function Change-Id: I26f2f965067f9da8aebdca3c4d841956751fc0a8 Signed-off-by: Jonathan Rajotte Julien Reviewed-on: https://git.eclipse.org/r/30977 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann Reviewed-by: Matthew Khouzam --- .../control/core/model/impl/BufferType.java | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BufferType.java b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BufferType.java index 06f6cd118f..6f67292274 100644 --- a/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BufferType.java +++ b/org.eclipse.linuxtools.lttng2.control.core/src/org/eclipse/linuxtools/internal/lttng2/control/core/model/impl/BufferType.java @@ -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; + } } -- 2.34.1