6f86bcef5c797486ecc43a998dd65199d92ef577
[vamsas.git] / src / uk / ac / vamsas / client / ClientHandle.java
1 /*
2  */
3 package uk.ac.vamsas.client;
4
5 import java.io.Serializable;
6
7 /**
8  * Uniquely describes a vamsas client application.
9  * @author jimp 
10  */
11 public class ClientHandle implements Serializable {
12   static final long serialVersionUID = 0;
13   /**
14    * @param clientName
15    * @param version
16    */
17   public ClientHandle(String clientName, String version) {
18     super();
19     this.clientName = clientName;
20     this.version = version;
21     this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: decide on application handle ornthing (used to prefix new ids made by a particular application)
22   }
23   /**
24    * (non-unique) human readable vamsas client name
25    */
26   String clientName;
27
28   /**
29    * the unambiguous client identifier
30    * This may be rewritten by the Vorba object if
31    * other clients with the same name, version 
32    * and user are involved in a session.
33    * 
34    */
35   String clientUrn;
36
37   /**
38    * version modifier to tag application space
39    */
40   String version;
41
42   /**
43    * @return Returns the clientUrn.
44    */
45   public String getClientUrn() {
46     return clientUrn;
47   }
48
49   /**
50    * May become protected - should only be set by a Vorba object.
51    * @param clientUrn
52    *          The clientUrn to set.
53    */
54   public void setClientUrn(String clientUrn) {
55     this.clientUrn = clientUrn;
56   }
57
58   /**
59    * @return Returns the version.
60    */
61   public String getVersion() {
62     return version;
63   }
64
65   /**
66    * @param version
67    *          The version to set.
68    */
69   public void setVersion(String version) {
70     this.version = version;
71   }
72
73
74   /**
75    * @return Returns the clientName.
76    */
77   public String getClientName() {
78     return clientName;
79   }
80
81   /**
82    * @param clientName
83    *          The clientName to set.
84    */
85   public void setClientName(String clientName) {
86     this.clientName = clientName;
87   }
88
89   public boolean equals(Object that) {
90     if (that instanceof ClientHandle)
91       return this.equals((ClientHandle) that); 
92     return false;
93   }
94   public boolean equals(ClientHandle that) {
95     return (clientName.equals(that.clientName) && version.equals(that.version) && clientUrn.equals(that.clientUrn));
96   }
97 }