4 package uk.ac.vamsas.client;
8 import java.util.Hashtable;
9 import java.util.Vector;
13 * base class for vamsas session/document types
14 * uses java.net.URI internally for construction of URN
16 public abstract class SessionUrn {
19 * The types of URI protocols we understand
21 protected static final Hashtable TYPES=new Hashtable();
24 protected SessionUrn()
29 * construct urn for a locally stored session file
33 protected SessionUrn(String type, java.net.URL url) {
34 if (!TYPES.containsKey(type.toLowerCase()))
35 throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'");
37 //urn = URI.create(type+"://"+urlString);
38 this.setURN(type+"://"+url.getPath());
39 // urn = URI.create(type+"://"+url.getPath());
40 } catch (Exception e) {
41 // TODO: something better than throwing an error should be done here.
42 e.printStackTrace(System.err);
46 public String getSessionUrn() {
47 return this.urn.toString();
52 * create a URI from the provided String
54 * @param urnString urn to convert to a URN
56 protected void setURN(String urnString) throws NullPointerException, IllegalArgumentException
58 this.urn = URI.create(urnString);