Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 92752ce8e19b6a3346e73daccdc63f4a5e2fc3e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*******************************************************************************
 * Copyright (c) 2015 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.serial;

/**
 * @since 5.8
 */
public enum StopBits {

	S1,
	S2;
	
	private static final String[] strings = {
		"1", //$NON-NLS-1$
		"2" //$NON-NLS-1$
	};
	
	public static String[] getStrings() {
		return strings;
	}
	
	private static final StopBits[] stopBits = {
		S1,
		S2
	};
	
	public static StopBits fromStringIndex(int index) {
		return stopBits[index];
	}

	public static int getStringIndex(StopBits sb) {
		for (int i = 0; i < stopBits.length; ++i) {
			if (sb.equals(stopBits[i])) {
				return i;
			}
		}
		return getStringIndex(getDefault());
	}
	
	public static StopBits getDefault() {
		return S1;
	}
	
}

Back to the top