licencing and format applied (eclipse)
[jalview.git] / src / jalview / io / vamsas / DatastoreItem.java
index bcbcf38..42e494f 100644 (file)
@@ -36,8 +36,9 @@ import uk.ac.vamsas.objects.core.Seg;
 
 /**
  * Holds all the common machinery for binding objects to vamsas objects
+ * 
  * @author JimP
- *
+ * 
  */
 public class DatastoreItem
 {
@@ -51,6 +52,7 @@ public class DatastoreItem
   Hashtable vobj2jv;
 
   IdentityHashMap jv2vobj;
+
   /**
    * @return the Vobject bound to Jalview datamodel object
    */
@@ -58,30 +60,31 @@ public class DatastoreItem
   {
     if (jv2vobj.containsKey(jvobj))
     {
-      return cdoc.getObject( (VorbaId) jv2vobj.get(jvobj));
+      return cdoc.getObject((VorbaId) jv2vobj.get(jvobj));
     }
     if (Cache.log.isDebugEnabled())
     {
-      Cache.log.debug("Returning null VorbaID binding for jalview object "+jvobj);
+      Cache.log.debug("Returning null VorbaID binding for jalview object "
+              + jvobj);
     }
     return null;
   }
 
   /**
-   *
+   * 
    * @param vobj
    * @return Jalview datamodel object bound to the vamsas document object
    */
   protected Object getvObj2jv(uk.ac.vamsas.client.Vobject vobj)
   {
-    if (vobj2jv==null)
+    if (vobj2jv == null)
       return null;
     VorbaId id = vobj.getVorbaId();
     if (id == null)
     {
       id = cdoc.registerObject(vobj);
       Cache.log
-          .debug("Registering new object and returning null for getvObj2jv");
+              .debug("Registering new object and returning null for getvObj2jv");
       return null;
     }
     if (vobj2jv.containsKey(vobj.getVorbaId()))
@@ -97,53 +100,67 @@ public class DatastoreItem
     if (id == null)
     {
       id = cdoc.registerObject(vobj);
-      if (id == null || vobj.getVorbaId() == null || cdoc.getObject(id)!=vobj)
+      if (id == null || vobj.getVorbaId() == null
+              || cdoc.getObject(id) != vobj)
       {
-        Cache.log.error("Failed to get id for " +
-                        (vobj.isRegisterable() ? "registerable" :
-                         "unregisterable") + " object " + vobj);
+        Cache.log.error("Failed to get id for "
+                + (vobj.isRegisterable() ? "registerable"
+                        : "unregisterable") + " object " + vobj);
       }
     }
 
-    if (vobj2jv.containsKey(vobj.getVorbaId()) &&
-        ! ( (VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
+    if (vobj2jv.containsKey(vobj.getVorbaId())
+            && !((VorbaId) vobj2jv.get(vobj.getVorbaId())).equals(jvobj))
     {
-      Cache.log.debug("Warning? Overwriting existing vamsas id binding for " +
-                      vobj.getVorbaId(),
-                      new Exception("Overwriting vamsas id binding."));
+      Cache.log.debug(
+              "Warning? Overwriting existing vamsas id binding for "
+                      + vobj.getVorbaId(), new Exception(
+                      "Overwriting vamsas id binding."));
     }
-    else if (jv2vobj.containsKey(jvobj) &&
-             ! ( (VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
+    else if (jv2vobj.containsKey(jvobj)
+            && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
     {
       Cache.log.debug(
-          "Warning? Overwriting existing jalview object binding for " + jvobj,
-          new Exception("Overwriting jalview object binding."));
+              "Warning? Overwriting existing jalview object binding for "
+                      + jvobj, new Exception(
+                      "Overwriting jalview object binding."));
     }
-    /* Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id " +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+" already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to bindjvvobj"));
-         }*/
+    /*
+     * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
+     * +vobj.getVorbaId()+" already bound to "+getvObj2jv(vobj)+" and "+jvobj+"
+     * already bound to "+getjv2vObj(jvobj),new Exception("Excessive call to
+     * bindjvvobj")); }
+     */
     // we just update the hash's regardless!
-    Cache.log.debug("Binding "+vobj.getVorbaId()+" to "+jvobj);
+    Cache.log.debug("Binding " + vobj.getVorbaId() + " to " + jvobj);
     vobj2jv.put(vobj.getVorbaId(), jvobj);
     // JBPNote - better implementing a hybrid invertible hash.
     jv2vobj.put(jvobj, vobj.getVorbaId());
   }
 
-  public DatastoreItem() {
+  public DatastoreItem()
+  {
     super();
   }
+
   public DatastoreItem(VamsasAppDatastore datastore)
   {
     this();
     initDatastoreItem(datastore);
     // TODO Auto-generated constructor stub
   }
+
   VamsasAppDatastore datastore = null;
+
   public void initDatastoreItem(VamsasAppDatastore ds)
   {
     datastore = ds;
-    initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(), ds.getVamsasObjectBinding(), ds.getJvObjectBinding());
+    initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(), ds
+            .getVamsasObjectBinding(), ds.getJvObjectBinding());
   }
-  public void initDatastoreItem(Entry provEntry, IClientDocument cdoc, Hashtable vobj2jv, IdentityHashMap jv2vobj)
+
+  public void initDatastoreItem(Entry provEntry, IClientDocument cdoc,
+          Hashtable vobj2jv, IdentityHashMap jv2vobj)
   {
     this.provEntry = provEntry;
     this.cdoc = cdoc;
@@ -153,7 +170,7 @@ public class DatastoreItem
 
   protected boolean isModifiable(String modifiable)
   {
-    return modifiable==null; // TODO: USE VAMSAS LIBRARY OBJECT LOCK METHODS)
+    return modifiable == null; // TODO: USE VAMSAS LIBRARY OBJECT LOCK METHODS)
   }
 
   protected Vector getjv2vObjs(Vector alsq)
@@ -166,14 +183,17 @@ public class DatastoreItem
     }
     return vObjs;
   }
+
   // utility functions
   /**
    * get start<end range of segment, adjusting for inclusivity flag and
    * polarity.
-   *
+   * 
    * @param visSeg
-   * @param ensureDirection when true - always ensure start is less than end.
-   * @return int[] { start, end, direction} where direction==1 for range running from end to start.
+   * @param ensureDirection
+   *                when true - always ensure start is less than end.
+   * @return int[] { start, end, direction} where direction==1 for range running
+   *         from end to start.
    */
   public int[] getSegRange(Seg visSeg, boolean ensureDirection)
   {
@@ -191,28 +211,29 @@ public class DatastoreItem
       start = t;
     }
     return new int[]
-        {
-        start, end, pol < 0 ? 1 : 0};
+    { start, end, pol < 0 ? 1 : 0 };
   }
+
   /**
    * provenance bits
    */
-  protected jalview.datamodel.Provenance getJalviewProvenance(Provenance prov)
+  protected jalview.datamodel.Provenance getJalviewProvenance(
+          Provenance prov)
   {
     // TODO: fix App and Action entries and check use of provenance in jalview.
     jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
     for (int i = 0; i < prov.getEntryCount(); i++)
     {
-      jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i).getAction(),
-                     prov.getEntry(i).getDate(),
-                     prov.getEntry(i).getId());
+      jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i)
+              .getAction(), prov.getEntry(i).getDate(), prov.getEntry(i)
+              .getId());
     }
 
     return jprov;
   }
 
   /**
-   *
+   * 
    * @return default initial provenance list for a Jalview created vamsas
    *         object.
    */