sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Map.java
index 5d5668d..561589c 100644 (file)
@@ -15,25 +15,35 @@ import org.exolab.castor.xml.Marshaller;
 import org.exolab.castor.xml.Unmarshaller;\r
 \r
 /**\r
- * From: Offset to first\r
- *  position in dataset sequence record that\r
- *  this database entry maps to To: Offset\r
- *  to last position in dataset sequence\r
- *  record that this database entry maps to\r
- *  Start: Offset to first last position in\r
- *  database entry that first (or offset)\r
- *  position in sequence maps to End: Offset\r
- *  to last position in database entry that\r
- *  last (offset) position in sequence maps\r
- *  to \r
+ * the local mapType maps from the parent\r
+ *  sequence coordinate frame to the reference\r
+ *  frame defined by the dbRef element.\r
+ *  The mapped mapType is the mapped range defined\r
+ *  on the dbRef element's reference frame.\r
+ *  Conventionally, the unit attribute defaults to 1, or\r
+ *  will be inferred from the local sequence's\r
+ *  dictionary type and any dictionary type associated\r
+ *  with the database being mapped to. \r
+ *  However, it may be used to avoid ambiguity.\r
+ *  \r
  * \r
  * @version $Revision$ $Date$\r
  */\r
-public class Map extends uk.ac.vamsas.objects.core.MapList \r
+public class Map extends uk.ac.vamsas.objects.core.MapType \r
 implements java.io.Serializable\r
 {\r
 \r
 \r
+      //--------------------------/\r
+     //- Class/Member Variables -/\r
+    //--------------------------/\r
+\r
+    /**\r
+     * Field _id.\r
+     */\r
+    private java.lang.String _id;\r
+\r
+\r
       //----------------/\r
      //- Constructors -/\r
     //----------------/\r
@@ -63,9 +73,44 @@ implements java.io.Serializable
         \r
         if (obj instanceof Map) {\r
         \r
-        return true;\r
+            Map temp = (Map)obj;\r
+            boolean thcycle;\r
+            boolean tmcycle;\r
+            if (this._id != null) {\r
+                if (temp._id == null) return false;\r
+                if (this._id != temp._id) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._id.equals(temp._id)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
+                    }\r
+                }\r
+            } else if (temp._id != null)\r
+                return false;\r
+            return true;\r
+        }\r
+        return false;\r
     }\r
-    return false;\r
+\r
+    /**\r
+     * Returns the value of field 'id'.\r
+     * \r
+     * @return the value of field 'Id'.\r
+     */\r
+    public java.lang.String getId(\r
+    ) {\r
+        return this._id;\r
     }\r
 \r
     /**\r
@@ -81,6 +126,11 @@ implements java.io.Serializable
         int result = super.hashCode();\r
         \r
         long tmp;\r
+        if (_id != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_id)) {\r
+           result = 37 * result + _id.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_id);\r
+        }\r
         \r
         return result;\r
     }\r
@@ -133,6 +183,16 @@ implements java.io.Serializable
     }\r
 \r
     /**\r
+     * Sets the value of field 'id'.\r
+     * \r
+     * @param id the value of field 'id'.\r
+     */\r
+    public void setId(\r
+            final java.lang.String id) {\r
+        this._id = id;\r
+    }\r
+\r
+    /**\r
      * Method unmarshal.\r
      * \r
      * @param reader\r
@@ -140,12 +200,12 @@ implements java.io.Serializable
      * null or if any SAXException is thrown during marshaling\r
      * @throws org.exolab.castor.xml.ValidationException if this\r
      * object is an invalid instance according to the schema\r
-     * @return the unmarshaled uk.ac.vamsas.objects.core.MapList\r
+     * @return the unmarshaled uk.ac.vamsas.objects.core.MapType\r
      */\r
-    public static uk.ac.vamsas.objects.core.MapList unmarshal(\r
+    public static uk.ac.vamsas.objects.core.MapType unmarshal(\r
             final java.io.Reader reader)\r
     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
-        return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Map.class, reader);\r
+        return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Map.class, reader);\r
     }\r
 \r
     /**\r