refactored org to uk
[vamsas.git] / src / org / vamsas / client / SessionUrn.java
1 /**
2  * 
3  */
4 package org.vamsas.client;
5
6 import java.net.URI;
7 import java.util.Hashtable;
8 import java.util.Vector;
9
10 /**
11  * @author jimp
12  * base class for vamsas session/document types
13  * uses java.net.URI internally for construction of URN
14  */
15 public abstract class SessionUrn {
16   protected URI urn;
17   /**
18    * The types of URI protocols we understand
19    */
20   protected static final Hashtable TYPES=new Hashtable();
21   
22   /**
23    * construct urn for a locally stored session file
24    * @param type
25    * @param url
26    */
27   protected SessionUrn(String type, java.net.URL url) {
28     if (!TYPES.containsKey(type.toLowerCase()))
29       throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for URL '"+url+"'");
30     try {
31       urn = URI.create(type+"://"+url.getPath());
32     } catch (Exception e) {
33       // TODO: something better than throwing an error should be done here.
34       throw new Error(e);
35     }
36   }
37   public String getSessionUrn() {
38     return urn.toString();
39   }
40 }