From: jprocter Date: Mon, 23 Jan 2006 10:34:06 +0000 (+0000) Subject: urn classes for different kinds of vamsas object. X-Git-Tag: Release_0.2~360 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cd5ea8217681cd2e035dcd07c2701c5d438f5be9;p=vamsas.git urn classes for different kinds of vamsas object. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@160 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/org/vamsas/client/SessionUrn.java b/src/org/vamsas/client/SessionUrn.java index 2cd5fdd..ee9e980 100644 --- a/src/org/vamsas/client/SessionUrn.java +++ b/src/org/vamsas/client/SessionUrn.java @@ -5,6 +5,7 @@ package org.vamsas.client; import java.io.File; import java.net.URI; +import java.util.Hashtable; import java.util.Vector; /** @@ -17,11 +18,7 @@ public abstract class SessionUrn { /** * The types of URI protocols we understand */ - protected static final Vector TYPES=new Vector(); - static { - TYPES.add(SessionUrn.VAMSASDOCUMENT); - } - public static String VAMSASDOCUMENT="vdoc"; + protected static final Hashtable TYPES=new Hashtable(); /** * construct urn for a locally stored session file @@ -29,11 +26,13 @@ public abstract class SessionUrn { * @param file */ protected SessionUrn(String type, File file) { - if (!TYPES.contains(type.toLowerCase())) + if (!TYPES.containsKey(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(); } + + // TODO: add abstract 'handler' methods for resolving the URN to a particular class } diff --git a/src/org/vamsas/client/simpleclient/ArchiveUrn.java b/src/org/vamsas/client/simpleclient/ArchiveUrn.java new file mode 100644 index 0000000..93e889c --- /dev/null +++ b/src/org/vamsas/client/simpleclient/ArchiveUrn.java @@ -0,0 +1,24 @@ +package org.vamsas.client.simpleclient; + +import java.io.File; + +/** + * Vamsas Document URN for files understood by ArchiveReader and + * written by VamsasArchive. + * vdoc://{Absolute path to file} + * @author jimp + * + */ +public class ArchiveUrn extends org.vamsas.client.SessionUrn { + /** + * a simple vamsas document urn prefix + */ + public static String VAMSASDOCUMENT="vdoc"; + static { + TYPES.put(ArchiveUrn.VAMSASDOCUMENT, ArchiveUrn.class); + } + + public ArchiveUrn(File docLocation) { + super(VAMSASDOCUMENT, docLocation); + } +} diff --git a/src/org/vamsas/client/simpleclient/SessionUrn.java b/src/org/vamsas/client/simpleclient/SessionUrn.java index dc4d522..55edb24 100644 --- a/src/org/vamsas/client/simpleclient/SessionUrn.java +++ b/src/org/vamsas/client/simpleclient/SessionUrn.java @@ -13,9 +13,12 @@ public class SessionUrn extends org.vamsas.client.SessionUrn { * a simple client session urn prefix */ public static final String SIMPLECLIENT="simpleclient"; + public static String VAMSASDOCUMENT="vdoc"; static { - TYPES.add(SIMPLECLIENT); + TYPES.put(SIMPLECLIENT, SessionUrn.class); + TYPES.put(SessionUrn.VAMSASDOCUMENT, SessionUrn.class); } + public SessionUrn(File sessionLocation) { super(SIMPLECLIENT, sessionLocation); }