sequence mappings and DbRef mapping objects unified and source binding for castor...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Treenode.java
index 320f7de..1a8620e 100644 (file)
@@ -15,9 +15,8 @@ import org.exolab.castor.xml.Marshaller;
 import org.exolab.castor.xml.Unmarshaller;\r
 \r
 /**\r
- * node identity and mapping data between tree representations and\r
- * vamsas document objects\r
- *  \r
+ * node identity and mapping data between tree\r
+ *  representations and vamsas document objects \r
  * \r
  * @version $Revision$ $Date$\r
  */\r
@@ -31,16 +30,15 @@ implements java.io.Serializable
     //--------------------------/\r
 \r
     /**\r
-     * reference to one or more trees containing the node being\r
-     * described.\r
-     *  \r
+     * reference to one or more trees containing\r
+     *  the node being described. \r
      */\r
     private java.util.Vector _treeId;\r
 \r
     /**\r
-     * String uniquely identifying a particular node in the\r
-     * referenced tree according to the format of the tree\r
-     * representation that is referenced.\r
+     * String uniquely identifying a particular\r
+     *  node in the referenced tree according to the format of\r
+     *  the tree representation that is referenced.\r
      *  \r
      */\r
     private java.lang.String _nodespec;\r
@@ -115,19 +113,51 @@ implements java.io.Serializable
         if (obj instanceof Treenode) {\r
         \r
             Treenode temp = (Treenode)obj;\r
+            boolean thcycle;\r
+            boolean tmcycle;\r
             if (this._treeId != null) {\r
                 if (temp._treeId == null) return false;\r
-                else if (!(this._treeId.equals(temp._treeId))) \r
-                    return false;\r
-            }\r
-            else if (temp._treeId != null)\r
+                if (this._treeId != temp._treeId) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeId);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeId);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._treeId.equals(temp._treeId)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId);\r
+                    }\r
+                }\r
+            } else if (temp._treeId != null)\r
                 return false;\r
             if (this._nodespec != null) {\r
                 if (temp._nodespec == null) return false;\r
-                else if (!(this._nodespec.equals(temp._nodespec))) \r
-                    return false;\r
-            }\r
-            else if (temp._nodespec != null)\r
+                if (this._nodespec != temp._nodespec) {\r
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._nodespec);\r
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._nodespec);\r
+                    if (thcycle!=tmcycle) {\r
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); };\r
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); };\r
+                        return false;\r
+                    }\r
+                    if (!thcycle) {\r
+                        if (!this._nodespec.equals(temp._nodespec)) {\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec);\r
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec);\r
+                            return false;\r
+                        }\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec);\r
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec);\r
+                    }\r
+                }\r
+            } else if (temp._nodespec != null)\r
                 return false;\r
             return true;\r
         }\r
@@ -137,8 +167,9 @@ implements java.io.Serializable
     /**\r
      * Returns the value of field 'nodespec'. The field 'nodespec'\r
      * has the following description: String uniquely identifying a\r
-     * particular node in the referenced tree according to the\r
-     * format of the tree representation that is referenced.\r
+     * particular\r
+     *  node in the referenced tree according to the format of\r
+     *  the tree representation that is referenced.\r
      *  \r
      * \r
      * @return the value of field 'Nodespec'.\r
@@ -217,11 +248,15 @@ implements java.io.Serializable
         int result = super.hashCode();\r
         \r
         long tmp;\r
-        if (_treeId != null) {\r
+        if (_treeId != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_treeId)) {\r
            result = 37 * result + _treeId.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_treeId);\r
         }\r
-        if (_nodespec != null) {\r
+        if (_nodespec != null\r
+            && !org.castor.util.CycleBreaker.startingToCycle(_nodespec)) {\r
            result = 37 * result + _nodespec.hashCode();\r
+           org.castor.util.CycleBreaker.releaseCycleHandle(_nodespec);\r
         }\r
         \r
         return result;\r
@@ -308,8 +343,9 @@ implements java.io.Serializable
     /**\r
      * Sets the value of field 'nodespec'. The field 'nodespec' has\r
      * the following description: String uniquely identifying a\r
-     * particular node in the referenced tree according to the\r
-     * format of the tree representation that is referenced.\r
+     * particular\r
+     *  node in the referenced tree according to the format of\r
+     *  the tree representation that is referenced.\r
      *  \r
      * \r
      * @param nodespec the value of field 'nodespec'.\r