/* */ package uk.ac.vamsas.client; import java.io.Serializable; /** * Uniquely describes a vamsas client application. * @author jimp */ public class ClientHandle implements Serializable { static final long serialVersionUID = 0; /** * @param clientName * @param version */ public ClientHandle(String _clientName, String _version) { super(); this.clientName = _clientName; this.version = _version; //this.setClientUrn("vamsas://"+clientName+":"+version+"/"); // TODO: decide on application handle ornthing (used to prefix new ids made by a particular application) this.setClientUrn(this.generateClientUrn(this.clientName, this.version)); } /** * (non-unique) human readable vamsas client name */ String clientName; /** * the unambiguous client identifier * This may be rewritten by the Vorba object if * other clients with the same name, version * and user are involved in a session. * */ String clientUrn; /** * version modifier to tag application space */ String version; /** * Generates the client Urn from the clientName and version * * @param clientName (non-unique) human readable vamsas client name * @param version version modifier * @return a String corresponding to the clientUrn */ private String generateClientUrn(String _clientName, String _version) { return ("vamsas://"+_clientName+":"+_version+"/").intern(); } /** * @return Returns the clientUrn. */ public String getClientUrn() { return this.clientUrn; } /** * May become protected - should only be set by a Vorba object. * @param clientUrn * The clientUrn to set. */ public void setClientUrn(String _clientUrn) { this.clientUrn = _clientUrn; } /** * @return Returns the version. */ public String getVersion() { return this.version; } /** * @param version * The version to set. */ public void setVersion(String _version) { this.version = _version; this.setClientUrn(this.generateClientUrn(this.clientName, this.version)); } /** * @return Returns the clientName. */ public String getClientName() { return this.clientName; } /** * @param clientName * The clientName to set. */ public void setClientName(String _clientName) { this.clientName = _clientName; this.setClientUrn(this.generateClientUrn(this.clientName, this.version)); } public boolean equals(Object that) { if (that instanceof ClientHandle) return this.equals((ClientHandle) that); return false; } public boolean equals(ClientHandle that) { return ( (this.clientName == null || this.clientName.equals(that.clientName)) && (this.version == null || this.version.equals(that.version)) && (this.clientUrn == null || this.clientUrn.equals(that.clientUrn))); } public String getClientNCname() { String ncname = clientName.replace(':', '_'); ncname = ncname.replace('@', '.'); return ncname; } }