2 * This file is part of the Vamsas Client version 0.1.
3 * Copyright 2009 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 * The unique reference id for a Vamsas document Vobject, used by applications
28 * to refer to the vamsas Vobject within their own data space in the vamsas
29 * document. This is serializable (thanks to Dominik Lindner) so an application
30 * can store it easily.
34 public class VorbaId implements Serializable {
36 * 1 is first vamsas release ID version.
38 private static final long serialVersionUID = 1L;
46 private VorbaId(String Id) {
54 * the source of vorba Ids
56 * the Vobject to be registered with a new vorba id
59 protected static VorbaId newId(IVorbaIdFactory vorbaObject, Vobject vobject) {
60 // Make unique id from appSpace info in vorbaObject
61 synchronized (vorbaObject) {
62 vobject.vorbaId = vorbaObject.makeVorbaId(vobject);
63 return vobject.vorbaId;
68 * protected VorbaId constructor used when turning XML ID strings into vorba
72 * @return VorbaId object or null if string was null.
74 protected static VorbaId newId(String id) {
75 return (id == null) ? null : new VorbaId(id);
79 * @return Returns the id.
81 public String getId() {
88 * @see java.lang.Object#equals(java.lang.Object)
90 public boolean equals(Object obj) {
91 if (obj instanceof String)
92 return id.equals(obj);
93 else if (obj instanceof VorbaId)
94 return id.equals(((VorbaId) obj).id);
101 * @see java.lang.Object#hashCode()
103 public int hashCode() {
104 return id.hashCode();
110 * @see java.lang.Object#toString()
112 public String toString() {