fixed probable bug
[vamsas.git] / src / org / vamsas / client / SessionUrn.java
1 /**
2  * 
3  */
4 package org.vamsas.client;
5
6 import java.io.File;
7 import java.net.URI;
8 import java.util.Hashtable;
9 import java.util.Vector;
10
11 /**
12  * @author jimp
13  * base class for vamsas session/document types
14  * uses java.net.URI internally for construction of URN
15  */
16 public abstract class SessionUrn {
17   URI urn;
18   /**
19    * The types of URI protocols we understand
20    */
21   protected static final Hashtable TYPES=new Hashtable();
22   
23   /**
24    * construct urn for a locally stored session file
25    * @param type
26    * @param file
27    */
28   protected SessionUrn(String type, File file) {
29     if (!TYPES.containsKey(type.toLowerCase()))
30       throw new Error("Unknown "+this.getClass().getName()+" type '"+type+"' for file '"+file.getAbsolutePath()+"'");
31     urn = URI.create(type+"://"+file.getAbsolutePath());
32   }
33   public String getSessionUrn() {
34     return urn.toString();
35   }
36   /**
37    * TODO: LATER: think about this again.
38    * @return File(urn.getPath())
39    */
40   public File asFile() {
41     return new File(urn.getPath());
42   }
43   // TODO: add abstract 'handler' methods for resolving the URN to a particular class
44 }