import static compbio.ws.client.Constraints.testKey;\r
\r
class CmdHelper {\r
-\r
/**\r
* Check whether presetList is set in the command line\r
* \r
static boolean keyFound(String[] cmd, String key) {\r
assert cmd != null && cmd.length > 0;\r
assert key != null;\r
- for (int i = 0; i < cmd.length; i++) {\r
- String listPresets = cmd[i];\r
- if (listPresets.trim().equalsIgnoreCase(key)) {\r
+\r
+ for (String c : cmd) {\r
+ if (c.trim().equalsIgnoreCase(key)) {\r
return true;\r
}\r
}\r
*/\r
static String getPresetName(String[] cmd) {\r
String preset = null;\r
- for (int i = 0; i < cmd.length; i++) {\r
- String presetPrm = cmd[i];\r
- if (presetPrm.trim().toLowerCase()\r
- .startsWith(presetkey + pseparator)) {\r
- preset = presetPrm.substring(presetPrm.indexOf(pseparator) + 1);\r
+ for (String c : cmd) {\r
+ if (c.trim().toLowerCase().startsWith(presetkey + pseparator)) {\r
+ preset = c.substring(c.indexOf(pseparator) + 1);\r
break;\r
}\r
}\r
* @return service name or null if it is not defined\r
*/\r
public static String getServiceName(String[] cmd) {\r
- for (int i = 0; i < cmd.length; i++) {\r
- String serv = cmd[i];\r
- if (serv.trim().toLowerCase().startsWith(servicekey + pseparator)) {\r
- return serv.substring(serv.indexOf(pseparator) + 1);\r
+ for (String c : cmd) {\r
+ if (c.trim().toLowerCase().startsWith(servicekey + pseparator)) {\r
+ return c.substring(c.indexOf(pseparator) + 1);\r
}\r
}\r
return null;\r
* @return host name or null if it is not defined\r
*/\r
public static String getHost(String[] cmd) {\r
- for (int i = 0; i < cmd.length; i++) {\r
- String host = cmd[i];\r
- if (host.trim().toLowerCase().startsWith(hostkey + pseparator)) {\r
- return host.substring(host.indexOf(pseparator) + 1);\r
+ for (String c : cmd) {\r
+ if (c.trim().toLowerCase().startsWith(hostkey + pseparator)) {\r
+ return c.substring(c.indexOf(pseparator) + 1);\r
}\r
}\r
return null;\r
static boolean listParameters(String[] cmd) {\r
return keyFound(cmd, paramList);\r
}\r
-\r
}\r
static File getFile(String[] cmd, String key, boolean mustExist)\r
throws IOException {\r
assert key != null && key.trim().length() != 0;\r
- for (int i = 0; i < cmd.length; i++) {\r
- String filename = cmd[i];\r
+ for (String c : cmd) {\r
+ String filename = c;\r
filename = filename.trim();\r
if (filename.toLowerCase().startsWith(key + pseparator)) {\r
filename = filename.substring((key + pseparator).length());\r