Alifold results are now parsed and stored in a ScoreManager object
[jabaws.git] / webservices / compbio / ws / client / CmdHelper.java
index 1faf3dc..1175230 100644 (file)
@@ -1,14 +1,32 @@
+/* Copyright (c) 2011 Peter Troshin\r
+ *  \r
+ *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0     \r
+ * \r
+ *  This library is free software; you can redistribute it and/or modify it under the terms of the\r
+ *  Apache License version 2 as published by the Apache Software Foundation\r
+ * \r
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
+ */\r
 package compbio.ws.client;\r
 import static compbio.ws.client.Constraints.hostkey;\r
 import static compbio.ws.client.Constraints.limitList;\r
+import static compbio.ws.client.Constraints.listServices;\r
 import static compbio.ws.client.Constraints.paramList;\r
 import static compbio.ws.client.Constraints.presetList;\r
 import static compbio.ws.client.Constraints.presetkey;\r
 import static compbio.ws.client.Constraints.pseparator;\r
 import static compbio.ws.client.Constraints.servicekey;\r
+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
@@ -32,6 +50,26 @@ class CmdHelper {
        }\r
 \r
        /**\r
+        * list available services\r
+        * \r
+        * @param cmd\r
+        * @return\r
+        */\r
+       static boolean listServices(String[] cmd) {\r
+               return keyFound(cmd, listServices);\r
+       }\r
+\r
+       /**\r
+        * tests service\r
+        * \r
+        * @param cmd\r
+        * @return\r
+        */\r
+       static boolean testService(String[] cmd) {\r
+               return keyFound(cmd, testKey);\r
+       }\r
+\r
+       /**\r
         * Checks whether the key is in the command line\r
         * \r
         * @param cmd\r
@@ -41,9 +79,9 @@ class CmdHelper {
        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
@@ -59,11 +97,9 @@ class CmdHelper {
         */\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
@@ -78,10 +114,9 @@ class CmdHelper {
         * @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
@@ -95,10 +130,9 @@ class CmdHelper {
         * @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
@@ -114,5 +148,4 @@ class CmdHelper {
        static boolean listParameters(String[] cmd) {\r
                return keyFound(cmd, paramList);\r
        }\r
-\r
 }\r