1 /* Copyright (c) 2011 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
18 package compbio.ws.client;
\r
19 import static compbio.ws.client.Constraints.hostkey;
\r
20 import static compbio.ws.client.Constraints.limitList;
\r
21 import static compbio.ws.client.Constraints.listServices;
\r
22 import static compbio.ws.client.Constraints.listServicesOld;
\r
23 import static compbio.ws.client.Constraints.paramList;
\r
24 import static compbio.ws.client.Constraints.presetList;
\r
25 import static compbio.ws.client.Constraints.presetkey;
\r
26 import static compbio.ws.client.Constraints.pseparator;
\r
27 import static compbio.ws.client.Constraints.servicekey;
\r
28 import static compbio.ws.client.Constraints.testKey;
\r
32 * Check whether presetList is set in the command line
\r
35 * command line options
\r
36 * @return true if presetList is found, false otherwise
\r
38 static boolean listPresets(String[] cmd) {
\r
39 return keyFound(cmd, presetList);
\r
43 * Checks whether limitList parameter is in the command line
\r
46 * - command line options
\r
47 * @return true if it is, false otherwise
\r
49 static boolean listLimits(String[] cmd) {
\r
50 return keyFound(cmd, limitList);
\r
54 * list available services
\r
59 static boolean listServices(String[] cmd) {
\r
60 return (keyFound(cmd, listServices) || keyFound(cmd, listServicesOld));
\r
69 static boolean testService(String[] cmd) {
\r
70 return keyFound(cmd, testKey);
\r
74 * Checks whether the key is in the command line
\r
78 * @return true if it is, false otherwise
\r
80 static boolean keyFound(String[] cmd, String key) {
\r
81 assert cmd != null && cmd.length > 0;
\r
84 for (String c : cmd) {
\r
85 if (c.trim().equalsIgnoreCase(key)) {
\r
93 * Extracts preset name from the command line is any
\r
96 * command line options
\r
97 * @return presetName or null if no presets is defined
\r
99 static String getPresetName(String[] cmd) {
\r
100 String preset = null;
\r
101 for (String c : cmd) {
\r
102 if (c.trim().toLowerCase().startsWith(presetkey + pseparator)) {
\r
103 preset = c.substring(c.indexOf(pseparator) + 1);
\r
111 * Extracts service name from the command line
\r
114 * command line options
\r
115 * @return service name or null if it is not defined
\r
117 public static String getServiceName(String[] cmd) {
\r
118 for (String c : cmd) {
\r
119 if (c.trim().toLowerCase().startsWith(servicekey + pseparator)) {
\r
120 return c.substring(c.indexOf(pseparator) + 1);
\r
127 * Extracts host name from the command line
\r
130 * command line options
\r
131 * @return host name or null if it is not defined
\r
133 public static String getHost(String[] cmd) {
\r
134 for (String c : cmd) {
\r
135 if (c.trim().toLowerCase().startsWith(hostkey + pseparator)) {
\r
136 return c.substring(c.indexOf(pseparator) + 1);
\r
143 * Searches the command line keys in the array of parameters
\r
146 * command line options
\r
147 * @return true is the list of Parameters is requested, false otherwise
\r
149 static boolean listParameters(String[] cmd) {
\r
150 return keyFound(cmd, paramList);
\r