applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / test / ExampleApplication.java
index 2fb20a3..6ebfcec 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * This file is part of the Vamsas Client version 0.1. 
+ * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
+ *  Andrew Waterhouse and Dominik Lindner.
+ * 
+ * Earlier versions have also been incorporated into Jalview version 2.4 
+ * since 2008, and TOPALi version 2 since 2007.
+ * 
+ * The Vamsas Client is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *  
+ * The Vamsas Client 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
+ * GNU Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
+ */
 package uk.ac.vamsas.test;
 
 import uk.ac.vamsas.client.*;
@@ -378,16 +399,19 @@ public class ExampleApplication {
   }
 
   public String Usage = "ExampleApplication :/n [-arena <vamsasFileDirectory>][-session <vamsasSessionURN>] <action> [+<arguments>]\n"
-      + "<action> is one of :\n\tsave,new,watch\n"+
-      "-arena and -session are not yet supported"; // TODO for release
+      + "<action> is one of :\n\tsave,new,watch\n"
+      + "-arena and -session are not yet supported"; // TODO for release
 
   String sess = null;
 
   String importFile = null;
 
   String outputFile = null;
-  boolean newSession=false;
-  boolean imported=false;
+
+  boolean newSession = false;
+
+  boolean imported = false;
+
   private boolean parseArgs(String args[]) {
     if (args.length == 0) {
       return false;
@@ -396,14 +420,15 @@ public class ExampleApplication {
     boolean parsed = false;
     while (!parsed && cpos < args.length) {
       // TODO: note importDocument not yet supported.
-      //if (args[cpos].toLowerCase().equals("load") && cpos + 1 < args.length) {
-      //  importFile = args[cpos + 1];
-      //  cpos += 2;
-      //  continue;
-      //}
+      // if (args[cpos].toLowerCase().equals("load") && cpos + 1 < args.length)
+      // {
+      // importFile = args[cpos + 1];
+      // cpos += 2;
+      // continue;
+      // }
       if (args[cpos].toLowerCase().equals("new") && cpos + 1 < args.length) {
         importFile = args[cpos + 1];
-        newSession=true;
+        newSession = true;
         cpos += 2;
         continue;
       }
@@ -465,9 +490,9 @@ public class ExampleApplication {
     // get an Iclient with session data
     app = new ClientHandle("uk.ac.vamsas.test.ExampleApplication", "0.1");
     user = new UserHandle("arnolduser", "deathsdoor");
-    if (sess!=null && importFile!=null)
-    {
-      System.err.println("Import of an existing document into an existing session is not fully supported yet.");
+    if (sess != null && importFile != null) {
+      System.err
+          .println("Import of an existing document into an existing session is not fully supported yet.");
       System.exit(3);
     }
     try {
@@ -475,32 +500,32 @@ public class ExampleApplication {
         System.out.println("Connecting to " + sess);
         vorbaclient = clientfactory.getIClient(app, user, sess);
       } else {
-        if (newSession)
-        {
-          if (importFile==null)
-          {
+        if (newSession) {
+          if (importFile == null) {
             System.out.println("Connecting to a new VAMSAS Session.");
             vorbaclient = clientfactory.getNewSessionIClient(app, user);
           } else {
-            System.out.println("Connecting to a new VAMSAS Session to share data in existing document:"+importFile);
+            System.out
+                .println("Connecting to a new VAMSAS Session to share data in existing document:"
+                    + importFile);
             File vfile = new File(importFile);
-            vorbaclient = clientfactory.openAsNewSessionIClient(app, user, vfile);
-            System.out.println("Succesfully imported document into new session.");
+            vorbaclient = clientfactory.openAsNewSessionIClient(app, user,
+                vfile);
+            System.out
+                .println("Succesfully imported document into new session.");
             imported = true;
-            importFile=null;
+            importFile = null;
           }
         } else {
-            vorbaclient = clientfactory.getIClient(app, user);
+          vorbaclient = clientfactory.getIClient(app, user);
         }
       }
-    }
-    catch (InvalidSessionDocumentException e) {
-      System.err.println("Failed to create a session to share "+importFile);
+    } catch (InvalidSessionDocumentException e) {
+      System.err.println("Failed to create a session to share " + importFile);
       System.err.println("Sorry it didn't work out. This is what went wrong:");
       e.printStackTrace(System.err);
       System.exit(3);
-    }
-    catch (NoDefaultSessionException e) {
+    } catch (NoDefaultSessionException e) {
       System.err
           .println("There appear to be several sessions to choose from :");
       String[] sessions = clientfactory.getCurrentSessions();
@@ -522,7 +547,7 @@ public class ExampleApplication {
       File vfile = new File(importFile);
       try {
         vorbaclient.importDocument(vfile);
-        imported=true;
+        imported = true;
       } catch (Exception e) {
         System.err.println("Failed to import file " + importFile);
         System.err.println("Exception received was " + e);
@@ -544,11 +569,11 @@ public class ExampleApplication {
     // get document data
     try {
       IClientDocument cdoc = vorbaclient.getClientDocument();
-      if (imported)
-      {
-        if (cdoc.getVamsasRoots()==null || cdoc.getVamsasRoots()[0].getDataSetCount()<1)
-        {
-          System.err.println("Imported an Empty vamsas document. Is this correct ?");
+      if (imported) {
+        if (cdoc.getVamsasRoots() == null
+            || cdoc.getVamsasRoots()[0].getDataSetCount() < 1) {
+          System.err
+              .println("Imported an Empty vamsas document. Is this correct ?");
         }
       }
       processVamsasDocument(cdoc);
@@ -598,7 +623,8 @@ public class ExampleApplication {
           }
           try {
             Thread.sleep(200);
-          } catch (Exception e){}
+          } catch (Exception e) {
+          }
         }
       } else {
         if (System.currentTimeMillis() > shutdown) {