1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.bin.argparser; |
22 |
|
|
23 |
|
import java.io.File; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.Arrays; |
26 |
|
import java.util.Collections; |
27 |
|
import java.util.HashMap; |
28 |
|
import java.util.HashSet; |
29 |
|
import java.util.List; |
30 |
|
import java.util.Locale; |
31 |
|
import java.util.Map; |
32 |
|
import java.util.Set; |
33 |
|
|
34 |
|
import jalview.bin.Cache; |
35 |
|
import jalview.bin.Console; |
36 |
|
import jalview.bin.argparser.Arg.Opt; |
37 |
|
import jalview.bin.argparser.Arg.Type; |
38 |
|
import jalview.util.FileUtils; |
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
|
|
| 0% |
Uncovered Elements: 409 (409) |
Complexity: 152 |
Complexity Density: 0.69 |
|
44 |
|
public class ArgValuesMap |
45 |
|
{ |
46 |
|
private List<ArgInfo> argInfoList = new ArrayList<>(); |
47 |
|
|
48 |
|
protected Map<Arg, ArgValues> m; |
49 |
|
|
50 |
|
private String linkedId; |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
52 |
0 |
protected ArgValuesMap(String linkedId)... |
53 |
|
{ |
54 |
0 |
this.linkedId = linkedId; |
55 |
0 |
this.newMap(); |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
58 |
0 |
protected ArgValuesMap(String linkedId, Map<Arg, ArgValues> map)... |
59 |
|
{ |
60 |
0 |
this.linkedId = linkedId; |
61 |
0 |
this.m = map; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0 |
public String getLinkedId()... |
65 |
|
{ |
66 |
0 |
return linkedId; |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
private Map<Arg, ArgValues> getMap()... |
70 |
|
{ |
71 |
0 |
return m; |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
0 |
private void newMap()... |
75 |
|
{ |
76 |
0 |
m = new HashMap<Arg, ArgValues>(); |
77 |
|
} |
78 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.75 |
|
79 |
0 |
private void newArg(Arg a)... |
80 |
|
{ |
81 |
0 |
if (m == null) |
82 |
|
{ |
83 |
0 |
newMap(); |
84 |
|
} |
85 |
0 |
if (!containsArg(a)) |
86 |
|
{ |
87 |
0 |
m.put(a, new ArgValues(a, this)); |
88 |
|
} |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
91 |
0 |
public ArgValues getArgValues(Arg a)... |
92 |
|
{ |
93 |
0 |
return m == null ? null : m.get(a); |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
96 |
0 |
public ArgValues getOrCreateArgValues(Arg a)... |
97 |
|
{ |
98 |
0 |
ArgValues avs = m.get(a); |
99 |
0 |
if (avs == null) |
100 |
0 |
newArg(a); |
101 |
0 |
return getArgValues(a); |
102 |
|
} |
103 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
104 |
0 |
public List<ArgValue> getArgValueList(Arg a)... |
105 |
|
{ |
106 |
0 |
ArgValues avs = getArgValues(a); |
107 |
0 |
return avs == null ? new ArrayList<>() : avs.getArgValueList(); |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
0 |
public List<ArgValue> getArgValueListFromSubValOrArg(ArgValue av, Arg a,... |
111 |
|
SubVals sv) |
112 |
|
{ |
113 |
0 |
return getArgValueListFromSubValArgOrPrefWithSubstitutionsWithinTypes( |
114 |
|
null, a, Position.AFTER, av, sv, null, null, null, true, null); |
115 |
|
} |
116 |
|
|
|
|
| 0% |
Uncovered Elements: 67 (67) |
Complexity: 24 |
Complexity Density: 0.62 |
|
117 |
0 |
public List<ArgValue> getArgValueListFromSubValArgOrPrefWithSubstitutionsWithinTypes(... |
118 |
|
ArgParser ap, Arg a, ArgValuesMap.Position pos, ArgValue av, |
119 |
|
SubVals sv, String key, String pref, String def, |
120 |
|
boolean withinTypes, Type type) |
121 |
|
{ |
122 |
0 |
if (key == null) |
123 |
|
{ |
124 |
0 |
key = a.getName(); |
125 |
|
} |
126 |
0 |
Set<Type> types = new HashSet<>(); |
127 |
0 |
if (type == null) |
128 |
|
{ |
129 |
0 |
types.addAll(Arrays.asList(av.getArg().getTypes())); |
130 |
|
} |
131 |
|
else |
132 |
|
{ |
133 |
0 |
types.add(type); |
134 |
|
} |
135 |
0 |
List<ArgValue> avList = new ArrayList<>(); |
136 |
0 |
if (sv != null && sv.has(key) && sv.get(key) != null) |
137 |
|
{ |
138 |
0 |
String value = ap == null ? sv.get(key) |
139 |
|
: sv.getWithSubstitutions(ap, getLinkedId(), key); |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
0 |
ArgValue svav = new ArgValue(a, null, null, value, av.getArgIndex(), |
144 |
|
false, null, this.getLinkedId()); |
145 |
0 |
avList.add(svav); |
146 |
|
} |
147 |
0 |
else if (containsArg(a)) |
148 |
|
{ |
149 |
0 |
if (pos == ArgValuesMap.Position.FIRST && getValue(a) != null) |
150 |
0 |
avList.add(getArgValue(a)); |
151 |
0 |
else if (pos == ArgValuesMap.Position.BEFORE |
152 |
|
&& getClosestPreviousArgValueOfArg(av, a) != null) |
153 |
|
{ |
154 |
0 |
for (ArgValue tmpAv : getArgValues(a).getArgValueList()) |
155 |
|
{ |
156 |
0 |
if (tmpAv.getArgIndex() >= av.getArgIndex()) |
157 |
|
{ |
158 |
0 |
continue; |
159 |
|
} |
160 |
0 |
avList.add(tmpAv); |
161 |
|
} |
162 |
|
} |
163 |
0 |
else if (pos == ArgValuesMap.Position.AFTER |
164 |
|
&& getClosestNextArgValueOfArg(av, a, withinTypes) != null) |
165 |
|
{ |
166 |
0 |
for (ArgValue tmpAv : getArgValues(a).getArgValueList()) |
167 |
|
{ |
168 |
0 |
if (tmpAv.getArgIndex() <= av.getArgIndex()) |
169 |
|
{ |
170 |
0 |
continue; |
171 |
|
} |
172 |
0 |
avList.add(tmpAv); |
173 |
|
} |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
|
|
178 |
|
|
179 |
0 |
if (withinTypes && !avList.isEmpty()) |
180 |
|
{ |
181 |
0 |
int nextPrimaryArgOfSameTypeIndex = Integer.MAX_VALUE; |
182 |
|
|
183 |
0 |
for (Arg tmpA : this.getArgKeys()) |
184 |
|
{ |
185 |
|
|
186 |
|
|
187 |
0 |
if (tmpA.hasType(types) && tmpA.hasOption(Opt.PRIMARY)) |
188 |
|
{ |
189 |
0 |
for (ArgValue tmpAv : getArgValueList(tmpA)) |
190 |
|
{ |
191 |
0 |
int tmpArgIndex = tmpAv.getArgIndex(); |
192 |
0 |
if (tmpArgIndex > av.getArgIndex() |
193 |
|
&& tmpArgIndex < nextPrimaryArgOfSameTypeIndex) |
194 |
|
{ |
195 |
0 |
nextPrimaryArgOfSameTypeIndex = tmpArgIndex; |
196 |
|
} |
197 |
|
} |
198 |
|
} |
199 |
|
} |
200 |
0 |
List<ArgValue> tmpList = new ArrayList<>(); |
201 |
0 |
for (ArgValue tmpAv : avList) |
202 |
|
{ |
203 |
0 |
int tmpAvIndex = tmpAv.getArgIndex(); |
204 |
0 |
if (av.getArgIndex() < tmpAvIndex |
205 |
|
&& tmpAvIndex < nextPrimaryArgOfSameTypeIndex) |
206 |
|
{ |
207 |
0 |
tmpList.add(tmpAv); |
208 |
|
} |
209 |
|
} |
210 |
0 |
avList = tmpList; |
211 |
|
} |
212 |
|
|
213 |
0 |
return avList; |
214 |
|
} |
215 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
216 |
0 |
public ArgValue getArgValue(Arg a)... |
217 |
|
{ |
218 |
0 |
List<ArgValue> vals = getArgValueList(a); |
219 |
0 |
return (vals == null || vals.size() == 0) ? null : vals.get(0); |
220 |
|
} |
221 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
222 |
0 |
public String getValue(Arg a)... |
223 |
|
{ |
224 |
0 |
ArgValue av = getArgValue(a); |
225 |
0 |
return av == null ? null : av.getValue(); |
226 |
|
} |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
public List<String> getValues(Arg a)... |
229 |
|
{ |
230 |
0 |
return toValues(getArgValueList(a)); |
231 |
|
} |
232 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
233 |
0 |
public static List<String> toValues(List<ArgValue> avl)... |
234 |
|
{ |
235 |
0 |
if (avl == null) |
236 |
|
{ |
237 |
0 |
return null; |
238 |
|
} |
239 |
0 |
List<String> vl = new ArrayList<>(); |
240 |
0 |
for (ArgValue av : avl) |
241 |
|
{ |
242 |
0 |
vl.add(av.getValue()); |
243 |
|
} |
244 |
0 |
return vl; |
245 |
|
} |
246 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 4 |
Complexity Density: 1.33 |
|
247 |
0 |
public boolean containsArg(Arg a)... |
248 |
|
{ |
249 |
0 |
if (m == null || !m.containsKey(a)) |
250 |
0 |
return false; |
251 |
0 |
return a.hasOption(Opt.STRING) ? getArgValue(a) != null : true; |
252 |
|
} |
253 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 7 |
Complexity Density: 1 |
|
254 |
0 |
public boolean hasValue(Arg a, String val)... |
255 |
|
{ |
256 |
0 |
if (m == null || !m.containsKey(a)) |
257 |
0 |
return false; |
258 |
0 |
for (ArgValue av : getArgValueList(a)) |
259 |
|
{ |
260 |
0 |
String avVal = av.getValue(); |
261 |
0 |
if ((val == null && avVal == null) |
262 |
|
|| (val != null && val.equals(avVal))) |
263 |
|
{ |
264 |
0 |
return true; |
265 |
|
} |
266 |
|
} |
267 |
0 |
return false; |
268 |
|
} |
269 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
270 |
0 |
public boolean getBoolean(Arg a)... |
271 |
|
{ |
272 |
0 |
ArgValues av = getArgValues(a); |
273 |
0 |
return av == null ? false : av.getBoolean(); |
274 |
|
} |
275 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
276 |
0 |
public Set<Arg> getArgKeys()... |
277 |
|
{ |
278 |
0 |
return m.keySet(); |
279 |
|
} |
280 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
281 |
0 |
public ArgValue getArgValueOfArgWithSubValKey(Arg a, String svKey)... |
282 |
|
{ |
283 |
0 |
return getArgValueOfArgWithSubValKey(a, svKey, false); |
284 |
|
} |
285 |
|
|
|
|
| 0% |
Uncovered Elements: 19 (19) |
Complexity: 6 |
Complexity Density: 0.55 |
|
286 |
0 |
public ArgValue getArgValueOfArgWithSubValKey(Arg a, String svKey,... |
287 |
|
boolean last) |
288 |
|
{ |
289 |
0 |
ArgValues avs = this.getArgValues(a); |
290 |
0 |
if (avs == null) |
291 |
|
{ |
292 |
0 |
return null; |
293 |
|
} |
294 |
0 |
List<ArgValue> compareAvs = avs.getArgValueList(); |
295 |
0 |
for (int i = 0; i < compareAvs.size(); i++) |
296 |
|
{ |
297 |
0 |
int index = last ? compareAvs.size() - 1 - i : i; |
298 |
0 |
ArgValue av = compareAvs.get(index); |
299 |
0 |
SubVals sv = av.getSubVals(); |
300 |
0 |
if (sv.has(svKey) && !sv.get(svKey).equals("false")) |
301 |
|
{ |
302 |
0 |
return av; |
303 |
|
} |
304 |
|
} |
305 |
0 |
return null; |
306 |
|
} |
307 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
308 |
0 |
public ArgValue getClosestPreviousArgValueOfArg(ArgValue thisAv, Arg a)... |
309 |
|
{ |
310 |
0 |
ArgValue closestAv = null; |
311 |
0 |
int thisArgIndex = thisAv.getArgIndex(); |
312 |
0 |
ArgValues compareAvs = this.getArgValues(a); |
313 |
0 |
int closestPreviousIndex = -1; |
314 |
0 |
for (ArgValue av : compareAvs.getArgValueList()) |
315 |
|
{ |
316 |
0 |
int argIndex = av.getArgIndex(); |
317 |
0 |
if (argIndex < thisArgIndex && argIndex > closestPreviousIndex) |
318 |
|
{ |
319 |
0 |
closestPreviousIndex = argIndex; |
320 |
0 |
closestAv = av; |
321 |
|
} |
322 |
|
} |
323 |
0 |
return closestAv; |
324 |
|
} |
325 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 11 |
Complexity Density: 0.5 |
|
326 |
0 |
public ArgValue getClosestNextArgValueOfArg(ArgValue thisAv, Arg a,... |
327 |
|
boolean withinTypes) |
328 |
|
{ |
329 |
|
|
330 |
|
|
331 |
|
|
332 |
0 |
ArgValue closestAv = null; |
333 |
0 |
int thisArgIndex = thisAv.getArgIndex(); |
334 |
0 |
if (!containsArg(a)) |
335 |
0 |
return null; |
336 |
0 |
ArgValues compareAvs = this.getArgValues(a); |
337 |
0 |
int closestNextIndex = Integer.MAX_VALUE; |
338 |
0 |
for (ArgValue av : compareAvs.getArgValueList()) |
339 |
|
{ |
340 |
0 |
int argIndex = av.getArgIndex(); |
341 |
0 |
if (argIndex > thisArgIndex && argIndex < closestNextIndex) |
342 |
|
{ |
343 |
0 |
closestNextIndex = argIndex; |
344 |
0 |
closestAv = av; |
345 |
|
} |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
0 |
if (withinTypes && closestAv != null) |
351 |
|
{ |
352 |
0 |
int nextPrimaryArgOfSameTypeIndex = Integer.MAX_VALUE; |
353 |
0 |
for (Arg tmpA : this.getArgKeys()) |
354 |
|
{ |
355 |
|
|
356 |
0 |
if (tmpA.sharesType(a) && tmpA.hasOption(Opt.PRIMARY)) |
357 |
|
{ |
358 |
0 |
for (ArgValue tmpAv : getArgValueList(tmpA)) |
359 |
|
{ |
360 |
0 |
int tmpArgIndex = tmpAv.getArgIndex(); |
361 |
0 |
if (tmpArgIndex > thisArgIndex |
362 |
|
&& tmpArgIndex < nextPrimaryArgOfSameTypeIndex) |
363 |
|
{ |
364 |
0 |
nextPrimaryArgOfSameTypeIndex = tmpArgIndex; |
365 |
|
} |
366 |
|
} |
367 |
|
} |
368 |
|
} |
369 |
0 |
if (nextPrimaryArgOfSameTypeIndex < closestAv.getArgIndex()) |
370 |
|
{ |
371 |
|
|
372 |
0 |
return null; |
373 |
|
} |
374 |
|
} |
375 |
|
|
376 |
0 |
return closestAv; |
377 |
|
} |
378 |
|
|
379 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
380 |
0 |
public ArgValue[] getArgValuesReferringTo(String key, String value, Arg a)... |
381 |
|
{ |
382 |
|
|
383 |
|
|
384 |
|
|
385 |
0 |
List<ArgValue> avList = new ArrayList<>(); |
386 |
0 |
Arg[] args = a == null ? (Arg[]) this.getMap().keySet().toArray() |
387 |
|
: new Arg[] |
388 |
|
{ a }; |
389 |
0 |
for (Arg keyArg : args) |
390 |
|
{ |
391 |
0 |
for (ArgValue av : this.getArgValueList(keyArg)) |
392 |
|
{ |
393 |
|
|
394 |
|
} |
395 |
|
} |
396 |
0 |
return (ArgValue[]) avList.toArray(); |
397 |
|
} |
398 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
399 |
0 |
public boolean hasId(Arg a, String id)... |
400 |
|
{ |
401 |
0 |
ArgValues avs = this.getArgValues(a); |
402 |
0 |
return avs == null ? false : avs.hasId(id); |
403 |
|
} |
404 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
405 |
0 |
public ArgValue getId(Arg a, String id)... |
406 |
|
{ |
407 |
0 |
ArgValues avs = this.getArgValues(a); |
408 |
0 |
return avs == null ? null : avs.getId(id); |
409 |
|
} |
410 |
|
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
415 |
0 |
public String getBasename()... |
416 |
|
{ |
417 |
0 |
return getDirBasenameOrExtension(false, false, false); |
418 |
|
} |
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
424 |
0 |
public String getExtension()... |
425 |
|
{ |
426 |
0 |
return getDirBasenameOrExtension(false, true, false); |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
433 |
0 |
public String getDirname()... |
434 |
|
{ |
435 |
0 |
return getDirBasenameOrExtension(true, false, false); |
436 |
|
} |
437 |
|
|
|
|
| 0% |
Uncovered Elements: 23 (23) |
Complexity: 7 |
Complexity Density: 0.54 |
|
438 |
0 |
public String getDirBasenameOrExtension(boolean dirname,... |
439 |
|
boolean extension, boolean absoluteDirname) |
440 |
|
{ |
441 |
0 |
String filename = null; |
442 |
0 |
String appendVal = getValue(Arg.APPEND); |
443 |
0 |
String openVal = getValue(Arg.OPEN); |
444 |
0 |
if (appendVal != null) |
445 |
0 |
filename = appendVal; |
446 |
0 |
if (filename == null && openVal != null) |
447 |
0 |
filename = openVal; |
448 |
0 |
if (filename == null) |
449 |
0 |
return null; |
450 |
|
|
451 |
0 |
File file = new File(filename); |
452 |
0 |
if (dirname) |
453 |
|
{ |
454 |
0 |
return FileUtils.getDirname(file); |
455 |
|
} |
456 |
0 |
return extension ? FileUtils.getExtension(file) |
457 |
|
: FileUtils.getBasename(file); |
458 |
|
} |
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
463 |
0 |
public boolean hasArgWithOption(Opt o)... |
464 |
|
{ |
465 |
0 |
for (Arg a : getArgKeys()) |
466 |
|
{ |
467 |
0 |
if (a.hasOption(o)) |
468 |
0 |
return true; |
469 |
|
} |
470 |
0 |
return false; |
471 |
|
} |
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
477 |
0 |
public void addArgInfo(Arg arg, String value, SubVals subVals,... |
478 |
|
int argIndex) |
479 |
|
{ |
480 |
0 |
argInfoList.add(new ArgInfo(arg, value, subVals, argIndex)); |
481 |
|
} |
482 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
483 |
0 |
public List<ArgInfo> getArgInfoList()... |
484 |
|
{ |
485 |
0 |
Collections.sort(argInfoList); |
486 |
0 |
return argInfoList; |
487 |
|
} |
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
492 |
0 |
public String getValueFromSubValOrArg(ArgValue av, Arg a, SubVals sv)... |
493 |
|
{ |
494 |
0 |
return getFromSubValArgOrPref(av, a, sv, null, null, null); |
495 |
|
} |
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
501 |
0 |
public String getFromSubValArgOrPref(ArgValue av, Arg a, SubVals sv,... |
502 |
|
String key, String pref, String def) |
503 |
|
{ |
504 |
0 |
return getFromSubValArgOrPref(a, Position.AFTER, av, sv, key, pref, |
505 |
|
def); |
506 |
|
} |
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
512 |
0 |
public String getFromSubValArgOrPref(Arg a, Position pos, ArgValue av,... |
513 |
|
SubVals sv, String key, String pref, String def) |
514 |
|
{ |
515 |
0 |
return getFromSubValArgOrPrefWithSubstitutions(null, a, pos, av, sv, |
516 |
|
key, pref, def); |
517 |
|
} |
518 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
519 |
0 |
public String getFromSubValArgOrPrefWithSubstitutions(ArgParser ap, Arg a,... |
520 |
|
Position pos, ArgValue av, SubVals sv, String key, String pref, |
521 |
|
String def) |
522 |
|
{ |
523 |
0 |
return getFromSubValArgOrPrefWithSubstitutionsWithinTypes(ap, a, pos, |
524 |
|
av, sv, key, pref, def, true); |
525 |
|
} |
526 |
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 23 |
Complexity Density: 0.96 |
|
527 |
0 |
public String getFromSubValArgOrPrefWithSubstitutionsWithinTypes(... |
528 |
|
ArgParser ap, Arg a, Position pos, ArgValue av, SubVals sv, |
529 |
|
String key, String pref, String def, boolean withinTypes) |
530 |
|
{ |
531 |
0 |
if (key == null) |
532 |
0 |
key = a.getName(); |
533 |
0 |
String value = null; |
534 |
0 |
if (sv != null && sv.has(key) && sv.get(key) != null) |
535 |
|
{ |
536 |
0 |
value = ap == null ? sv.get(key) |
537 |
|
: sv.getWithSubstitutions(ap, getLinkedId(), key); |
538 |
|
} |
539 |
0 |
else if (containsArg(a)) |
540 |
|
{ |
541 |
0 |
if (pos == ArgValuesMap.Position.FIRST && getValue(a) != null) |
542 |
0 |
value = getValue(a); |
543 |
0 |
else if (pos == ArgValuesMap.Position.BEFORE |
544 |
|
&& getClosestPreviousArgValueOfArg(av, a) != null) |
545 |
0 |
value = getClosestPreviousArgValueOfArg(av, a).getValue(); |
546 |
0 |
else if (pos == ArgValuesMap.Position.AFTER |
547 |
|
&& getClosestNextArgValueOfArg(av, a, withinTypes) != null) |
548 |
0 |
value = getClosestNextArgValueOfArg(av, a, withinTypes).getValue(); |
549 |
|
|
550 |
|
|
551 |
0 |
Arg arg = av.getArg(); |
552 |
0 |
if (value == null && arg.hasOption(Opt.PRIMARY) |
553 |
|
&& arg.hasType(Type.STRUCTURE) && !a.hasOption(Opt.PRIMARY) |
554 |
|
&& (a.getFirstType() == Type.STRUCTURE |
555 |
|
|
556 |
|
)) |
557 |
|
{ |
558 |
0 |
ArgValue av2 = getArgValueOfArgWithSubValKey(a, |
559 |
|
Arg.ALLSTRUCTURES.getName()); |
560 |
0 |
if (av2 != null) |
561 |
|
{ |
562 |
0 |
value = av2.getValue(); |
563 |
|
} |
564 |
|
} |
565 |
|
|
566 |
0 |
if (value == null) |
567 |
|
{ |
568 |
|
|
569 |
0 |
for (ArgValue tmpAv : this.getArgValueList(a)) |
570 |
|
{ |
571 |
0 |
if (tmpAv.setByWildcardLinkedId()) |
572 |
|
{ |
573 |
0 |
value = tmpAv.getValue(); |
574 |
|
} |
575 |
|
} |
576 |
|
} |
577 |
|
} |
578 |
0 |
if (value == null) |
579 |
|
{ |
580 |
0 |
value = pref != null ? Cache.getDefault(pref, def) : def; |
581 |
|
} |
582 |
0 |
return value; |
583 |
|
} |
584 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
585 |
0 |
public boolean getBoolFromSubValOrArg(Arg a, SubVals sv)... |
586 |
|
{ |
587 |
0 |
return getFromSubValArgOrPref(a, sv, null, null, false); |
588 |
|
} |
589 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
590 |
0 |
public boolean getFromSubValArgOrPref(Arg a, SubVals sv, String key,... |
591 |
|
String pref, boolean def) |
592 |
|
{ |
593 |
0 |
return getFromSubValArgOrPref(a, sv, key, pref, def, false); |
594 |
|
} |
595 |
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 20 |
Complexity Density: 0.83 |
|
596 |
0 |
public boolean getFromSubValArgOrPref(Arg a, SubVals sv, String key,... |
597 |
|
String pref, boolean def, boolean invertPref) |
598 |
|
{ |
599 |
0 |
if ((key == null && a == null) || (sv == null && a == null)) |
600 |
0 |
return false; |
601 |
|
|
602 |
0 |
boolean usingArgKey = false; |
603 |
0 |
if (key == null) |
604 |
|
{ |
605 |
0 |
key = a.getName(); |
606 |
0 |
usingArgKey = true; |
607 |
|
} |
608 |
|
|
609 |
0 |
String nokey = ArgParser.NEGATESTRING + key; |
610 |
|
|
611 |
|
|
612 |
0 |
if (sv != null) |
613 |
|
{ |
614 |
|
|
615 |
0 |
if (sv.has(key) && sv.get(key) != null) |
616 |
|
{ |
617 |
0 |
if (usingArgKey) |
618 |
|
{ |
619 |
0 |
if (!(a.hasOption(Opt.BOOLEAN) || a.hasOption(Opt.UNARY))) |
620 |
|
{ |
621 |
0 |
Console.debug( |
622 |
|
"Looking for boolean in subval from non-boolean/non-unary Arg " |
623 |
|
+ a.getName()); |
624 |
0 |
return false; |
625 |
|
} |
626 |
|
} |
627 |
0 |
return sv.get(key).toLowerCase(Locale.ROOT).equals("true"); |
628 |
|
} |
629 |
|
|
630 |
|
|
631 |
0 |
if (sv.has(nokey) && sv.get(nokey) != null) |
632 |
|
{ |
633 |
0 |
if (usingArgKey) |
634 |
|
{ |
635 |
0 |
if (!(a.hasOption(Opt.BOOLEAN))) |
636 |
|
{ |
637 |
0 |
Console.debug( |
638 |
|
"Looking for negative boolean in subval from non-boolean Arg " |
639 |
|
+ a.getName()); |
640 |
0 |
return false; |
641 |
|
} |
642 |
|
} |
643 |
0 |
return !sv.get(nokey).toLowerCase(Locale.ROOT).equals("true"); |
644 |
|
} |
645 |
|
} |
646 |
|
|
647 |
|
|
648 |
0 |
if (containsArg(a)) |
649 |
0 |
return getBoolean(a); |
650 |
|
|
651 |
|
|
652 |
0 |
boolean prefVal = pref != null ? Cache.getDefault(pref, def) : false; |
653 |
0 |
return pref != null ? (invertPref ? !prefVal : prefVal) : def; |
654 |
|
} |
655 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
656 |
0 |
@Override... |
657 |
|
public String toString() |
658 |
|
{ |
659 |
0 |
StringBuilder sb = new StringBuilder(); |
660 |
0 |
for (Arg a : this.getArgKeys()) |
661 |
|
{ |
662 |
0 |
sb.append(a.argString()); |
663 |
0 |
sb.append(":\n"); |
664 |
0 |
for (ArgValue av : this.getArgValueList(a)) |
665 |
|
{ |
666 |
0 |
sb.append(" "); |
667 |
0 |
sb.append(av.getValue()); |
668 |
0 |
sb.append("\n"); |
669 |
|
} |
670 |
|
} |
671 |
0 |
return sb.toString(); |
672 |
|
} |
673 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 6 |
Complexity Density: 0.67 |
|
674 |
|
public class ArgInfo implements Comparable<ArgInfo> |
675 |
|
{ |
676 |
|
private Arg arg; |
677 |
|
|
678 |
|
private String value; |
679 |
|
|
680 |
|
private SubVals subVals; |
681 |
|
|
682 |
|
private int argIndex; |
683 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
684 |
0 |
public ArgInfo(Arg arg, String value, SubVals subVals, int argIndex)... |
685 |
|
{ |
686 |
0 |
this.arg = arg; |
687 |
0 |
this.value = value; |
688 |
0 |
this.subVals = subVals; |
689 |
0 |
this.argIndex = argIndex; |
690 |
|
} |
691 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
692 |
0 |
public Arg arg()... |
693 |
|
{ |
694 |
0 |
return arg; |
695 |
|
} |
696 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
697 |
0 |
public String value()... |
698 |
|
{ |
699 |
0 |
return value; |
700 |
|
} |
701 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
702 |
0 |
public SubVals subVals()... |
703 |
|
{ |
704 |
0 |
return subVals; |
705 |
|
} |
706 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
707 |
0 |
public int argIndex()... |
708 |
|
{ |
709 |
0 |
return argIndex; |
710 |
|
} |
711 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
712 |
0 |
@Override... |
713 |
|
public int compareTo(ArgInfo ai2) |
714 |
|
{ |
715 |
0 |
return Integer.compare(this.argIndex(), ai2.argIndex()); |
716 |
|
} |
717 |
|
} |
718 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
719 |
|
public static enum Position |
720 |
|
{ |
721 |
|
FIRST, BEFORE, AFTER |
722 |
|
} |
723 |
|
} |