|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.config; |
|
19 |
| |
|
20 |
| import java.io.File; |
|
21 |
| import java.io.IOException; |
|
22 |
| import java.util.List; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| public final class QedeqConfig { |
|
38 |
| |
|
39 |
| |
|
40 |
| private static final String DEFAULT_LOCAL_MODULES_DIRECTORY |
|
41 |
| = "local"; |
|
42 |
| |
|
43 |
| |
|
44 |
| private static final String DEFAULT_LOCAL_BUFFER |
|
45 |
| = "buffer"; |
|
46 |
| |
|
47 |
| |
|
48 |
| private static final String DEFAULT_GENERATED |
|
49 |
| = "generated"; |
|
50 |
| |
|
51 |
| |
|
52 |
| private static final String DEFAULT_LOG_FILE |
|
53 |
| = "log/log.txt"; |
|
54 |
| |
|
55 |
| |
|
56 |
| private final ConfigAccess configAccess; |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
| |
|
64 |
| |
|
65 |
| |
|
66 |
2
| public QedeqConfig(final File configDirectory, final String configFileName,
|
|
67 |
| final String description) throws IOException { |
|
68 |
2
| configAccess = new ConfigAccess(configDirectory, configFileName, description);
|
|
69 |
| } |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
| |
|
76 |
2
| public final void store() throws IOException {
|
|
77 |
2
| configAccess.store();
|
|
78 |
| } |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
0
| public final String getGenerationDirectory() {
|
|
86 |
0
| final String location = configAccess.getString("generationLocation");
|
|
87 |
0
| if (location == null) {
|
|
88 |
0
| return QedeqConfig.DEFAULT_GENERATED;
|
|
89 |
| } |
|
90 |
0
| return location;
|
|
91 |
| } |
|
92 |
| |
|
93 |
| |
|
94 |
| |
|
95 |
| |
|
96 |
| |
|
97 |
| |
|
98 |
0
| public final void setGenerationDirectory(final String location) {
|
|
99 |
0
| configAccess.setString("generationLocation", location);
|
|
100 |
| } |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
| |
|
106 |
| |
|
107 |
1
| public final String getBufferDirectory() {
|
|
108 |
1
| final String location = configAccess.getString("bufferLocation");
|
|
109 |
1
| if (location == null) {
|
|
110 |
1
| return QedeqConfig.DEFAULT_LOCAL_BUFFER;
|
|
111 |
| } |
|
112 |
0
| return location;
|
|
113 |
| } |
|
114 |
| |
|
115 |
| |
|
116 |
| |
|
117 |
| |
|
118 |
| |
|
119 |
| |
|
120 |
| |
|
121 |
| |
|
122 |
0
| public final void setBufferDirectory(final String location) {
|
|
123 |
0
| configAccess.setString("bufferLocation", location);
|
|
124 |
| } |
|
125 |
| |
|
126 |
| |
|
127 |
| |
|
128 |
| |
|
129 |
| |
|
130 |
| |
|
131 |
1
| public final String getLogFilePath() {
|
|
132 |
1
| final String location = configAccess.getString("logLocation");
|
|
133 |
1
| if (location == null) {
|
|
134 |
1
| return QedeqConfig.DEFAULT_LOG_FILE;
|
|
135 |
| } |
|
136 |
0
| return location;
|
|
137 |
| } |
|
138 |
| |
|
139 |
| |
|
140 |
| |
|
141 |
| |
|
142 |
| |
|
143 |
| |
|
144 |
1
| public final String[] getModuleHistory() {
|
|
145 |
1
| return configAccess.getStringProperties("moduleHistory.");
|
|
146 |
| } |
|
147 |
| |
|
148 |
| |
|
149 |
| |
|
150 |
| |
|
151 |
| |
|
152 |
| |
|
153 |
3
| public final void saveModuleHistory(final List modules) {
|
|
154 |
3
| configAccess.removeProperties(("moduleHistory."));
|
|
155 |
3
| for (int i = 0; i < modules.size(); i++) {
|
|
156 |
25
| configAccess.setString("moduleHistory." + (i + 101),
|
|
157 |
| modules.get(i).toString()); |
|
158 |
| } |
|
159 |
| } |
|
160 |
| |
|
161 |
| |
|
162 |
| |
|
163 |
| |
|
164 |
| |
|
165 |
| |
|
166 |
4
| public final String[] getPreviouslyCheckedModules() {
|
|
167 |
4
| return configAccess.getStringProperties("checkedModule.");
|
|
168 |
| } |
|
169 |
| |
|
170 |
| |
|
171 |
| |
|
172 |
| |
|
173 |
| |
|
174 |
| |
|
175 |
2
| public final void setLoadedModules(final String[] moduleAddresses) {
|
|
176 |
2
| configAccess.removeProperties("checkedModule.");
|
|
177 |
2
| for (int i = 0; i < moduleAddresses.length; i++) {
|
|
178 |
9
| configAccess.setString("checkedModule." + (i + 1), moduleAddresses[i]);
|
|
179 |
| } |
|
180 |
| } |
|
181 |
| |
|
182 |
| |
|
183 |
| |
|
184 |
| |
|
185 |
| |
|
186 |
| |
|
187 |
| |
|
188 |
| |
|
189 |
0
| public final File getStartDirectory() {
|
|
190 |
0
| return new File(".");
|
|
191 |
| } |
|
192 |
| |
|
193 |
| |
|
194 |
| |
|
195 |
| |
|
196 |
| |
|
197 |
| |
|
198 |
0
| public final boolean isAutoStartHtmlBrowser() {
|
|
199 |
0
| return "true".equals(
|
|
200 |
| configAccess.getString("autoStartHtmlBrowser", "true")); |
|
201 |
| } |
|
202 |
| |
|
203 |
| |
|
204 |
| |
|
205 |
| |
|
206 |
| |
|
207 |
| |
|
208 |
| |
|
209 |
0
| public final void setAutoStartHtmlBrowser(final boolean mode) {
|
|
210 |
0
| configAccess.setString("autoStartHtmlBrowser", (mode ? "true" : "false"));
|
|
211 |
| } |
|
212 |
| |
|
213 |
| |
|
214 |
| |
|
215 |
| |
|
216 |
| |
|
217 |
| |
|
218 |
| |
|
219 |
0
| public final boolean isDirectResponse() {
|
|
220 |
0
| return "true".equals(
|
|
221 |
| configAccess.getString("directResponse", "true")); |
|
222 |
| } |
|
223 |
| |
|
224 |
| |
|
225 |
| |
|
226 |
| |
|
227 |
| |
|
228 |
| |
|
229 |
| |
|
230 |
0
| public final void setDirectResponse(final boolean mode) {
|
|
231 |
0
| configAccess.setString("directResponse", (mode ? "true" : "false"));
|
|
232 |
| } |
|
233 |
| |
|
234 |
| |
|
235 |
| |
|
236 |
| |
|
237 |
| |
|
238 |
| |
|
239 |
2
| public boolean isAutoReloadLastSessionChecked() {
|
|
240 |
2
| return "true".equals(
|
|
241 |
| configAccess.getString("sessionAutoReload", "true")); |
|
242 |
| } |
|
243 |
| |
|
244 |
| |
|
245 |
| |
|
246 |
| |
|
247 |
| |
|
248 |
| |
|
249 |
| |
|
250 |
0
| public final void setAutoReloadLastSessionChecked(final boolean mode) {
|
|
251 |
0
| configAccess.setString("sessionAutoReload", (mode ? "true" : "false"));
|
|
252 |
| } |
|
253 |
| |
|
254 |
| |
|
255 |
| |
|
256 |
| |
|
257 |
| |
|
258 |
| |
|
259 |
| |
|
260 |
0
| public final boolean isOldHtml() {
|
|
261 |
0
| return "true".equals(configAccess.getString("oldHtml", "true"));
|
|
262 |
| } |
|
263 |
| |
|
264 |
| |
|
265 |
| |
|
266 |
| |
|
267 |
| |
|
268 |
| |
|
269 |
0
| public final void setOldHtml(final boolean mode) {
|
|
270 |
0
| configAccess.setString("oldHtml", (mode ? "true" : "false"));
|
|
271 |
| } |
|
272 |
| |
|
273 |
| |
|
274 |
| |
|
275 |
| |
|
276 |
| |
|
277 |
| |
|
278 |
| |
|
279 |
0
| public final String getLocalModulesDirectory() {
|
|
280 |
0
| final String location = configAccess.getString("localModulesDirectory");
|
|
281 |
0
| if (location == null) {
|
|
282 |
0
| return QedeqConfig.DEFAULT_LOCAL_MODULES_DIRECTORY;
|
|
283 |
| } |
|
284 |
0
| return location;
|
|
285 |
| } |
|
286 |
| |
|
287 |
| |
|
288 |
| |
|
289 |
| |
|
290 |
| |
|
291 |
| |
|
292 |
| |
|
293 |
| |
|
294 |
0
| public final void setLocalModulesDirectory(final String location) {
|
|
295 |
0
| configAccess.setString("localModulesDirectory", location);
|
|
296 |
| } |
|
297 |
| |
|
298 |
| |
|
299 |
| } |