applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / Tree.java
1 /*
2  * This file is part of the Vamsas Client version 0.1. 
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
4  *  Andrew Waterhouse and Dominik Lindner.
5  * 
6  * Earlier versions have also been incorporated into Jalview version 2.4 
7  * since 2008, and TOPALi version 2 since 2007.
8  * 
9  * The Vamsas Client is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *  
14  * The Vamsas Client is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 package uk.ac.vamsas.objects.core;
23
24 //---------------------------------/
25 //- Imported classes and packages -/
26 //---------------------------------/
27
28 import org.exolab.castor.xml.Marshaller;
29 import org.exolab.castor.xml.Unmarshaller;
30
31 /**
32  * Class Tree.
33  * 
34  * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007)
35  *          $
36  */
37 public class Tree extends uk.ac.vamsas.client.Vobject implements
38     java.io.Serializable {
39
40   // --------------------------/
41   // - Class/Member Variables -/
42   // --------------------------/
43
44   /**
45    * Primary Key for vamsas object referencing
46    */
47   private java.lang.String _id;
48
49   /**
50    * Field _modifiable.
51    */
52   private java.lang.String _modifiable;
53
54   /**
55    * Field _title.
56    */
57   private java.lang.String _title;
58
59   /**
60    * Field _newickList.
61    */
62   private java.util.Vector _newickList;
63
64   /**
65    * node identity and mapping data between tree representations and vamsas
66    * document objects
67    */
68   private java.util.Vector _treenodeList;
69
70   /**
71    * Field _propertyList.
72    */
73   private java.util.Vector _propertyList;
74
75   /**
76    * Field _provenance.
77    */
78   private uk.ac.vamsas.objects.core.Provenance _provenance;
79
80   // ----------------/
81   // - Constructors -/
82   // ----------------/
83
84   public Tree() {
85     super();
86     this._newickList = new java.util.Vector();
87     this._treenodeList = new java.util.Vector();
88     this._propertyList = new java.util.Vector();
89   }
90
91   // -----------/
92   // - Methods -/
93   // -----------/
94
95   /**
96    * 
97    * 
98    * @param vNewick
99    * @throws java.lang.IndexOutOfBoundsException
100    *           if the index given is outside the bounds of the collection
101    */
102   public void addNewick(final uk.ac.vamsas.objects.core.Newick vNewick)
103       throws java.lang.IndexOutOfBoundsException {
104     this._newickList.addElement(vNewick);
105   }
106
107   /**
108    * 
109    * 
110    * @param index
111    * @param vNewick
112    * @throws java.lang.IndexOutOfBoundsException
113    *           if the index given is outside the bounds of the collection
114    */
115   public void addNewick(final int index,
116       final uk.ac.vamsas.objects.core.Newick vNewick)
117       throws java.lang.IndexOutOfBoundsException {
118     this._newickList.add(index, vNewick);
119   }
120
121   /**
122    * 
123    * 
124    * @param vProperty
125    * @throws java.lang.IndexOutOfBoundsException
126    *           if the index given is outside the bounds of the collection
127    */
128   public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty)
129       throws java.lang.IndexOutOfBoundsException {
130     this._propertyList.addElement(vProperty);
131   }
132
133   /**
134    * 
135    * 
136    * @param index
137    * @param vProperty
138    * @throws java.lang.IndexOutOfBoundsException
139    *           if the index given is outside the bounds of the collection
140    */
141   public void addProperty(final int index,
142       final uk.ac.vamsas.objects.core.Property vProperty)
143       throws java.lang.IndexOutOfBoundsException {
144     this._propertyList.add(index, vProperty);
145   }
146
147   /**
148    * 
149    * 
150    * @param vTreenode
151    * @throws java.lang.IndexOutOfBoundsException
152    *           if the index given is outside the bounds of the collection
153    */
154   public void addTreenode(final uk.ac.vamsas.objects.core.Treenode vTreenode)
155       throws java.lang.IndexOutOfBoundsException {
156     this._treenodeList.addElement(vTreenode);
157   }
158
159   /**
160    * 
161    * 
162    * @param index
163    * @param vTreenode
164    * @throws java.lang.IndexOutOfBoundsException
165    *           if the index given is outside the bounds of the collection
166    */
167   public void addTreenode(final int index,
168       final uk.ac.vamsas.objects.core.Treenode vTreenode)
169       throws java.lang.IndexOutOfBoundsException {
170     this._treenodeList.add(index, vTreenode);
171   }
172
173   /**
174    * Method enumerateNewick.
175    * 
176    * @return an Enumeration over all uk.ac.vamsas.objects.core.Newick elements
177    */
178   public java.util.Enumeration enumerateNewick() {
179     return this._newickList.elements();
180   }
181
182   /**
183    * Method enumerateProperty.
184    * 
185    * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements
186    */
187   public java.util.Enumeration enumerateProperty() {
188     return this._propertyList.elements();
189   }
190
191   /**
192    * Method enumerateTreenode.
193    * 
194    * @return an Enumeration over all uk.ac.vamsas.objects.core.Treenode elements
195    */
196   public java.util.Enumeration enumerateTreenode() {
197     return this._treenodeList.elements();
198   }
199
200   /**
201    * Overrides the java.lang.Object.equals method.
202    * 
203    * @param obj
204    * @return true if the objects are equal.
205    */
206   public boolean equals(final java.lang.Object obj) {
207     if (this == obj)
208       return true;
209
210     if (super.equals(obj) == false)
211       return false;
212
213     if (obj instanceof Tree) {
214
215       Tree temp = (Tree) obj;
216       boolean thcycle;
217       boolean tmcycle;
218       if (this._id != null) {
219         if (temp._id == null)
220           return false;
221         if (this._id != temp._id) {
222           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
223           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
224           if (thcycle != tmcycle) {
225             if (!thcycle) {
226               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
227             }
228             ;
229             if (!tmcycle) {
230               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
231             }
232             ;
233             return false;
234           }
235           if (!thcycle) {
236             if (!this._id.equals(temp._id)) {
237               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
238               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
239               return false;
240             }
241             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
242             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
243           }
244         }
245       } else if (temp._id != null)
246         return false;
247       if (this._modifiable != null) {
248         if (temp._modifiable == null)
249           return false;
250         if (this._modifiable != temp._modifiable) {
251           thcycle = org.castor.util.CycleBreaker
252               .startingToCycle(this._modifiable);
253           tmcycle = org.castor.util.CycleBreaker
254               .startingToCycle(temp._modifiable);
255           if (thcycle != tmcycle) {
256             if (!thcycle) {
257               org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
258             }
259             ;
260             if (!tmcycle) {
261               org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
262             }
263             ;
264             return false;
265           }
266           if (!thcycle) {
267             if (!this._modifiable.equals(temp._modifiable)) {
268               org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
269               org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
270               return false;
271             }
272             org.castor.util.CycleBreaker.releaseCycleHandle(this._modifiable);
273             org.castor.util.CycleBreaker.releaseCycleHandle(temp._modifiable);
274           }
275         }
276       } else if (temp._modifiable != null)
277         return false;
278       if (this._title != null) {
279         if (temp._title == null)
280           return false;
281         if (this._title != temp._title) {
282           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._title);
283           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._title);
284           if (thcycle != tmcycle) {
285             if (!thcycle) {
286               org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
287             }
288             ;
289             if (!tmcycle) {
290               org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
291             }
292             ;
293             return false;
294           }
295           if (!thcycle) {
296             if (!this._title.equals(temp._title)) {
297               org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
298               org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
299               return false;
300             }
301             org.castor.util.CycleBreaker.releaseCycleHandle(this._title);
302             org.castor.util.CycleBreaker.releaseCycleHandle(temp._title);
303           }
304         }
305       } else if (temp._title != null)
306         return false;
307       if (this._newickList != null) {
308         if (temp._newickList == null)
309           return false;
310         if (this._newickList != temp._newickList) {
311           thcycle = org.castor.util.CycleBreaker
312               .startingToCycle(this._newickList);
313           tmcycle = org.castor.util.CycleBreaker
314               .startingToCycle(temp._newickList);
315           if (thcycle != tmcycle) {
316             if (!thcycle) {
317               org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList);
318             }
319             ;
320             if (!tmcycle) {
321               org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList);
322             }
323             ;
324             return false;
325           }
326           if (!thcycle) {
327             if (!this._newickList.equals(temp._newickList)) {
328               org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList);
329               org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList);
330               return false;
331             }
332             org.castor.util.CycleBreaker.releaseCycleHandle(this._newickList);
333             org.castor.util.CycleBreaker.releaseCycleHandle(temp._newickList);
334           }
335         }
336       } else if (temp._newickList != null)
337         return false;
338       if (this._treenodeList != null) {
339         if (temp._treenodeList == null)
340           return false;
341         if (this._treenodeList != temp._treenodeList) {
342           thcycle = org.castor.util.CycleBreaker
343               .startingToCycle(this._treenodeList);
344           tmcycle = org.castor.util.CycleBreaker
345               .startingToCycle(temp._treenodeList);
346           if (thcycle != tmcycle) {
347             if (!thcycle) {
348               org.castor.util.CycleBreaker
349                   .releaseCycleHandle(this._treenodeList);
350             }
351             ;
352             if (!tmcycle) {
353               org.castor.util.CycleBreaker
354                   .releaseCycleHandle(temp._treenodeList);
355             }
356             ;
357             return false;
358           }
359           if (!thcycle) {
360             if (!this._treenodeList.equals(temp._treenodeList)) {
361               org.castor.util.CycleBreaker
362                   .releaseCycleHandle(this._treenodeList);
363               org.castor.util.CycleBreaker
364                   .releaseCycleHandle(temp._treenodeList);
365               return false;
366             }
367             org.castor.util.CycleBreaker.releaseCycleHandle(this._treenodeList);
368             org.castor.util.CycleBreaker.releaseCycleHandle(temp._treenodeList);
369           }
370         }
371       } else if (temp._treenodeList != null)
372         return false;
373       if (this._propertyList != null) {
374         if (temp._propertyList == null)
375           return false;
376         if (this._propertyList != temp._propertyList) {
377           thcycle = org.castor.util.CycleBreaker
378               .startingToCycle(this._propertyList);
379           tmcycle = org.castor.util.CycleBreaker
380               .startingToCycle(temp._propertyList);
381           if (thcycle != tmcycle) {
382             if (!thcycle) {
383               org.castor.util.CycleBreaker
384                   .releaseCycleHandle(this._propertyList);
385             }
386             ;
387             if (!tmcycle) {
388               org.castor.util.CycleBreaker
389                   .releaseCycleHandle(temp._propertyList);
390             }
391             ;
392             return false;
393           }
394           if (!thcycle) {
395             if (!this._propertyList.equals(temp._propertyList)) {
396               org.castor.util.CycleBreaker
397                   .releaseCycleHandle(this._propertyList);
398               org.castor.util.CycleBreaker
399                   .releaseCycleHandle(temp._propertyList);
400               return false;
401             }
402             org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
403             org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
404           }
405         }
406       } else if (temp._propertyList != null)
407         return false;
408       if (this._provenance != null) {
409         if (temp._provenance == null)
410           return false;
411         if (this._provenance != temp._provenance) {
412           thcycle = org.castor.util.CycleBreaker
413               .startingToCycle(this._provenance);
414           tmcycle = org.castor.util.CycleBreaker
415               .startingToCycle(temp._provenance);
416           if (thcycle != tmcycle) {
417             if (!thcycle) {
418               org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
419             }
420             ;
421             if (!tmcycle) {
422               org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
423             }
424             ;
425             return false;
426           }
427           if (!thcycle) {
428             if (!this._provenance.equals(temp._provenance)) {
429               org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
430               org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
431               return false;
432             }
433             org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
434             org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
435           }
436         }
437       } else if (temp._provenance != null)
438         return false;
439       return true;
440     }
441     return false;
442   }
443
444   /**
445    * Returns the value of field 'id'. The field 'id' has the following
446    * description: Primary Key for vamsas object referencing
447    * 
448    * @return the value of field 'Id'.
449    */
450   public java.lang.String getId() {
451     return this._id;
452   }
453
454   /**
455    * Returns the value of field 'modifiable'.
456    * 
457    * @return the value of field 'Modifiable'.
458    */
459   public java.lang.String getModifiable() {
460     return this._modifiable;
461   }
462
463   /**
464    * Method getNewick.
465    * 
466    * @param index
467    * @throws java.lang.IndexOutOfBoundsException
468    *           if the index given is outside the bounds of the collection
469    * @return the value of the uk.ac.vamsas.objects.core.Newick at the given
470    *         index
471    */
472   public uk.ac.vamsas.objects.core.Newick getNewick(final int index)
473       throws java.lang.IndexOutOfBoundsException {
474     // check bounds for index
475     if (index < 0 || index >= this._newickList.size()) {
476       throw new IndexOutOfBoundsException("getNewick: Index value '" + index
477           + "' not in range [0.." + (this._newickList.size() - 1) + "]");
478     }
479
480     return (uk.ac.vamsas.objects.core.Newick) _newickList.get(index);
481   }
482
483   /**
484    * Method getNewick.Returns the contents of the collection in an Array.
485    * <p>
486    * Note: Just in case the collection contents are changing in another thread,
487    * we pass a 0-length Array of the correct type into the API call. This way we
488    * <i>know</i> that the Array returned is of exactly the correct length.
489    * 
490    * @return this collection as an Array
491    */
492   public uk.ac.vamsas.objects.core.Newick[] getNewick() {
493     uk.ac.vamsas.objects.core.Newick[] array = new uk.ac.vamsas.objects.core.Newick[0];
494     return (uk.ac.vamsas.objects.core.Newick[]) this._newickList.toArray(array);
495   }
496
497   /**
498    * Method getNewickAsReference.Returns a reference to '_newickList'. No type
499    * checking is performed on any modifications to the Vector.
500    * 
501    * @return a reference to the Vector backing this class
502    */
503   public java.util.Vector getNewickAsReference() {
504     return this._newickList;
505   }
506
507   /**
508    * Method getNewickCount.
509    * 
510    * @return the size of this collection
511    */
512   public int getNewickCount() {
513     return this._newickList.size();
514   }
515
516   /**
517    * Method getProperty.
518    * 
519    * @param index
520    * @throws java.lang.IndexOutOfBoundsException
521    *           if the index given is outside the bounds of the collection
522    * @return the value of the uk.ac.vamsas.objects.core.Property at the given
523    *         index
524    */
525   public uk.ac.vamsas.objects.core.Property getProperty(final int index)
526       throws java.lang.IndexOutOfBoundsException {
527     // check bounds for index
528     if (index < 0 || index >= this._propertyList.size()) {
529       throw new IndexOutOfBoundsException("getProperty: Index value '" + index
530           + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
531     }
532
533     return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
534   }
535
536   /**
537    * Method getProperty.Returns the contents of the collection in an Array.
538    * <p>
539    * Note: Just in case the collection contents are changing in another thread,
540    * we pass a 0-length Array of the correct type into the API call. This way we
541    * <i>know</i> that the Array returned is of exactly the correct length.
542    * 
543    * @return this collection as an Array
544    */
545   public uk.ac.vamsas.objects.core.Property[] getProperty() {
546     uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
547     return (uk.ac.vamsas.objects.core.Property[]) this._propertyList
548         .toArray(array);
549   }
550
551   /**
552    * Method getPropertyAsReference.Returns a reference to '_propertyList'. No
553    * type checking is performed on any modifications to the Vector.
554    * 
555    * @return a reference to the Vector backing this class
556    */
557   public java.util.Vector getPropertyAsReference() {
558     return this._propertyList;
559   }
560
561   /**
562    * Method getPropertyCount.
563    * 
564    * @return the size of this collection
565    */
566   public int getPropertyCount() {
567     return this._propertyList.size();
568   }
569
570   /**
571    * Returns the value of field 'provenance'.
572    * 
573    * @return the value of field 'Provenance'.
574    */
575   public uk.ac.vamsas.objects.core.Provenance getProvenance() {
576     return this._provenance;
577   }
578
579   /**
580    * Returns the value of field 'title'.
581    * 
582    * @return the value of field 'Title'.
583    */
584   public java.lang.String getTitle() {
585     return this._title;
586   }
587
588   /**
589    * Method getTreenode.
590    * 
591    * @param index
592    * @throws java.lang.IndexOutOfBoundsException
593    *           if the index given is outside the bounds of the collection
594    * @return the value of the uk.ac.vamsas.objects.core.Treenode at the given
595    *         index
596    */
597   public uk.ac.vamsas.objects.core.Treenode getTreenode(final int index)
598       throws java.lang.IndexOutOfBoundsException {
599     // check bounds for index
600     if (index < 0 || index >= this._treenodeList.size()) {
601       throw new IndexOutOfBoundsException("getTreenode: Index value '" + index
602           + "' not in range [0.." + (this._treenodeList.size() - 1) + "]");
603     }
604
605     return (uk.ac.vamsas.objects.core.Treenode) _treenodeList.get(index);
606   }
607
608   /**
609    * Method getTreenode.Returns the contents of the collection in an Array.
610    * <p>
611    * Note: Just in case the collection contents are changing in another thread,
612    * we pass a 0-length Array of the correct type into the API call. This way we
613    * <i>know</i> that the Array returned is of exactly the correct length.
614    * 
615    * @return this collection as an Array
616    */
617   public uk.ac.vamsas.objects.core.Treenode[] getTreenode() {
618     uk.ac.vamsas.objects.core.Treenode[] array = new uk.ac.vamsas.objects.core.Treenode[0];
619     return (uk.ac.vamsas.objects.core.Treenode[]) this._treenodeList
620         .toArray(array);
621   }
622
623   /**
624    * Method getTreenodeAsReference.Returns a reference to '_treenodeList'. No
625    * type checking is performed on any modifications to the Vector.
626    * 
627    * @return a reference to the Vector backing this class
628    */
629   public java.util.Vector getTreenodeAsReference() {
630     return this._treenodeList;
631   }
632
633   /**
634    * Method getTreenodeCount.
635    * 
636    * @return the size of this collection
637    */
638   public int getTreenodeCount() {
639     return this._treenodeList.size();
640   }
641
642   /**
643    * Overrides the java.lang.Object.hashCode method.
644    * <p>
645    * The following steps came from <b>Effective Java Programming Language
646    * Guide</b> by Joshua Bloch, Chapter 3
647    * 
648    * @return a hash code value for the object.
649    */
650   public int hashCode() {
651     int result = super.hashCode();
652
653     long tmp;
654     if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
655       result = 37 * result + _id.hashCode();
656       org.castor.util.CycleBreaker.releaseCycleHandle(_id);
657     }
658     if (_modifiable != null
659         && !org.castor.util.CycleBreaker.startingToCycle(_modifiable)) {
660       result = 37 * result + _modifiable.hashCode();
661       org.castor.util.CycleBreaker.releaseCycleHandle(_modifiable);
662     }
663     if (_title != null && !org.castor.util.CycleBreaker.startingToCycle(_title)) {
664       result = 37 * result + _title.hashCode();
665       org.castor.util.CycleBreaker.releaseCycleHandle(_title);
666     }
667     if (_newickList != null
668         && !org.castor.util.CycleBreaker.startingToCycle(_newickList)) {
669       result = 37 * result + _newickList.hashCode();
670       org.castor.util.CycleBreaker.releaseCycleHandle(_newickList);
671     }
672     if (_treenodeList != null
673         && !org.castor.util.CycleBreaker.startingToCycle(_treenodeList)) {
674       result = 37 * result + _treenodeList.hashCode();
675       org.castor.util.CycleBreaker.releaseCycleHandle(_treenodeList);
676     }
677     if (_propertyList != null
678         && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
679       result = 37 * result + _propertyList.hashCode();
680       org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
681     }
682     if (_provenance != null
683         && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
684       result = 37 * result + _provenance.hashCode();
685       org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
686     }
687
688     return result;
689   }
690
691   /**
692    * Method isValid.
693    * 
694    * @return true if this object is valid according to the schema
695    */
696   public boolean isValid() {
697     try {
698       validate();
699     } catch (org.exolab.castor.xml.ValidationException vex) {
700       return false;
701     }
702     return true;
703   }
704
705   /**
706    * 
707    * 
708    * @param out
709    * @throws org.exolab.castor.xml.MarshalException
710    *           if object is null or if any SAXException is thrown during
711    *           marshaling
712    * @throws org.exolab.castor.xml.ValidationException
713    *           if this object is an invalid instance according to the schema
714    */
715   public void marshal(final java.io.Writer out)
716       throws org.exolab.castor.xml.MarshalException,
717       org.exolab.castor.xml.ValidationException {
718     Marshaller.marshal(this, out);
719   }
720
721   /**
722    * 
723    * 
724    * @param handler
725    * @throws java.io.IOException
726    *           if an IOException occurs during marshaling
727    * @throws org.exolab.castor.xml.ValidationException
728    *           if this object is an invalid instance according to the schema
729    * @throws org.exolab.castor.xml.MarshalException
730    *           if object is null or if any SAXException is thrown during
731    *           marshaling
732    */
733   public void marshal(final org.xml.sax.ContentHandler handler)
734       throws java.io.IOException, org.exolab.castor.xml.MarshalException,
735       org.exolab.castor.xml.ValidationException {
736     Marshaller.marshal(this, handler);
737   }
738
739   /**
740      */
741   public void removeAllNewick() {
742     this._newickList.clear();
743   }
744
745   /**
746      */
747   public void removeAllProperty() {
748     this._propertyList.clear();
749   }
750
751   /**
752      */
753   public void removeAllTreenode() {
754     this._treenodeList.clear();
755   }
756
757   /**
758    * Method removeNewick.
759    * 
760    * @param vNewick
761    * @return true if the object was removed from the collection.
762    */
763   public boolean removeNewick(final uk.ac.vamsas.objects.core.Newick vNewick) {
764     boolean removed = _newickList.remove(vNewick);
765     return removed;
766   }
767
768   /**
769    * Method removeNewickAt.
770    * 
771    * @param index
772    * @return the element removed from the collection
773    */
774   public uk.ac.vamsas.objects.core.Newick removeNewickAt(final int index) {
775     java.lang.Object obj = this._newickList.remove(index);
776     return (uk.ac.vamsas.objects.core.Newick) obj;
777   }
778
779   /**
780    * Method removeProperty.
781    * 
782    * @param vProperty
783    * @return true if the object was removed from the collection.
784    */
785   public boolean removeProperty(
786       final uk.ac.vamsas.objects.core.Property vProperty) {
787     boolean removed = _propertyList.remove(vProperty);
788     return removed;
789   }
790
791   /**
792    * Method removePropertyAt.
793    * 
794    * @param index
795    * @return the element removed from the collection
796    */
797   public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) {
798     java.lang.Object obj = this._propertyList.remove(index);
799     return (uk.ac.vamsas.objects.core.Property) obj;
800   }
801
802   /**
803    * Method removeTreenode.
804    * 
805    * @param vTreenode
806    * @return true if the object was removed from the collection.
807    */
808   public boolean removeTreenode(
809       final uk.ac.vamsas.objects.core.Treenode vTreenode) {
810     boolean removed = _treenodeList.remove(vTreenode);
811     return removed;
812   }
813
814   /**
815    * Method removeTreenodeAt.
816    * 
817    * @param index
818    * @return the element removed from the collection
819    */
820   public uk.ac.vamsas.objects.core.Treenode removeTreenodeAt(final int index) {
821     java.lang.Object obj = this._treenodeList.remove(index);
822     return (uk.ac.vamsas.objects.core.Treenode) obj;
823   }
824
825   /**
826    * Sets the value of field 'id'. The field 'id' has the following description:
827    * Primary Key for vamsas object referencing
828    * 
829    * @param id
830    *          the value of field 'id'.
831    */
832   public void setId(final java.lang.String id) {
833     this._id = id;
834   }
835
836   /**
837    * Sets the value of field 'modifiable'.
838    * 
839    * @param modifiable
840    *          the value of field 'modifiable'.
841    */
842   public void setModifiable(final java.lang.String modifiable) {
843     this._modifiable = modifiable;
844   }
845
846   /**
847    * 
848    * 
849    * @param index
850    * @param vNewick
851    * @throws java.lang.IndexOutOfBoundsException
852    *           if the index given is outside the bounds of the collection
853    */
854   public void setNewick(final int index,
855       final uk.ac.vamsas.objects.core.Newick vNewick)
856       throws java.lang.IndexOutOfBoundsException {
857     // check bounds for index
858     if (index < 0 || index >= this._newickList.size()) {
859       throw new IndexOutOfBoundsException("setNewick: Index value '" + index
860           + "' not in range [0.." + (this._newickList.size() - 1) + "]");
861     }
862
863     this._newickList.set(index, vNewick);
864   }
865
866   /**
867    * 
868    * 
869    * @param vNewickArray
870    */
871   public void setNewick(final uk.ac.vamsas.objects.core.Newick[] vNewickArray) {
872     // -- copy array
873     _newickList.clear();
874
875     for (int i = 0; i < vNewickArray.length; i++) {
876       this._newickList.add(vNewickArray[i]);
877     }
878   }
879
880   /**
881    * Sets the value of '_newickList' by copying the given Vector. All elements
882    * will be checked for type safety.
883    * 
884    * @param vNewickList
885    *          the Vector to copy.
886    */
887   public void setNewick(final java.util.Vector vNewickList) {
888     // copy vector
889     this._newickList.clear();
890
891     this._newickList.addAll(vNewickList);
892   }
893
894   /**
895    * Sets the value of '_newickList' by setting it to the given Vector. No type
896    * checking is performed.
897    * 
898    * @deprecated
899    * 
900    * @param newickVector
901    *          the Vector to set.
902    */
903   public void setNewickAsReference(final java.util.Vector newickVector) {
904     this._newickList = newickVector;
905   }
906
907   /**
908    * 
909    * 
910    * @param index
911    * @param vProperty
912    * @throws java.lang.IndexOutOfBoundsException
913    *           if the index given is outside the bounds of the collection
914    */
915   public void setProperty(final int index,
916       final uk.ac.vamsas.objects.core.Property vProperty)
917       throws java.lang.IndexOutOfBoundsException {
918     // check bounds for index
919     if (index < 0 || index >= this._propertyList.size()) {
920       throw new IndexOutOfBoundsException("setProperty: Index value '" + index
921           + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
922     }
923
924     this._propertyList.set(index, vProperty);
925   }
926
927   /**
928    * 
929    * 
930    * @param vPropertyArray
931    */
932   public void setProperty(
933       final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
934     // -- copy array
935     _propertyList.clear();
936
937     for (int i = 0; i < vPropertyArray.length; i++) {
938       this._propertyList.add(vPropertyArray[i]);
939     }
940   }
941
942   /**
943    * Sets the value of '_propertyList' by copying the given Vector. All elements
944    * will be checked for type safety.
945    * 
946    * @param vPropertyList
947    *          the Vector to copy.
948    */
949   public void setProperty(final java.util.Vector vPropertyList) {
950     // copy vector
951     this._propertyList.clear();
952
953     this._propertyList.addAll(vPropertyList);
954   }
955
956   /**
957    * Sets the value of '_propertyList' by setting it to the given Vector. No
958    * type checking is performed.
959    * 
960    * @deprecated
961    * 
962    * @param propertyVector
963    *          the Vector to set.
964    */
965   public void setPropertyAsReference(final java.util.Vector propertyVector) {
966     this._propertyList = propertyVector;
967   }
968
969   /**
970    * Sets the value of field 'provenance'.
971    * 
972    * @param provenance
973    *          the value of field 'provenance'.
974    */
975   public void setProvenance(
976       final uk.ac.vamsas.objects.core.Provenance provenance) {
977     this._provenance = provenance;
978   }
979
980   /**
981    * Sets the value of field 'title'.
982    * 
983    * @param title
984    *          the value of field 'title'.
985    */
986   public void setTitle(final java.lang.String title) {
987     this._title = title;
988   }
989
990   /**
991    * 
992    * 
993    * @param index
994    * @param vTreenode
995    * @throws java.lang.IndexOutOfBoundsException
996    *           if the index given is outside the bounds of the collection
997    */
998   public void setTreenode(final int index,
999       final uk.ac.vamsas.objects.core.Treenode vTreenode)
1000       throws java.lang.IndexOutOfBoundsException {
1001     // check bounds for index
1002     if (index < 0 || index >= this._treenodeList.size()) {
1003       throw new IndexOutOfBoundsException("setTreenode: Index value '" + index
1004           + "' not in range [0.." + (this._treenodeList.size() - 1) + "]");
1005     }
1006
1007     this._treenodeList.set(index, vTreenode);
1008   }
1009
1010   /**
1011    * 
1012    * 
1013    * @param vTreenodeArray
1014    */
1015   public void setTreenode(
1016       final uk.ac.vamsas.objects.core.Treenode[] vTreenodeArray) {
1017     // -- copy array
1018     _treenodeList.clear();
1019
1020     for (int i = 0; i < vTreenodeArray.length; i++) {
1021       this._treenodeList.add(vTreenodeArray[i]);
1022     }
1023   }
1024
1025   /**
1026    * Sets the value of '_treenodeList' by copying the given Vector. All elements
1027    * will be checked for type safety.
1028    * 
1029    * @param vTreenodeList
1030    *          the Vector to copy.
1031    */
1032   public void setTreenode(final java.util.Vector vTreenodeList) {
1033     // copy vector
1034     this._treenodeList.clear();
1035
1036     this._treenodeList.addAll(vTreenodeList);
1037   }
1038
1039   /**
1040    * Sets the value of '_treenodeList' by setting it to the given Vector. No
1041    * type checking is performed.
1042    * 
1043    * @deprecated
1044    * 
1045    * @param treenodeVector
1046    *          the Vector to set.
1047    */
1048   public void setTreenodeAsReference(final java.util.Vector treenodeVector) {
1049     this._treenodeList = treenodeVector;
1050   }
1051
1052   /**
1053    * Method unmarshal.
1054    * 
1055    * @param reader
1056    * @throws org.exolab.castor.xml.MarshalException
1057    *           if object is null or if any SAXException is thrown during
1058    *           marshaling
1059    * @throws org.exolab.castor.xml.ValidationException
1060    *           if this object is an invalid instance according to the schema
1061    * @return the unmarshaled uk.ac.vamsas.objects.core.Tree
1062    */
1063   public static uk.ac.vamsas.objects.core.Tree unmarshal(
1064       final java.io.Reader reader)
1065       throws org.exolab.castor.xml.MarshalException,
1066       org.exolab.castor.xml.ValidationException {
1067     return (uk.ac.vamsas.objects.core.Tree) Unmarshaller.unmarshal(
1068         uk.ac.vamsas.objects.core.Tree.class, reader);
1069   }
1070
1071   /**
1072    * 
1073    * 
1074    * @throws org.exolab.castor.xml.ValidationException
1075    *           if this object is an invalid instance according to the schema
1076    */
1077   public void validate() throws org.exolab.castor.xml.ValidationException {
1078     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1079     validator.validate(this);
1080   }
1081
1082 }