| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.bin; |
| 22 |
|
|
| 23 |
|
import jalview.util.Platform; |
| 24 |
|
|
| 25 |
|
import java.net.URLDecoder; |
| 26 |
|
import java.util.ArrayList; |
| 27 |
|
import java.util.List; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
|
| 37 |
|
|
| |
|
| 73.8% |
Uncovered Elements: 16 (61) |
Complexity: 20 |
Complexity Density: 0.61 |
|
| 38 |
|
public class ArgsParser |
| 39 |
|
{ |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
public static final String NOCALCULATION = "nocalculation"; |
| 44 |
|
|
| 45 |
|
public static final String NOMENUBAR = "nomenubar"; |
| 46 |
|
|
| 47 |
|
public static final String NOSTATUS = "nostatus"; |
| 48 |
|
|
| 49 |
|
public static final String SHOWOVERVIEW = "showoverview"; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
public static final String ANNOTATIONS = "annotations"; |
| 53 |
|
|
| 54 |
|
public static final String COLOUR = "colour"; |
| 55 |
|
|
| 56 |
|
public static final String FEATURES = "features"; |
| 57 |
|
|
| 58 |
|
public static final String GROOVY = "groovy"; |
| 59 |
|
|
| 60 |
|
public static final String GROUPS = "groups"; |
| 61 |
|
|
| 62 |
|
public static final String HEADLESS = "headless"; |
| 63 |
|
|
| 64 |
|
public static final String JABAWS = "jabaws"; |
| 65 |
|
|
| 66 |
|
public static final String NOANNOTATION = "no-annotation"; |
| 67 |
|
|
| 68 |
|
public static final String NOANNOTATION2 = "noannotation"; |
| 69 |
|
|
| 70 |
|
public static final String NODISPLAY = "nodisplay"; |
| 71 |
|
|
| 72 |
|
public static final String NOGUI = "nogui"; |
| 73 |
|
|
| 74 |
|
public static final String NONEWS = "nonews"; |
| 75 |
|
|
| 76 |
|
public static final String NOQUESTIONNAIRE = "noquestionnaire"; |
| 77 |
|
|
| 78 |
|
public static final String NOSORTBYTREE = "nosortbytree"; |
| 79 |
|
|
| 80 |
|
public static final String NOUSAGESTATS = "nousagestats"; |
| 81 |
|
|
| 82 |
|
public static final String OPEN = "open"; |
| 83 |
|
|
| 84 |
|
public static final String OPEN2 = "open2"; |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
public static final String PROPS = "props"; |
| 89 |
|
|
| 90 |
|
public static final String QUESTIONNAIRE = "questionnaire"; |
| 91 |
|
|
| 92 |
|
public static final String SETPROP = "setprop"; |
| 93 |
|
|
| 94 |
|
public static final String SORTBYTREE = "sortbytree"; |
| 95 |
|
|
| 96 |
|
public static final String TREE = "tree"; |
| 97 |
|
|
| 98 |
|
public static final String VDOC = "vdoc"; |
| 99 |
|
|
| 100 |
|
public static final String VSESS = "vsess"; |
| 101 |
|
|
| 102 |
|
private List<String> vargs = null; |
| 103 |
|
|
| 104 |
|
private boolean isApplet; |
| 105 |
|
|
| 106 |
|
private AppletParams appletParams; |
| 107 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 108 |
0 |
public boolean isApplet()... |
| 109 |
|
{ |
| 110 |
0 |
return isApplet; |
| 111 |
|
} |
| 112 |
|
|
| |
|
| 75% |
Uncovered Elements: 5 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 113 |
142 |
public ArgsParser(String[] args)... |
| 114 |
|
{ |
| 115 |
142 |
vargs = new ArrayList<>(); |
| 116 |
142 |
isApplet = (args.length > 0 && args[0].startsWith("<applet")); |
| 117 |
142 |
if (isApplet) |
| 118 |
|
{ |
| 119 |
0 |
appletParams = AppletParams.getAppletParams(args, vargs); |
| 120 |
|
} |
| 121 |
|
else |
| 122 |
|
{ |
| 123 |
142 |
if (Platform.isJS()) |
| 124 |
|
|
| 125 |
|
{ |
| 126 |
0 |
isApplet = true; |
| 127 |
0 |
appletParams = AppletParams |
| 128 |
|
.getAppletParams(Platform.getAppletInfoAsMap(), vargs); |
| 129 |
|
} |
| 130 |
930 |
for (int i = 0; i < args.length; i++) |
| 131 |
|
{ |
| 132 |
788 |
String arg = args[i].trim(); |
| 133 |
788 |
if (arg.charAt(0) == '-') |
| 134 |
|
{ |
| 135 |
628 |
arg = arg.substring(1); |
| 136 |
|
} |
| 137 |
788 |
vargs.add(arg); |
| 138 |
|
} |
| 139 |
|
} |
| 140 |
|
} |
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
@param |
| 146 |
|
@return |
| 147 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 148 |
454 |
public String getValue(String arg)... |
| 149 |
|
{ |
| 150 |
454 |
return getValue(arg, false); |
| 151 |
|
} |
| 152 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 5 |
Complexity Density: 0.45 |
|
| 153 |
777 |
public String getValue(String arg, boolean utf8decode)... |
| 154 |
|
{ |
| 155 |
777 |
int index = vargs.indexOf(arg); |
| 156 |
777 |
String dc = null, ret = null; |
| 157 |
777 |
if (index != -1) |
| 158 |
|
{ |
| 159 |
28 |
ret = vargs.get(index + 1).toString(); |
| 160 |
28 |
vargs.remove(index); |
| 161 |
28 |
vargs.remove(index); |
| 162 |
28 |
if (utf8decode && ret != null) |
| 163 |
|
{ |
| 164 |
24 |
try |
| 165 |
|
{ |
| 166 |
24 |
dc = URLDecoder.decode(ret, "UTF-8"); |
| 167 |
24 |
ret = dc; |
| 168 |
|
} catch (Exception e) |
| 169 |
|
{ |
| 170 |
|
|
| 171 |
|
} |
| 172 |
|
} |
| 173 |
|
} |
| 174 |
777 |
return ret; |
| 175 |
|
} |
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
@param |
| 181 |
|
@return |
| 182 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 183 |
1888 |
public boolean contains(String arg)... |
| 184 |
|
{ |
| 185 |
1888 |
if (vargs.contains(arg)) |
| 186 |
|
{ |
| 187 |
22 |
vargs.remove(arg); |
| 188 |
22 |
return true; |
| 189 |
|
} |
| 190 |
|
else |
| 191 |
|
{ |
| 192 |
1866 |
return false; |
| 193 |
|
} |
| 194 |
|
} |
| 195 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 196 |
36 |
public String nextValue()... |
| 197 |
|
{ |
| 198 |
36 |
return vargs.remove(0); |
| 199 |
|
} |
| 200 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 201 |
55 |
public int getSize()... |
| 202 |
|
{ |
| 203 |
55 |
return vargs.size(); |
| 204 |
|
} |
| 205 |
|
|
| |
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 2 |
|
| 206 |
0 |
public Object getAppletValue(String key, String def, boolean asString)... |
| 207 |
|
{ |
| 208 |
0 |
Object value; |
| 209 |
0 |
return (appletParams == null ? null |
| 210 |
? |
: (value = appletParams.get(key.toLowerCase())) == null |
| 211 |
0 |
? def : asString ? "" + value |
| 212 |
|
: value); |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
} |