blob: c0bd75dbaeaf89770a7e2746d8c27a5a9fd5c1e2 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
package bjc.utils.ioutils.format;
/**
* A collection of the modifiers attached to a CL format directive.
*
* @author EVE
*
*/
public class CLModifiers {
/**
* Whether the at mod is on.
*/
public final boolean atMod;
/**
* Whether the colon mod is on.
*/
public final boolean colonMod;
/**
* Whether the dollar mod is on.
*/
public final boolean dollarMod;
/**
* Whether the star mod is on.
*/
public final boolean starMod;
/**
* Create a new set of CL modifiers.
*
* @param at
* The state of the at mod.
* @param colon
* The state of the colon mod.
* @param dollar
* The state of the dollar mod.
* @param star
* The state of the star mod.
*/
public CLModifiers(boolean at, boolean colon, boolean dollar, boolean star) {
atMod = at;
colonMod = colon;
dollarMod = dollar;
starMod = star;
}
/**
* Create a set of modifiers from a modifier string.
*
* @param modString
* The string to parse modifiers from.
* @return A set of modifiers matching the string.
*/
public static CLModifiers fromString(String modString) {
boolean atMod = false;
boolean colonMod = false;
boolean dollarMod = false;
boolean starMod = false;
if (modString != null) {
atMod = modString.contains("@");
colonMod = modString.contains(":");
dollarMod = modString.contains("$");
starMod = modString.contains("*");
}
return new CLModifiers(atMod, colonMod, dollarMod, starMod);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
if (atMod) sb.append('@');
if (colonMod) sb.append(':');
if (dollarMod) sb.append('$');
if (starMod) sb.append('*');
return sb.toString();
}
}
|