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