applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / client / SessionUrn.java
index 66b73c3..7789d2d 100644 (file)
@@ -1,78 +1,99 @@
-/**
- * 
- */
-package uk.ac.vamsas.client;
-
-import java.net.URI;
-import java.util.Hashtable;
-
-/**
- * @author jimp
- * base class for vamsas session/document types
- * uses java.net.URI internally for construction of URN
- */
-public abstract class SessionUrn {
-  protected URI urn;
-  /**
-   * The types of URI protocols we understand
-   */
-  protected static final Hashtable TYPES=new Hashtable();
-  
-  
-  protected SessionUrn()
-  {
-    //
-  }
-  /**
-   * construct urn for a locally stored session file
-   * @param type
-   * @param url
-   */
-  protected SessionUrn(String type, java.net.URL url) {
-    if (!TYPES.containsKey(type.toLowerCase()))
-      throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'");
-    try {
-      
-        this.setURN(type+"://"+url.getPath());
-    //  urn = URI.create(type+"://"+url.getPath());
-    } catch (Exception e) {
-      // TODO: something better than throwing an error should be done here.
-      e.printStackTrace(System.err);
-      throw new Error(e);
-    }
-  }
-  
-  protected SessionUrn(String type, URI uri) {
-    if (!TYPES.containsKey(type.toLowerCase()))
-      throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URI '"+uri+"'");
-    try {
-      //  this.setURN(type+"://"+uri.getPath());
-      //bad hack but should do the trick
-      this.setURN(type+"://"+uri.getRawPath());
-   } catch (Exception e) {
-      // TODO: something better than throwing an error should be done here.
-      e.printStackTrace(System.err);
-      throw new Error(e);
-    }
-  }
-  
-  public String getSessionUrn() {
-    return this.urn.toString();
-  }
-  
-  /**
-   * Set the urn attribute
-   * create a URI from the provided String
-   * 
-   * @param urnString urn to convert to a URN
-   */
-  protected void setURN(String urnString) throws    InvalidSessionUrnException// NullPointerException, IllegalArgumentException 
-    {
-      try {
-        this.urn = URI.create(urnString);
-      } catch (Exception e) {
-        throw new InvalidSessionUrnException(e);
-      }
-    }
-  
-}
+/*\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.client;\r
+\r
+import java.net.URI;\r
+import java.util.Hashtable;\r
+\r
+/**\r
+ * @author jimp base class for vamsas session/document types uses java.net.URI\r
+ *         internally for construction of URN\r
+ */\r
+public abstract class SessionUrn {\r
+  protected URI urn;\r
+\r
+  /**\r
+   * The types of URI protocols we understand\r
+   */\r
+  protected static final Hashtable TYPES = new Hashtable();\r
+\r
+  protected SessionUrn() {\r
+    //\r
+  }\r
+\r
+  /**\r
+   * construct urn for a locally stored session file\r
+   * \r
+   * @param type\r
+   * @param url\r
+   */\r
+  protected SessionUrn(String type, java.net.URL url) {\r
+    if (!TYPES.containsKey(type.toLowerCase()))\r
+      throw new Error("Unknown " + this.getClass().getName() + " type '" + type\r
+          + "' for URL '" + url + "'");\r
+    try {\r
+\r
+      this.setURN(type + "://" + url.getPath());\r
+      // urn = URI.create(type+"://"+url.getPath());\r
+    } catch (Exception e) {\r
+      // TODO: something better than throwing an error should be done here.\r
+      e.printStackTrace(System.err);\r
+      throw new Error(e);\r
+    }\r
+  }\r
+\r
+  protected SessionUrn(String type, URI uri) {\r
+    if (!TYPES.containsKey(type.toLowerCase()))\r
+      throw new Error("Unknown " + this.getClass().getName() + " type '" + type\r
+          + "' for URI '" + uri + "'");\r
+    try {\r
+      // this.setURN(type+"://"+uri.getPath());\r
+      // bad hack but should do the trick\r
+      this.setURN(type + "://" + uri.getRawPath());\r
+    } catch (Exception e) {\r
+      // TODO: something better than throwing an error should be done here.\r
+      e.printStackTrace(System.err);\r
+      throw new Error(e);\r
+    }\r
+  }\r
+\r
+  public String getSessionUrn() {\r
+    return this.urn.toString();\r
+  }\r
+\r
+  /**\r
+   * Set the urn attribute create a URI from the provided String\r
+   * \r
+   * @param urnString\r
+   *          urn to convert to a URN\r
+   */\r
+  protected void setURN(String urnString) throws InvalidSessionUrnException// NullPointerException,\r
+                                                                           // IllegalArgumentException\r
+  {\r
+    try {\r
+      this.urn = URI.create(urnString);\r
+    } catch (Exception e) {\r
+      throw new InvalidSessionUrnException(e);\r
+    }\r
+  }\r
+\r
+}\r