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.listServices;
\r
5 import static compbio.ws.client.Constraints.paramList;
\r
6 import static compbio.ws.client.Constraints.presetList;
\r
7 import static compbio.ws.client.Constraints.presetkey;
\r
8 import static compbio.ws.client.Constraints.pseparator;
\r
9 import static compbio.ws.client.Constraints.servicekey;
\r
10 import static compbio.ws.client.Constraints.testKey;
\r
15 * Check whether presetList is set in the command line
\r
18 * command line options
\r
19 * @return true if presetList is found, false otherwise
\r
21 static boolean listPresets(String[] cmd) {
\r
22 return keyFound(cmd, presetList);
\r
26 * Checks whether limitList parameter is in the command line
\r
29 * - command line options
\r
30 * @return true if it is, false otherwise
\r
32 static boolean listLimits(String[] cmd) {
\r
33 return keyFound(cmd, limitList);
\r
37 * list available services
\r
42 static boolean listServices(String[] cmd) {
\r
43 return keyFound(cmd, listServices);
\r
52 static boolean testService(String[] cmd) {
\r
53 return keyFound(cmd, testKey);
\r
57 * Checks whether the key is in the command line
\r
61 * @return true if it is, false otherwise
\r
63 static boolean keyFound(String[] cmd, String key) {
\r
64 assert cmd != null && cmd.length > 0;
\r
66 for (int i = 0; i < cmd.length; i++) {
\r
67 String listPresets = cmd[i];
\r
68 if (listPresets.trim().equalsIgnoreCase(key)) {
\r
76 * Extracts preset name from the command line is any
\r
79 * command line options
\r
80 * @return presetName or null if no presets is defined
\r
82 static String getPresetName(String[] cmd) {
\r
83 String preset = null;
\r
84 for (int i = 0; i < cmd.length; i++) {
\r
85 String presetPrm = cmd[i];
\r
86 if (presetPrm.trim().toLowerCase()
\r
87 .startsWith(presetkey + pseparator)) {
\r
88 preset = presetPrm.substring(presetPrm.indexOf(pseparator) + 1);
\r
96 * Extracts service name from the command line
\r
99 * command line options
\r
100 * @return service name or null if it is not defined
\r
102 public static String getServiceName(String[] cmd) {
\r
103 for (int i = 0; i < cmd.length; i++) {
\r
104 String serv = cmd[i];
\r
105 if (serv.trim().toLowerCase().startsWith(servicekey + pseparator)) {
\r
106 return serv.substring(serv.indexOf(pseparator) + 1);
\r
113 * Extracts host name from the command line
\r
116 * command line options
\r
117 * @return host name or null if it is not defined
\r
119 public static String getHost(String[] cmd) {
\r
120 for (int i = 0; i < cmd.length; i++) {
\r
121 String host = cmd[i];
\r
122 if (host.trim().toLowerCase().startsWith(hostkey + pseparator)) {
\r
123 return host.substring(host.indexOf(pseparator) + 1);
\r
130 * Searches the command line keys in the array of parameters
\r
133 * command line options
\r
134 * @return true is the list of Parameters is requested, false otherwise
\r
136 static boolean listParameters(String[] cmd) {
\r
137 return keyFound(cmd, paramList);
\r