blob: 7b9a73009c1fc413da999f46647c3683268bd6f6 (
plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
|
package morfologik.fsa;
import java.util.Set;
/**
* FSA automaton flags. Where applicable, flags follow Daciuk's <code>fsa</code> package.
*/
public enum FSAFlags {
/** Daciuk: flexible FSA encoding. */
FLEXIBLE(1 << 0),
/** Daciuk: stop bit in use. */
STOPBIT(1 << 1),
/** Daciuk: next bit in use. */
NEXTBIT(1 << 2),
/** Daciuk: tails compression. */
TAILS(1 << 3),
/*
* These flags are outside of byte range (never occur in Daciuk's FSA).
*/
/**
* The FSA contains right-language count numbers on states.
*
* @see FSA#getRightLanguageCount(int)
*/
NUMBERS(1 << 8),
/**
* The FSA supports legacy built-in separator and filler characters (Daciuk's FSA package
* compatibility).
*/
SEPARATORS(1 << 9);
/**
* Bit mask for the corresponding flag.
*/
public final int bits;
/** */
private FSAFlags(int bits) {
this.bits = bits;
}
/**
* Returns <code>true</code> if the corresponding flag is set in the bit set.
*/
public static boolean isSet(int flags, FSAFlags flag) {
return (flags & flag.bits) != 0;
}
/**
* Returns the set of flags encoded in a single short.
*/
public static short asShort(Set<FSAFlags> flags) {
short value = 0;
for (FSAFlags f : flags)
value |= f.bits;
return value;
}
}
|