1 package compbio.ws.client;
\r
2 import static compbio.ws.client.Constraints.hostkey;
\r
3 import static compbio.ws.client.Constraints.limitList;
\r
4 import static compbio.ws.client.Constraints.paramList;
\r
5 import static compbio.ws.client.Constraints.presetList;
\r
6 import static compbio.ws.client.Constraints.presetkey;
\r
7 import static compbio.ws.client.Constraints.pseparator;
\r
8 import static compbio.ws.client.Constraints.servicekey;
\r
13 * Check whether presetList is set in the command line
\r
16 * command line options
\r
17 * @return true if presetList is found, false otherwise
\r
19 static boolean listPresets(String[] cmd) {
\r
20 return keyFound(cmd, presetList);
\r
24 * Checks whether limitList parameter is in the command line
\r
27 * - command line options
\r
28 * @return true if it is, false otherwise
\r
30 static boolean listLimits(String[] cmd) {
\r
31 return keyFound(cmd, limitList);
\r
35 * Checks whether the key is in the command line
\r
39 * @return true if it is, false otherwise
\r
41 static boolean keyFound(String[] cmd, String key) {
\r
42 assert cmd != null && cmd.length > 0;
\r
44 for (int i = 0; i < cmd.length; i++) {
\r
45 String listPresets = cmd[i];
\r
46 if (listPresets.trim().equalsIgnoreCase(key)) {
\r
54 * Extracts preset name from the command line is any
\r
57 * command line options
\r
58 * @return presetName or null if no presets is defined
\r
60 static String getPresetName(String[] cmd) {
\r
61 String preset = null;
\r
62 for (int i = 0; i < cmd.length; i++) {
\r
63 String presetPrm = cmd[i];
\r
64 if (presetPrm.trim().toLowerCase()
\r
65 .startsWith(presetkey + pseparator)) {
\r
66 preset = presetPrm.substring(presetPrm.indexOf(pseparator) + 1);
\r
74 * Extracts service name from the command line
\r
77 * command line options
\r
78 * @return service name or null if it is not defined
\r
80 public static String getServiceName(String[] cmd) {
\r
81 for (int i = 0; i < cmd.length; i++) {
\r
82 String serv = cmd[i];
\r
83 if (serv.trim().toLowerCase().startsWith(servicekey + pseparator)) {
\r
84 return serv.substring(serv.indexOf(pseparator) + 1);
\r
91 * Extracts host name from the command line
\r
94 * command line options
\r
95 * @return host name or null if it is not defined
\r
97 public static String getHost(String[] cmd) {
\r
98 for (int i = 0; i < cmd.length; i++) {
\r
99 String host = cmd[i];
\r
100 if (host.trim().toLowerCase().startsWith(hostkey + pseparator)) {
\r
101 return host.substring(host.indexOf(pseparator) + 1);
\r
108 * Searches the command line keys in the array of parameters
\r
111 * command line options
\r
112 * @return true is the list of Parameters is requested, false otherwise
\r
114 static boolean listParameters(String[] cmd) {
\r
115 return keyFound(cmd, paramList);
\r