2 * This file is part of the Vamsas Client version 0.2.
3 * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite,
4 * Andrew Waterhouse and Dominik Lindner.
6 * Earlier versions have also been incorporated into Jalview version 2.4
7 * since 2008, and TOPALi version 2 since 2007.
9 * The Vamsas Client is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * The Vamsas Client is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the Vamsas Client. If not, see <http://www.gnu.org/licenses/>.
22 package uk.ac.vamsas.client;
24 import java.io.Serializable;
27 * Uniquely describes a vamsas client application.
31 public class ClientHandle implements Serializable {
32 static final long serialVersionUID = 0;
38 public ClientHandle(String _clientName, String _version) {
40 this.clientName = _clientName;
41 this.version = _version;
42 // this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO:
43 // decide on application handle ornthing (used to prefix new ids made by a
44 // particular application)
45 this.setClientUrn(this.generateClientUrn(this.clientName, this.version));
49 * (non-unique) human readable vamsas client name
54 * the unambiguous client identifier This may be rewritten by the Vorba object
55 * if other clients with the same name, version and user are involved in a
62 * version modifier to tag application space
67 * Generates the client Urn from the clientName and version
70 * (non-unique) human readable vamsas client name
73 * @return a String corresponding to the clientUrn
75 private String generateClientUrn(String _clientName, String _version) {
76 return ("vamsas://" + _clientName + ":" + _version + "/").intern();
80 * @return Returns the clientUrn.
82 public String getClientUrn() {
83 return this.clientUrn;
87 * May become protected - should only be set by a Vorba object.
90 * The clientUrn to set.
92 public void setClientUrn(String _clientUrn) {
93 this.clientUrn = _clientUrn;
97 * @return Returns the version.
99 public String getVersion() {
105 * The version to set.
107 public void setVersion(String _version) {
108 this.version = _version;
109 this.setClientUrn(this.generateClientUrn(this.clientName, this.version));
113 * @return Returns the clientName.
115 public String getClientName() {
116 return this.clientName;
121 * The clientName to set.
123 public void setClientName(String _clientName) {
124 this.clientName = _clientName;
125 this.setClientUrn(this.generateClientUrn(this.clientName, this.version));
128 public boolean equals(Object that) {
129 if (that instanceof ClientHandle)
130 return this.equals((ClientHandle) that);
134 public boolean equals(ClientHandle that) {
135 return ((this.clientName == null || this.clientName.equals(that.clientName))
136 && (this.version == null || this.version.equals(that.version)) && (this.clientUrn == null || this.clientUrn
137 .equals(that.clientUrn)));
140 public String getClientNCname() {
142 String ncname = clientName.replace(':', '_');
143 ncname = ncname.replace('@', '.');