X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fobjects%2Fcore%2FTreenode.java;h=1a8620e3103f866bab7ad4e4d830b8121dd47351;hb=f5306591821b5f6d4e381ff30b647bd149d51f43;hp=320f7de281ae3aa30ad4e08fd68c0cc6ec82b732;hpb=eae55a9d436c058b8f03036faa0a4baa930c2cd5;p=vamsas.git diff --git a/src/uk/ac/vamsas/objects/core/Treenode.java b/src/uk/ac/vamsas/objects/core/Treenode.java index 320f7de..1a8620e 100644 --- a/src/uk/ac/vamsas/objects/core/Treenode.java +++ b/src/uk/ac/vamsas/objects/core/Treenode.java @@ -15,9 +15,8 @@ import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.Unmarshaller; /** - * node identity and mapping data between tree representations and - * vamsas document objects - * + * node identity and mapping data between tree + * representations and vamsas document objects * * @version $Revision$ $Date$ */ @@ -31,16 +30,15 @@ implements java.io.Serializable //--------------------------/ /** - * reference to one or more trees containing the node being - * described. - * + * reference to one or more trees containing + * the node being described. */ private java.util.Vector _treeId; /** - * String uniquely identifying a particular node in the - * referenced tree according to the format of the tree - * representation that is referenced. + * String uniquely identifying a particular + * node in the referenced tree according to the format of + * the tree representation that is referenced. * */ private java.lang.String _nodespec; @@ -115,19 +113,51 @@ implements java.io.Serializable if (obj instanceof Treenode) { Treenode temp = (Treenode)obj; + boolean thcycle; + boolean tmcycle; if (this._treeId != null) { if (temp._treeId == null) return false; - else if (!(this._treeId.equals(temp._treeId))) - return false; - } - else if (temp._treeId != null) + if (this._treeId != temp._treeId) { + thcycle=org.castor.util.CycleBreaker.startingToCycle(this._treeId); + tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._treeId); + if (thcycle!=tmcycle) { + if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); }; + if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); }; + return false; + } + if (!thcycle) { + if (!this._treeId.equals(temp._treeId)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._treeId); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeId); + } + } + } else if (temp._treeId != null) return false; if (this._nodespec != null) { if (temp._nodespec == null) return false; - else if (!(this._nodespec.equals(temp._nodespec))) - return false; - } - else if (temp._nodespec != null) + if (this._nodespec != temp._nodespec) { + thcycle=org.castor.util.CycleBreaker.startingToCycle(this._nodespec); + tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._nodespec); + if (thcycle!=tmcycle) { + if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); }; + if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); }; + return false; + } + if (!thcycle) { + if (!this._nodespec.equals(temp._nodespec)) { + org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); + return false; + } + org.castor.util.CycleBreaker.releaseCycleHandle(this._nodespec); + org.castor.util.CycleBreaker.releaseCycleHandle(temp._nodespec); + } + } + } else if (temp._nodespec != null) return false; return true; } @@ -137,8 +167,9 @@ implements java.io.Serializable /** * Returns the value of field 'nodespec'. The field 'nodespec' * has the following description: String uniquely identifying a - * particular node in the referenced tree according to the - * format of the tree representation that is referenced. + * particular + * node in the referenced tree according to the format of + * the tree representation that is referenced. * * * @return the value of field 'Nodespec'. @@ -217,11 +248,15 @@ implements java.io.Serializable int result = super.hashCode(); long tmp; - if (_treeId != null) { + if (_treeId != null + && !org.castor.util.CycleBreaker.startingToCycle(_treeId)) { result = 37 * result + _treeId.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_treeId); } - if (_nodespec != null) { + if (_nodespec != null + && !org.castor.util.CycleBreaker.startingToCycle(_nodespec)) { result = 37 * result + _nodespec.hashCode(); + org.castor.util.CycleBreaker.releaseCycleHandle(_nodespec); } return result; @@ -308,8 +343,9 @@ implements java.io.Serializable /** * Sets the value of field 'nodespec'. The field 'nodespec' has * the following description: String uniquely identifying a - * particular node in the referenced tree according to the - * format of the tree representation that is referenced. + * particular + * node in the referenced tree according to the format of + * the tree representation that is referenced. * * * @param nodespec the value of field 'nodespec'.