Commit | Line | Data |
---|---|---|
ccc66d01 | 1 | /********************************************************************** |
54f2dcc0 | 2 | * Copyright (c) 2012, 2014 Ericsson |
b0318660 | 3 | * |
ccc66d01 BH |
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 | |
b0318660 AM |
8 | * |
9 | * Contributors: | |
ccc66d01 BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | *********************************************************************/ | |
8e8c0226 | 12 | package org.eclipse.linuxtools.internal.lttng2.control.core.model; |
ccc66d01 | 13 | |
927bc9a3 | 14 | |
ccc66d01 | 15 | /** |
ccc66d01 | 16 | * Type of log Level enumeration. |
b0318660 | 17 | * |
dbd4432d | 18 | * @author Bernd Hufmann |
ccc66d01 BH |
19 | */ |
20 | public enum LogLevelType { | |
b0318660 | 21 | |
ccc66d01 BH |
22 | // ------------------------------------------------------------------------ |
23 | // Enum definition | |
24 | // ------------------------------------------------------------------------ | |
b0318660 | 25 | /** range of log levels [0,logLevel] */ |
927bc9a3 JRJ |
26 | LOGLEVEL("<=", "RANGE"), //$NON-NLS-1$ //$NON-NLS-2$ |
27 | ||
28 | /** all log level */ | |
29 | LOGLEVEL_ALL("", "ALL"), //$NON-NLS-1$//$NON-NLS-2$ | |
ccc66d01 | 30 | |
b0318660 | 31 | /** single log level */ |
927bc9a3 | 32 | LOGLEVEL_ONLY("==", "SINGLE"), //$NON-NLS-1$ //$NON-NLS-2$ |
ccc66d01 | 33 | |
b0318660 | 34 | /** no log level */ |
927bc9a3 | 35 | LOGLEVEL_NONE("", "UNKNOWN"); //$NON-NLS-1$ //$NON-NLS-2$ |
54f2dcc0 BH |
36 | |
37 | // ------------------------------------------------------------------------ | |
38 | // Constuctors | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
41 | /** | |
42 | * Private constructor | |
927bc9a3 JRJ |
43 | * |
44 | * @param name | |
45 | * the name of state | |
54f2dcc0 | 46 | */ |
927bc9a3 | 47 | private LogLevelType(String shortName, String miName) { |
54f2dcc0 | 48 | fShortName = shortName; |
927bc9a3 | 49 | fMiName = miName; |
54f2dcc0 BH |
50 | } |
51 | ||
927bc9a3 | 52 | // ------------------------------------------------------------------------ |
54f2dcc0 BH |
53 | // Attributes |
54 | // ------------------------------------------------------------------------ | |
55 | /** | |
56 | * Name of enum. | |
57 | */ | |
58 | private final String fShortName; | |
927bc9a3 | 59 | private final String fMiName; |
54f2dcc0 BH |
60 | |
61 | // ------------------------------------------------------------------------ | |
62 | // Accessors | |
63 | // ------------------------------------------------------------------------ | |
64 | /** | |
65 | * @return short string | |
66 | */ | |
67 | public String getShortName() { | |
68 | return fShortName; | |
69 | } | |
70 | ||
927bc9a3 JRJ |
71 | /** |
72 | * @return machine interface name string | |
73 | */ | |
74 | public String getMiName() { | |
75 | return fMiName; | |
76 | } | |
77 | ||
78 | // ------------------------------------------------------------------------ | |
79 | // Utility | |
80 | // ------------------------------------------------------------------------ | |
81 | /** | |
82 | * Return the corresponding {@link LogLevelType} to String "name" | |
83 | * | |
84 | * @param name | |
85 | * String to compare to retrieve the good LogLevelType | |
86 | * @return the corresponding {@link LogLevelType} | |
87 | */ | |
88 | public static LogLevelType valueOfString(String name) { | |
89 | if (name == null) { | |
90 | throw new IllegalArgumentException(); | |
91 | } | |
92 | for (LogLevelType lltype : LogLevelType.values()) { | |
93 | if (!lltype.equals(LOGLEVEL_NONE)) { | |
94 | boolean isEqual = lltype.fShortName.equalsIgnoreCase(name) || lltype.fMiName.equalsIgnoreCase(name); | |
95 | if (isEqual) { | |
96 | return lltype; | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | // No match | |
102 | return LogLevelType.LOGLEVEL_NONE; | |
103 | } | |
b0318660 | 104 | } |