X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=webservices%2Fcompbio%2Fws%2Fclient%2FCmdHelper.java;h=11752305176f80efcd72ba378f5c2ffe6ca07c87;hb=d182b2d2b6ede7c952c6ca5a24b1576c6a194eed;hp=5b33aba439e4e44382889d69a5ffa25891d194ec;hpb=bcb2c33dfed7ffefa3566af8af9383d08a9022ef;p=jabaws.git diff --git a/webservices/compbio/ws/client/CmdHelper.java b/webservices/compbio/ws/client/CmdHelper.java index 5b33aba..1175230 100644 --- a/webservices/compbio/ws/client/CmdHelper.java +++ b/webservices/compbio/ws/client/CmdHelper.java @@ -1,3 +1,20 @@ +/* Copyright (c) 2011 Peter Troshin + * + * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * Apache License version 2 as published by the Apache Software Foundation + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache + * License for more details. + * + * A copy of the license is in apache_license.txt. It is also available here: + * @see: http://www.apache.org/licenses/LICENSE-2.0.txt + * + * Any republication or derived work distributed in source code form + * must include this copyright and license notice. + */ package compbio.ws.client; import static compbio.ws.client.Constraints.hostkey; import static compbio.ws.client.Constraints.limitList; @@ -10,7 +27,6 @@ import static compbio.ws.client.Constraints.servicekey; import static compbio.ws.client.Constraints.testKey; class CmdHelper { - /** * Check whether presetList is set in the command line * @@ -63,9 +79,9 @@ class CmdHelper { static boolean keyFound(String[] cmd, String key) { assert cmd != null && cmd.length > 0; assert key != null; - for (int i = 0; i < cmd.length; i++) { - String listPresets = cmd[i]; - if (listPresets.trim().equalsIgnoreCase(key)) { + + for (String c : cmd) { + if (c.trim().equalsIgnoreCase(key)) { return true; } } @@ -81,11 +97,9 @@ class CmdHelper { */ static String getPresetName(String[] cmd) { String preset = null; - for (int i = 0; i < cmd.length; i++) { - String presetPrm = cmd[i]; - if (presetPrm.trim().toLowerCase() - .startsWith(presetkey + pseparator)) { - preset = presetPrm.substring(presetPrm.indexOf(pseparator) + 1); + for (String c : cmd) { + if (c.trim().toLowerCase().startsWith(presetkey + pseparator)) { + preset = c.substring(c.indexOf(pseparator) + 1); break; } } @@ -100,10 +114,9 @@ class CmdHelper { * @return service name or null if it is not defined */ public static String getServiceName(String[] cmd) { - for (int i = 0; i < cmd.length; i++) { - String serv = cmd[i]; - if (serv.trim().toLowerCase().startsWith(servicekey + pseparator)) { - return serv.substring(serv.indexOf(pseparator) + 1); + for (String c : cmd) { + if (c.trim().toLowerCase().startsWith(servicekey + pseparator)) { + return c.substring(c.indexOf(pseparator) + 1); } } return null; @@ -117,10 +130,9 @@ class CmdHelper { * @return host name or null if it is not defined */ public static String getHost(String[] cmd) { - for (int i = 0; i < cmd.length; i++) { - String host = cmd[i]; - if (host.trim().toLowerCase().startsWith(hostkey + pseparator)) { - return host.substring(host.indexOf(pseparator) + 1); + for (String c : cmd) { + if (c.trim().toLowerCase().startsWith(hostkey + pseparator)) { + return c.substring(c.indexOf(pseparator) + 1); } } return null; @@ -136,5 +148,4 @@ class CmdHelper { static boolean listParameters(String[] cmd) { return keyFound(cmd, paramList); } - }