1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.layout;
21
22
23 import java.util.HashMap;
24 import java.util.Map;
25
26
27 public enum TextAlign {
28
29 LEFT("left"),
30 RIGHT("right"),
31 CENTER("center"),
32 JUSTIFY("justify");
33
34 public static final String STRING_LEFT = "left";
35 public static final String STRING_RIGHT = "right";
36 public static final String STRING_CENTER = "center";
37 public static final String STRING_JUSTIFY = "justify";
38
39 private String value;
40
41 TextAlign(String value) {
42 this.value = value;
43 }
44
45 public String getValue() {
46 return value;
47 }
48
49 private static final Map<String, TextAlign> MAPPING;
50
51 static {
52 MAPPING = new HashMap<String, TextAlign>();
53
54 for (TextAlign textAlign : TextAlign.values()) {
55 MAPPING.put(textAlign.getValue(), textAlign);
56 }
57 }
58
59 public static TextAlign parse(String string) {
60 if (string == null) {
61 return null;
62 }
63 TextAlign value = MAPPING.get(string);
64 if (value != null) {
65 return value;
66 } else {
67 throw new IllegalArgumentException("Unknown value for TextAlign: '" + string + "'");
68 }
69 }
70
71 }