X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fobjects%2Fcore%2FTree.java;h=5c0e72a0bd7604a95650ebdddcc22e84f7d748a4;hb=eae55a9d436c058b8f03036faa0a4baa930c2cd5;hp=5019ad2474495952ef285def0e79c835925f0e39;hpb=ae13f473eb7580171784b6a3c8eb6e3afc5ef152;p=vamsas.git diff --git a/src/uk/ac/vamsas/objects/core/Tree.java b/src/uk/ac/vamsas/objects/core/Tree.java index 5019ad2..5c0e72a 100644 --- a/src/uk/ac/vamsas/objects/core/Tree.java +++ b/src/uk/ac/vamsas/objects/core/Tree.java @@ -49,6 +49,13 @@ implements java.io.Serializable private java.util.Vector _newickList; /** + * node identity and mapping data between tree representations + * and vamsas document objects + * + */ + private java.util.Vector _treenodeList; + + /** * Field _propertyList. */ private java.util.Vector _propertyList; @@ -66,6 +73,7 @@ implements java.io.Serializable public Tree() { super(); this._newickList = new java.util.Vector(); + this._treenodeList = new java.util.Vector(); this._propertyList = new java.util.Vector(); } @@ -131,6 +139,34 @@ implements java.io.Serializable } /** + * + * + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addTreenode( + final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + this._treenodeList.addElement(vTreenode); + } + + /** + * + * + * @param index + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void addTreenode( + final int index, + final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + this._treenodeList.add(index, vTreenode); + } + + /** * Method enumerateNewick. * * @return an Enumeration over all @@ -153,6 +189,17 @@ implements java.io.Serializable } /** + * Method enumerateTreenode. + * + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.Treenode elements + */ + public java.util.Enumeration enumerateTreenode( + ) { + return this._treenodeList.elements(); + } + + /** * Overrides the java.lang.Object.equals method. * * @param obj @@ -197,6 +244,13 @@ implements java.io.Serializable } else if (temp._newickList != null) return false; + if (this._treenodeList != null) { + if (temp._treenodeList == null) return false; + else if (!(this._treenodeList.equals(temp._treenodeList))) + return false; + } + else if (temp._treenodeList != null) + return false; if (this._propertyList != null) { if (temp._propertyList == null) return false; else if (!(this._propertyList.equals(temp._propertyList))) @@ -373,6 +427,63 @@ implements java.io.Serializable } /** + * Method getTreenode. + * + * @param index + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + * @return the value of the uk.ac.vamsas.objects.core.Treenode + * at the given index + */ + public uk.ac.vamsas.objects.core.Treenode getTreenode( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treenodeList.size()) { + throw new IndexOutOfBoundsException("getTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); + } + + return (uk.ac.vamsas.objects.core.Treenode) _treenodeList.get(index); + } + + /** + * Method getTreenode.Returns the contents of the collection in + * an Array.

Note: Just in case the collection contents + * are changing in another thread, we pass a 0-length Array of + * the correct type into the API call. This way we know + * that the Array returned is of exactly the correct length. + * + * @return this collection as an Array + */ + public uk.ac.vamsas.objects.core.Treenode[] getTreenode( + ) { + uk.ac.vamsas.objects.core.Treenode[] array = new uk.ac.vamsas.objects.core.Treenode[0]; + return (uk.ac.vamsas.objects.core.Treenode[]) this._treenodeList.toArray(array); + } + + /** + * Method getTreenodeAsReference.Returns a reference to + * '_treenodeList'. No type checking is performed on any + * modifications to the Vector. + * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getTreenodeAsReference( + ) { + return this._treenodeList; + } + + /** + * Method getTreenodeCount. + * + * @return the size of this collection + */ + public int getTreenodeCount( + ) { + return this._treenodeList.size(); + } + + /** * Overrides the java.lang.Object.hashCode method. *

* The following steps came from Effective Java Programming @@ -397,6 +508,9 @@ implements java.io.Serializable if (_newickList != null) { result = 37 * result + _newickList.hashCode(); } + if (_treenodeList != null) { + result = 37 * result + _treenodeList.hashCode(); + } if (_propertyList != null) { result = 37 * result + _propertyList.hashCode(); } @@ -469,6 +583,13 @@ implements java.io.Serializable } /** + */ + public void removeAllTreenode( + ) { + this._treenodeList.clear(); + } + + /** * Method removeNewick. * * @param vNewick @@ -517,6 +638,30 @@ implements java.io.Serializable } /** + * Method removeTreenode. + * + * @param vTreenode + * @return true if the object was removed from the collection. + */ + public boolean removeTreenode( + final uk.ac.vamsas.objects.core.Treenode vTreenode) { + boolean removed = _treenodeList.remove(vTreenode); + return removed; + } + + /** + * Method removeTreenodeAt. + * + * @param index + * @return the element removed from the collection + */ + public uk.ac.vamsas.objects.core.Treenode removeTreenodeAt( + final int index) { + java.lang.Object obj = this._treenodeList.remove(index); + return (uk.ac.vamsas.objects.core.Treenode) obj; + } + + /** * Sets the value of field 'id'. The field 'id' has the * following description: Primary Key for vamsas object * referencing @@ -681,6 +826,67 @@ implements java.io.Serializable } /** + * + * + * @param index + * @param vTreenode + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setTreenode( + final int index, + final uk.ac.vamsas.objects.core.Treenode vTreenode) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._treenodeList.size()) { + throw new IndexOutOfBoundsException("setTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]"); + } + + this._treenodeList.set(index, vTreenode); + } + + /** + * + * + * @param vTreenodeArray + */ + public void setTreenode( + final uk.ac.vamsas.objects.core.Treenode[] vTreenodeArray) { + //-- copy array + _treenodeList.clear(); + + for (int i = 0; i < vTreenodeArray.length; i++) { + this._treenodeList.add(vTreenodeArray[i]); + } + } + + /** + * Sets the value of '_treenodeList' by copying the given + * Vector. All elements will be checked for type safety. + * + * @param vTreenodeList the Vector to copy. + */ + public void setTreenode( + final java.util.Vector vTreenodeList) { + // copy vector + this._treenodeList.clear(); + + this._treenodeList.addAll(vTreenodeList); + } + + /** + * Sets the value of '_treenodeList' by setting it to the given + * Vector. No type checking is performed. + * @deprecated + * + * @param treenodeVector the Vector to set. + */ + public void setTreenodeAsReference( + final java.util.Vector treenodeVector) { + this._treenodeList = treenodeVector; + } + + /** * Method unmarshal. * * @param reader