2 * This class was automatically generated with
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
8 package uk.ac.vamsas.objects.core;
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
20 * @version $Revision$ $Date$
22 public class Tree extends uk.ac.vamsas.client.Vobject
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * Primary Key for vamsas object referencing
34 private java.lang.String _id;
39 private java.lang.String _modifiable;
44 private java.lang.String _title;
49 private java.util.Vector _newickList;
52 * node identity and mapping data between tree representations
53 * and vamsas document objects
56 private java.util.Vector _treenodeList;
59 * Field _propertyList.
61 private java.util.Vector _propertyList;
66 private uk.ac.vamsas.objects.core.Provenance _provenance;
75 this._newickList = new java.util.Vector();
76 this._treenodeList = new java.util.Vector();
77 this._propertyList = new java.util.Vector();
89 * @throws java.lang.IndexOutOfBoundsException if the index
90 * given is outside the bounds of the collection
92 public void addNewick(
93 final uk.ac.vamsas.objects.core.Newick vNewick)
94 throws java.lang.IndexOutOfBoundsException {
95 this._newickList.addElement(vNewick);
103 * @throws java.lang.IndexOutOfBoundsException if the index
104 * given is outside the bounds of the collection
106 public void addNewick(
108 final uk.ac.vamsas.objects.core.Newick vNewick)
109 throws java.lang.IndexOutOfBoundsException {
110 this._newickList.add(index, vNewick);
117 * @throws java.lang.IndexOutOfBoundsException if the index
118 * given is outside the bounds of the collection
120 public void addProperty(
121 final uk.ac.vamsas.objects.core.Property vProperty)
122 throws java.lang.IndexOutOfBoundsException {
123 this._propertyList.addElement(vProperty);
131 * @throws java.lang.IndexOutOfBoundsException if the index
132 * given is outside the bounds of the collection
134 public void addProperty(
136 final uk.ac.vamsas.objects.core.Property vProperty)
137 throws java.lang.IndexOutOfBoundsException {
138 this._propertyList.add(index, vProperty);
145 * @throws java.lang.IndexOutOfBoundsException if the index
146 * given is outside the bounds of the collection
148 public void addTreenode(
149 final uk.ac.vamsas.objects.core.Treenode vTreenode)
150 throws java.lang.IndexOutOfBoundsException {
151 this._treenodeList.addElement(vTreenode);
159 * @throws java.lang.IndexOutOfBoundsException if the index
160 * given is outside the bounds of the collection
162 public void addTreenode(
164 final uk.ac.vamsas.objects.core.Treenode vTreenode)
165 throws java.lang.IndexOutOfBoundsException {
166 this._treenodeList.add(index, vTreenode);
170 * Method enumerateNewick.
172 * @return an Enumeration over all
173 * uk.ac.vamsas.objects.core.Newick elements
175 public java.util.Enumeration enumerateNewick(
177 return this._newickList.elements();
181 * Method enumerateProperty.
183 * @return an Enumeration over all
184 * uk.ac.vamsas.objects.core.Property elements
186 public java.util.Enumeration enumerateProperty(
188 return this._propertyList.elements();
192 * Method enumerateTreenode.
194 * @return an Enumeration over all
195 * uk.ac.vamsas.objects.core.Treenode elements
197 public java.util.Enumeration enumerateTreenode(
199 return this._treenodeList.elements();
203 * Overrides the java.lang.Object.equals method.
206 * @return true if the objects are equal.
208 public boolean equals(
209 final java.lang.Object obj) {
213 if (super.equals(obj)==false)
216 if (obj instanceof Tree) {
218 Tree temp = (Tree)obj;
219 if (this._id != null) {
220 if (temp._id == null) return false;
221 else if (!(this._id.equals(temp._id)))
224 else if (temp._id != null)
226 if (this._modifiable != null) {
227 if (temp._modifiable == null) return false;
228 else if (!(this._modifiable.equals(temp._modifiable)))
231 else if (temp._modifiable != null)
233 if (this._title != null) {
234 if (temp._title == null) return false;
235 else if (!(this._title.equals(temp._title)))
238 else if (temp._title != null)
240 if (this._newickList != null) {
241 if (temp._newickList == null) return false;
242 else if (!(this._newickList.equals(temp._newickList)))
245 else if (temp._newickList != null)
247 if (this._treenodeList != null) {
248 if (temp._treenodeList == null) return false;
249 else if (!(this._treenodeList.equals(temp._treenodeList)))
252 else if (temp._treenodeList != null)
254 if (this._propertyList != null) {
255 if (temp._propertyList == null) return false;
256 else if (!(this._propertyList.equals(temp._propertyList)))
259 else if (temp._propertyList != null)
261 if (this._provenance != null) {
262 if (temp._provenance == null) return false;
263 else if (!(this._provenance.equals(temp._provenance)))
266 else if (temp._provenance != null)
274 * Returns the value of field 'id'. The field 'id' has the
275 * following description: Primary Key for vamsas object
278 * @return the value of field 'Id'.
280 public java.lang.String getId(
286 * Returns the value of field 'modifiable'.
288 * @return the value of field 'Modifiable'.
290 public java.lang.String getModifiable(
292 return this._modifiable;
299 * @throws java.lang.IndexOutOfBoundsException if the index
300 * given is outside the bounds of the collection
301 * @return the value of the uk.ac.vamsas.objects.core.Newick at
304 public uk.ac.vamsas.objects.core.Newick getNewick(
306 throws java.lang.IndexOutOfBoundsException {
307 // check bounds for index
308 if (index < 0 || index >= this._newickList.size()) {
309 throw new IndexOutOfBoundsException("getNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]");
312 return (uk.ac.vamsas.objects.core.Newick) _newickList.get(index);
316 * Method getNewick.Returns the contents of the collection in
317 * an Array. <p>Note: Just in case the collection contents
318 * are changing in another thread, we pass a 0-length Array of
319 * the correct type into the API call. This way we <i>know</i>
320 * that the Array returned is of exactly the correct length.
322 * @return this collection as an Array
324 public uk.ac.vamsas.objects.core.Newick[] getNewick(
326 uk.ac.vamsas.objects.core.Newick[] array = new uk.ac.vamsas.objects.core.Newick[0];
327 return (uk.ac.vamsas.objects.core.Newick[]) this._newickList.toArray(array);
331 * Method getNewickAsReference.Returns a reference to
332 * '_newickList'. No type checking is performed on any
333 * modifications to the Vector.
335 * @return a reference to the Vector backing this class
337 public java.util.Vector getNewickAsReference(
339 return this._newickList;
343 * Method getNewickCount.
345 * @return the size of this collection
347 public int getNewickCount(
349 return this._newickList.size();
353 * Method getProperty.
356 * @throws java.lang.IndexOutOfBoundsException if the index
357 * given is outside the bounds of the collection
358 * @return the value of the uk.ac.vamsas.objects.core.Property
361 public uk.ac.vamsas.objects.core.Property getProperty(
363 throws java.lang.IndexOutOfBoundsException {
364 // check bounds for index
365 if (index < 0 || index >= this._propertyList.size()) {
366 throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
369 return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
373 * Method getProperty.Returns the contents of the collection in
374 * an Array. <p>Note: Just in case the collection contents
375 * are changing in another thread, we pass a 0-length Array of
376 * the correct type into the API call. This way we <i>know</i>
377 * that the Array returned is of exactly the correct length.
379 * @return this collection as an Array
381 public uk.ac.vamsas.objects.core.Property[] getProperty(
383 uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
384 return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array);
388 * Method getPropertyAsReference.Returns a reference to
389 * '_propertyList'. No type checking is performed on any
390 * modifications to the Vector.
392 * @return a reference to the Vector backing this class
394 public java.util.Vector getPropertyAsReference(
396 return this._propertyList;
400 * Method getPropertyCount.
402 * @return the size of this collection
404 public int getPropertyCount(
406 return this._propertyList.size();
410 * Returns the value of field 'provenance'.
412 * @return the value of field 'Provenance'.
414 public uk.ac.vamsas.objects.core.Provenance getProvenance(
416 return this._provenance;
420 * Returns the value of field 'title'.
422 * @return the value of field 'Title'.
424 public java.lang.String getTitle(
430 * Method getTreenode.
433 * @throws java.lang.IndexOutOfBoundsException if the index
434 * given is outside the bounds of the collection
435 * @return the value of the uk.ac.vamsas.objects.core.Treenode
438 public uk.ac.vamsas.objects.core.Treenode getTreenode(
440 throws java.lang.IndexOutOfBoundsException {
441 // check bounds for index
442 if (index < 0 || index >= this._treenodeList.size()) {
443 throw new IndexOutOfBoundsException("getTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]");
446 return (uk.ac.vamsas.objects.core.Treenode) _treenodeList.get(index);
450 * Method getTreenode.Returns the contents of the collection in
451 * an Array. <p>Note: Just in case the collection contents
452 * are changing in another thread, we pass a 0-length Array of
453 * the correct type into the API call. This way we <i>know</i>
454 * that the Array returned is of exactly the correct length.
456 * @return this collection as an Array
458 public uk.ac.vamsas.objects.core.Treenode[] getTreenode(
460 uk.ac.vamsas.objects.core.Treenode[] array = new uk.ac.vamsas.objects.core.Treenode[0];
461 return (uk.ac.vamsas.objects.core.Treenode[]) this._treenodeList.toArray(array);
465 * Method getTreenodeAsReference.Returns a reference to
466 * '_treenodeList'. No type checking is performed on any
467 * modifications to the Vector.
469 * @return a reference to the Vector backing this class
471 public java.util.Vector getTreenodeAsReference(
473 return this._treenodeList;
477 * Method getTreenodeCount.
479 * @return the size of this collection
481 public int getTreenodeCount(
483 return this._treenodeList.size();
487 * Overrides the java.lang.Object.hashCode method.
489 * The following steps came from <b>Effective Java Programming
490 * Language Guide</b> by Joshua Bloch, Chapter 3
492 * @return a hash code value for the object.
496 int result = super.hashCode();
500 result = 37 * result + _id.hashCode();
502 if (_modifiable != null) {
503 result = 37 * result + _modifiable.hashCode();
505 if (_title != null) {
506 result = 37 * result + _title.hashCode();
508 if (_newickList != null) {
509 result = 37 * result + _newickList.hashCode();
511 if (_treenodeList != null) {
512 result = 37 * result + _treenodeList.hashCode();
514 if (_propertyList != null) {
515 result = 37 * result + _propertyList.hashCode();
517 if (_provenance != null) {
518 result = 37 * result + _provenance.hashCode();
527 * @return true if this object is valid according to the schema
529 public boolean isValid(
533 } catch (org.exolab.castor.xml.ValidationException vex) {
543 * @throws org.exolab.castor.xml.MarshalException if object is
544 * null or if any SAXException is thrown during marshaling
545 * @throws org.exolab.castor.xml.ValidationException if this
546 * object is an invalid instance according to the schema
549 final java.io.Writer out)
550 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
551 Marshaller.marshal(this, out);
558 * @throws java.io.IOException if an IOException occurs during
560 * @throws org.exolab.castor.xml.ValidationException if this
561 * object is an invalid instance according to the schema
562 * @throws org.exolab.castor.xml.MarshalException if object is
563 * null or if any SAXException is thrown during marshaling
566 final org.xml.sax.ContentHandler handler)
567 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
568 Marshaller.marshal(this, handler);
573 public void removeAllNewick(
575 this._newickList.clear();
580 public void removeAllProperty(
582 this._propertyList.clear();
587 public void removeAllTreenode(
589 this._treenodeList.clear();
593 * Method removeNewick.
596 * @return true if the object was removed from the collection.
598 public boolean removeNewick(
599 final uk.ac.vamsas.objects.core.Newick vNewick) {
600 boolean removed = _newickList.remove(vNewick);
605 * Method removeNewickAt.
608 * @return the element removed from the collection
610 public uk.ac.vamsas.objects.core.Newick removeNewickAt(
612 java.lang.Object obj = this._newickList.remove(index);
613 return (uk.ac.vamsas.objects.core.Newick) obj;
617 * Method removeProperty.
620 * @return true if the object was removed from the collection.
622 public boolean removeProperty(
623 final uk.ac.vamsas.objects.core.Property vProperty) {
624 boolean removed = _propertyList.remove(vProperty);
629 * Method removePropertyAt.
632 * @return the element removed from the collection
634 public uk.ac.vamsas.objects.core.Property removePropertyAt(
636 java.lang.Object obj = this._propertyList.remove(index);
637 return (uk.ac.vamsas.objects.core.Property) obj;
641 * Method removeTreenode.
644 * @return true if the object was removed from the collection.
646 public boolean removeTreenode(
647 final uk.ac.vamsas.objects.core.Treenode vTreenode) {
648 boolean removed = _treenodeList.remove(vTreenode);
653 * Method removeTreenodeAt.
656 * @return the element removed from the collection
658 public uk.ac.vamsas.objects.core.Treenode removeTreenodeAt(
660 java.lang.Object obj = this._treenodeList.remove(index);
661 return (uk.ac.vamsas.objects.core.Treenode) obj;
665 * Sets the value of field 'id'. The field 'id' has the
666 * following description: Primary Key for vamsas object
669 * @param id the value of field 'id'.
672 final java.lang.String id) {
677 * Sets the value of field 'modifiable'.
679 * @param modifiable the value of field 'modifiable'.
681 public void setModifiable(
682 final java.lang.String modifiable) {
683 this._modifiable = modifiable;
691 * @throws java.lang.IndexOutOfBoundsException if the index
692 * given is outside the bounds of the collection
694 public void setNewick(
696 final uk.ac.vamsas.objects.core.Newick vNewick)
697 throws java.lang.IndexOutOfBoundsException {
698 // check bounds for index
699 if (index < 0 || index >= this._newickList.size()) {
700 throw new IndexOutOfBoundsException("setNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]");
703 this._newickList.set(index, vNewick);
709 * @param vNewickArray
711 public void setNewick(
712 final uk.ac.vamsas.objects.core.Newick[] vNewickArray) {
716 for (int i = 0; i < vNewickArray.length; i++) {
717 this._newickList.add(vNewickArray[i]);
722 * Sets the value of '_newickList' by copying the given Vector.
723 * All elements will be checked for type safety.
725 * @param vNewickList the Vector to copy.
727 public void setNewick(
728 final java.util.Vector vNewickList) {
730 this._newickList.clear();
732 this._newickList.addAll(vNewickList);
736 * Sets the value of '_newickList' by setting it to the given
737 * Vector. No type checking is performed.
740 * @param newickVector the Vector to set.
742 public void setNewickAsReference(
743 final java.util.Vector newickVector) {
744 this._newickList = newickVector;
752 * @throws java.lang.IndexOutOfBoundsException if the index
753 * given is outside the bounds of the collection
755 public void setProperty(
757 final uk.ac.vamsas.objects.core.Property vProperty)
758 throws java.lang.IndexOutOfBoundsException {
759 // check bounds for index
760 if (index < 0 || index >= this._propertyList.size()) {
761 throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
764 this._propertyList.set(index, vProperty);
770 * @param vPropertyArray
772 public void setProperty(
773 final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
775 _propertyList.clear();
777 for (int i = 0; i < vPropertyArray.length; i++) {
778 this._propertyList.add(vPropertyArray[i]);
783 * Sets the value of '_propertyList' by copying the given
784 * Vector. All elements will be checked for type safety.
786 * @param vPropertyList the Vector to copy.
788 public void setProperty(
789 final java.util.Vector vPropertyList) {
791 this._propertyList.clear();
793 this._propertyList.addAll(vPropertyList);
797 * Sets the value of '_propertyList' by setting it to the given
798 * Vector. No type checking is performed.
801 * @param propertyVector the Vector to set.
803 public void setPropertyAsReference(
804 final java.util.Vector propertyVector) {
805 this._propertyList = propertyVector;
809 * Sets the value of field 'provenance'.
811 * @param provenance the value of field 'provenance'.
813 public void setProvenance(
814 final uk.ac.vamsas.objects.core.Provenance provenance) {
815 this._provenance = provenance;
819 * Sets the value of field 'title'.
821 * @param title the value of field 'title'.
823 public void setTitle(
824 final java.lang.String title) {
833 * @throws java.lang.IndexOutOfBoundsException if the index
834 * given is outside the bounds of the collection
836 public void setTreenode(
838 final uk.ac.vamsas.objects.core.Treenode vTreenode)
839 throws java.lang.IndexOutOfBoundsException {
840 // check bounds for index
841 if (index < 0 || index >= this._treenodeList.size()) {
842 throw new IndexOutOfBoundsException("setTreenode: Index value '" + index + "' not in range [0.." + (this._treenodeList.size() - 1) + "]");
845 this._treenodeList.set(index, vTreenode);
851 * @param vTreenodeArray
853 public void setTreenode(
854 final uk.ac.vamsas.objects.core.Treenode[] vTreenodeArray) {
856 _treenodeList.clear();
858 for (int i = 0; i < vTreenodeArray.length; i++) {
859 this._treenodeList.add(vTreenodeArray[i]);
864 * Sets the value of '_treenodeList' by copying the given
865 * Vector. All elements will be checked for type safety.
867 * @param vTreenodeList the Vector to copy.
869 public void setTreenode(
870 final java.util.Vector vTreenodeList) {
872 this._treenodeList.clear();
874 this._treenodeList.addAll(vTreenodeList);
878 * Sets the value of '_treenodeList' by setting it to the given
879 * Vector. No type checking is performed.
882 * @param treenodeVector the Vector to set.
884 public void setTreenodeAsReference(
885 final java.util.Vector treenodeVector) {
886 this._treenodeList = treenodeVector;
893 * @throws org.exolab.castor.xml.MarshalException if object is
894 * null or if any SAXException is thrown during marshaling
895 * @throws org.exolab.castor.xml.ValidationException if this
896 * object is an invalid instance according to the schema
897 * @return the unmarshaled uk.ac.vamsas.objects.core.Tree
899 public static uk.ac.vamsas.objects.core.Tree unmarshal(
900 final java.io.Reader reader)
901 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
902 return (uk.ac.vamsas.objects.core.Tree) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Tree.class, reader);
908 * @throws org.exolab.castor.xml.ValidationException if this
909 * object is an invalid instance according to the schema
911 public void validate(
913 throws org.exolab.castor.xml.ValidationException {
914 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
915 validator.validate(this);