| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2014 Ericsson |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Bernd Hufmann - Initial API and implementation |
| 11 | **********************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.internal.lttng2.control.core.model; |
| 14 | |
| 15 | /** |
| 16 | * Trace event type enumeration. |
| 17 | * |
| 18 | * @author Bernd Hufmann |
| 19 | */ |
| 20 | public enum TraceEventType { |
| 21 | /** Event type: tracepoint */ |
| 22 | TRACEPOINT("tracepoint"), //$NON-NLS-1$ |
| 23 | /** Event type: syscall */ |
| 24 | SYSCALL("syscall"), //$NON-NLS-1$ |
| 25 | /** Event type: probe */ |
| 26 | PROBE("probe"), //$NON-NLS-1$ |
| 27 | /** Event type: function */ |
| 28 | FUNCTION("function"), //$NON-NLS-1$ |
| 29 | /** Event type unknown */ |
| 30 | UNKNOWN("unknown"); //$NON-NLS-1$ |
| 31 | |
| 32 | private final String fInName; |
| 33 | |
| 34 | private TraceEventType(String name) { |
| 35 | fInName = name; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Get the type's name |
| 40 | * |
| 41 | * @return The type's name |
| 42 | */ |
| 43 | public String getInName() { |
| 44 | return fInName; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Return the corresponding {@link TraceEventType} of string miName |
| 49 | * |
| 50 | * @param name |
| 51 | * name of the {@link TraceEventType} to look for |
| 52 | * @return the corresponding {@link TraceEventType} |
| 53 | */ |
| 54 | public static TraceEventType valueOfString(String name) { |
| 55 | if (name == null) { |
| 56 | throw new IllegalArgumentException(); |
| 57 | } |
| 58 | for (TraceEventType teType : TraceEventType.values()) { |
| 59 | if (teType.getInName().equalsIgnoreCase(name)) { |
| 60 | return teType; |
| 61 | } |
| 62 | } |
| 63 | return UNKNOWN; |
| 64 | } |
| 65 | } |