applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / test / simpleclient / CommandProcessor.java
index 3b53068..48d0904 100644 (file)
@@ -1,65 +1,94 @@
-package uk.ac.vamsas.test.simpleclient;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-public class CommandProcessor {
-  /**
-   * this is not getOPT!!!! - processes a *series* of space separated commands - some of which take arguments.
-   */
-  private Vector commands;
-  /* static {
-    ClientsFileTest.commands=new Vector();
-    ClientsFileTest.commands.add(new String("add"));
-    ClientsFileTest.commands.add(new String("remove"));
-    ClientsFileTest.commands.add(new String("list"));    
-    ClientsFileTest.commands.add(new String("clear"));
-    ClientsFileTest.commands.add(new String("watch"));    
-    ClientsFileTest.commands.add(new String("monitor"));    
-  } */
-
-  public int addCommand(String cmd, int argneed, String complainString) {
-    int cnum=0;
-    if (commands==null)
-      commands = new Vector();
-    else 
-      cnum = commands.size();
-    Vector cv = new Vector();
-    cv.add(new String(cmd));
-    cv.add(new Integer(argneed));
-    cv.add(new String(complainString));
-    commands.add(cv);
-    return cnum;
-  }
-  /**
-   * Integer argl, Integer argpos, String cmd, Integer argneed, String msg in vector
-   */
-  public void complainArgs(int argl, int argpos, Vector ca) {
-    int argneed = ((Integer) ca.get(1)).intValue();
-    if (argl-argpos<argneed)
-      throw new Error(((String) ca.get(0))+" at position "+argpos+" needs "+argneed+" arguments : "+(String) ca.get(2));
-  }
-  /**
-   * find and verify a command
-   * @param args argstring
-   * @param argpos position to check for command
-   * @return matching command or -1
-   */
-  public int getCommand(String[]args, int argpos) {
-    Iterator coms = commands.iterator();
-    int com=-1, argc;
-    argc=argpos;
-    while ((coms!=null) && coms.hasNext()) {
-      com++;
-      Vector comnext = (Vector) coms.next();
-      if (args[argc].toLowerCase().equals((String) comnext.get(0))) {
-        if (comnext.size()>2)
-          complainArgs(args.length, argc+1, comnext);
-        return com;
-      }
-    }
-    return -1;
-        
-  }
-}
+/*\r
+ * This file is part of the Vamsas Client version 0.1. \r
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
+ *  Andrew Waterhouse and Dominik Lindner.\r
+ * \r
+ * Earlier versions have also been incorporated into Jalview version 2.4 \r
+ * since 2008, and TOPALi version 2 since 2007.\r
+ * \r
+ * The Vamsas Client is free software: you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation, either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *  \r
+ * The Vamsas Client is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public License\r
+ * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.\r
+ */\r
+package uk.ac.vamsas.test.simpleclient;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+public class CommandProcessor {\r
+  /**\r
+   * this is not getOPT!!!! - processes a *series* of space separated commands -\r
+   * some of which take arguments.\r
+   */\r
+  private Vector commands;\r
+\r
+  /*\r
+   * static { ClientsFileTest.commands=new Vector();\r
+   * ClientsFileTest.commands.add(new String("add"));\r
+   * ClientsFileTest.commands.add(new String("remove"));\r
+   * ClientsFileTest.commands.add(new String("list"));\r
+   * ClientsFileTest.commands.add(new String("clear"));\r
+   * ClientsFileTest.commands.add(new String("watch"));\r
+   * ClientsFileTest.commands.add(new String("monitor")); }\r
+   */\r
+\r
+  public int addCommand(String cmd, int argneed, String complainString) {\r
+    int cnum = 0;\r
+    if (commands == null)\r
+      commands = new Vector();\r
+    else\r
+      cnum = commands.size();\r
+    Vector cv = new Vector();\r
+    cv.add(new String(cmd));\r
+    cv.add(new Integer(argneed));\r
+    cv.add(new String(complainString));\r
+    commands.add(cv);\r
+    return cnum;\r
+  }\r
+\r
+  /**\r
+   * Integer argl, Integer argpos, String cmd, Integer argneed, String msg in\r
+   * vector\r
+   */\r
+  public void complainArgs(int argl, int argpos, Vector ca) {\r
+    int argneed = ((Integer) ca.get(1)).intValue();\r
+    if (argl - argpos < argneed)\r
+      throw new Error(((String) ca.get(0)) + " at position " + argpos\r
+          + " needs " + argneed + " arguments : " + (String) ca.get(2));\r
+  }\r
+\r
+  /**\r
+   * find and verify a command\r
+   * \r
+   * @param args\r
+   *          argstring\r
+   * @param argpos\r
+   *          position to check for command\r
+   * @return matching command or -1\r
+   */\r
+  public int getCommand(String[] args, int argpos) {\r
+    Iterator coms = commands.iterator();\r
+    int com = -1, argc;\r
+    argc = argpos;\r
+    while ((coms != null) && coms.hasNext()) {\r
+      com++;\r
+      Vector comnext = (Vector) coms.next();\r
+      if (args[argc].toLowerCase().equals((String) comnext.get(0))) {\r
+        if (comnext.size() > 2)\r
+          complainArgs(args.length, argc + 1, comnext);\r
+        return com;\r
+      }\r
+    }\r
+    return -1;\r
+\r
+  }\r
+}\r