refactored org to uk
[vamsas.git] / src / uk / ac / vamsas / client / VorbaId.java
diff --git a/src/uk/ac/vamsas/client/VorbaId.java b/src/uk/ac/vamsas/client/VorbaId.java
new file mode 100644 (file)
index 0000000..8ffee9e
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Created on 12-Sep-2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package uk.ac.vamsas.client;
+
+/**
+ * The unique reference id for a Vamsas document Vobject,
+ * used by applications to refer to the vamsas Vobject
+ * within their own data space in the vamsas document.
+ * TODO: decide if VorbaId should contain a reference 
+ * to either the IVorbaIdFactory that made it or the 
+ * IClient that defines the session (it might be 
+ * convenient).
+ * @author jimp
+ */
+public class VorbaId {
+  protected String id;
+  protected VorbaId() {
+    super();
+  }
+  private VorbaId(String Id) {
+    super();
+    id = Id;
+  }
+  /**
+   * 
+   * @param vorbaObject the source of vorba Ids
+   * @param vobject the Vobject to be registered with a new vorba id
+   * @return
+   */
+  protected static VorbaId newId(IVorbaIdFactory vorbaObject, Vobject vobject) {
+    // Make unique id from appSpace info in vorbaObject
+    synchronized (vorbaObject) {
+      vobject.vorbaId=vorbaObject.makeVorbaId(vobject);
+      return vobject.vorbaId;
+    }
+  }
+  protected static VorbaId newId(String id) {
+    return new VorbaId(id);
+  }
+  /**
+   * @return Returns the id.
+   */
+  public String getId() {
+    return id;
+  }
+  /* (non-Javadoc)
+   * @see java.lang.Object#equals(java.lang.Object)
+   */
+  public boolean equals(Object obj) {
+    if (obj instanceof String)
+      return id.equals(obj);
+    else if (obj instanceof VorbaId)
+      return id.equals(((VorbaId)obj).id);
+    return false;
+  }
+  /* (non-Javadoc)
+   * @see java.lang.Object#hashCode()
+   */
+  public int hashCode() {
+    return id.hashCode();
+  }
+  /* (non-Javadoc)
+   * @see java.lang.Object#toString()
+   */
+  public String toString() {
+    return id;
+  }
+  
+}