urn classes for different kinds of vamsas object.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 23 Jan 2006 10:13:23 +0000 (10:13 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 23 Jan 2006 10:13:23 +0000 (10:13 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@159 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/client/SessionUrn.java [new file with mode: 0644]
src/org/vamsas/client/simpleclient/SessionUrn.java [new file with mode: 0644]

diff --git a/src/org/vamsas/client/SessionUrn.java b/src/org/vamsas/client/SessionUrn.java
new file mode 100644 (file)
index 0000000..2cd5fdd
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+package org.vamsas.client;
+
+import java.io.File;
+import java.net.URI;
+import java.util.Vector;
+
+/**
+ * @author jimp
+ * base class for vamsas session/document types
+ * uses java.net.URI internally for construction of URN
+ */
+public abstract class SessionUrn {
+  URI urn;
+  /**
+   * The types of URI protocols we understand
+   */
+  protected static final Vector TYPES=new Vector();
+  static {
+    TYPES.add(SessionUrn.VAMSASDOCUMENT);
+  }
+  public static String VAMSASDOCUMENT="vdoc";
+  
+  /**
+   * construct urn for a locally stored session file
+   * @param type
+   * @param file
+   */
+  protected SessionUrn(String type, File file) {
+    if (!TYPES.contains(type.toLowerCase()))
+      throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for file '"+file.getAbsolutePath()+"'");
+    urn = URI.create(type+"://"+file.getAbsolutePath());
+  }
+  public String getSessionUrn() {
+    return urn.toString();
+  }
+}
diff --git a/src/org/vamsas/client/simpleclient/SessionUrn.java b/src/org/vamsas/client/simpleclient/SessionUrn.java
new file mode 100644 (file)
index 0000000..dc4d522
--- /dev/null
@@ -0,0 +1,22 @@
+package org.vamsas.client.simpleclient;
+
+import java.io.File;
+
+/**
+ * SessionUrn for simpleclient sessions:
+ * simpleclient://{Absolute path to session directory}
+ * @author jimp
+ *
+ */
+public class SessionUrn extends org.vamsas.client.SessionUrn {
+  /**
+   * a simple client session urn prefix
+   */
+  public static final String SIMPLECLIENT="simpleclient";
+  static {
+    TYPES.add(SIMPLECLIENT);
+  }
+  public SessionUrn(File sessionLocation) {
+    super(SIMPLECLIENT, sessionLocation);
+  }
+}