1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.nuiton.jrst;
24
25 import static org.nuiton.i18n.I18n.t;
26 import static org.nuiton.i18n.I18n.n;
27
28 import java.io.File;
29
30 import org.nuiton.config.ApplicationConfig;
31 import org.nuiton.config.ConfigOptionDef;
32
33
34
35
36
37
38 public enum JRSTConfigOption implements ConfigOptionDef {
39
40 FORCE("force", n("jrst.option.force"), "false", String.class, true, false),
41 SIMPLE("simple", n("jrst.option.simple"), "false", String.class, true, false),
42 OUT_FILE("outFile", n("jrst.option.outfile"), null, String.class, true, false),
43 OUT_TYPE("outType", n("jrst.option.outtype"), null, String.class, true, false),
44 XSL_FILE("xslFile", n("jrst.option.xslfile"), null, String.class, true, false),
45 INTERMEDIATE_FILE("intermediateFile", n("jrst.option.intermediatefile"), JRST.TYPE_XHTML,
46 String.class, true, false);
47
48 public String key;
49 public String description;
50 public String defaultValue;
51 public Class<?> type;
52 public boolean isTransient;
53 public boolean isFinal;
54 public String[] alias;
55
56 private JRSTConfigOption(String key, String description,
57 String defaultValue, Class<?> type, boolean isTransient, boolean isFinal, String... alias) {
58 this.key = key;
59 this.description = description;
60 this.defaultValue = defaultValue;
61 this.type = type;
62 this.isTransient = isTransient;
63 this.isFinal = isFinal;
64 this.alias = alias;
65 }
66
67 @Override
68 public boolean isFinal() {
69 return isFinal;
70 }
71
72 @Override
73 public boolean isTransient() {
74 return isTransient;
75 }
76
77 @Override
78 public String getDefaultValue() {
79 return defaultValue;
80 }
81
82 @Override
83 public String getDescription() {
84 return t(description);
85 }
86
87 @Override
88 public String getKey() {
89 return key;
90 }
91
92 @Override
93 public Class<?> getType() {
94 return type;
95 }
96
97 @Override
98 public void setDefaultValue(String defaultValue) {
99 this.defaultValue = defaultValue;
100 }
101
102 @Override
103 public void setTransient(boolean isTransient) {
104 this.isTransient = isTransient;
105 }
106
107 @Override
108 public void setFinal(boolean isFinal) {
109 this.isFinal = isFinal;
110 }
111
112 public String[] getAlias() {
113 return alias;
114 }
115
116 public String getOption(ApplicationConfig config) {
117 String result = config.getOption(getKey());
118 return result;
119 }
120
121 public File getOptionAsFile(ApplicationConfig config) {
122 File result = config.getOptionAsFile(getKey());
123 return result;
124 }
125
126 public boolean getOptionAsBoolean(ApplicationConfig config) {
127 boolean result = config.getOptionAsBoolean(getKey());
128 return result;
129 }
130 }