applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / DataSet.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 DataSet.
33  * 
34  * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007)
35  *          $
36  */
37 public class DataSet 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 _sequenceList.
51    */
52   private java.util.Vector _sequenceList;
53
54   /**
55    * Field _sequenceMappingList.
56    */
57   private java.util.Vector _sequenceMappingList;
58
59   /**
60    * Field _dataSetAnnotationsList.
61    */
62   private java.util.Vector _dataSetAnnotationsList;
63
64   /**
65    * Field _alignmentList.
66    */
67   private java.util.Vector _alignmentList;
68
69   /**
70    * Field _treeList.
71    */
72   private java.util.Vector _treeList;
73
74   /**
75    * Field _provenance.
76    */
77   private uk.ac.vamsas.objects.core.Provenance _provenance;
78
79   // ----------------/
80   // - Constructors -/
81   // ----------------/
82
83   public DataSet() {
84     super();
85     this._sequenceList = new java.util.Vector();
86     this._sequenceMappingList = new java.util.Vector();
87     this._dataSetAnnotationsList = new java.util.Vector();
88     this._alignmentList = new java.util.Vector();
89     this._treeList = new java.util.Vector();
90   }
91
92   // -----------/
93   // - Methods -/
94   // -----------/
95
96   /**
97    * 
98    * 
99    * @param vAlignment
100    * @throws java.lang.IndexOutOfBoundsException
101    *           if the index given is outside the bounds of the collection
102    */
103   public void addAlignment(final uk.ac.vamsas.objects.core.Alignment vAlignment)
104       throws java.lang.IndexOutOfBoundsException {
105     this._alignmentList.addElement(vAlignment);
106   }
107
108   /**
109    * 
110    * 
111    * @param index
112    * @param vAlignment
113    * @throws java.lang.IndexOutOfBoundsException
114    *           if the index given is outside the bounds of the collection
115    */
116   public void addAlignment(final int index,
117       final uk.ac.vamsas.objects.core.Alignment vAlignment)
118       throws java.lang.IndexOutOfBoundsException {
119     this._alignmentList.add(index, vAlignment);
120   }
121
122   /**
123    * 
124    * 
125    * @param vDataSetAnnotations
126    * @throws java.lang.IndexOutOfBoundsException
127    *           if the index given is outside the bounds of the collection
128    */
129   public void addDataSetAnnotations(
130       final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations)
131       throws java.lang.IndexOutOfBoundsException {
132     this._dataSetAnnotationsList.addElement(vDataSetAnnotations);
133   }
134
135   /**
136    * 
137    * 
138    * @param index
139    * @param vDataSetAnnotations
140    * @throws java.lang.IndexOutOfBoundsException
141    *           if the index given is outside the bounds of the collection
142    */
143   public void addDataSetAnnotations(final int index,
144       final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations)
145       throws java.lang.IndexOutOfBoundsException {
146     this._dataSetAnnotationsList.add(index, vDataSetAnnotations);
147   }
148
149   /**
150    * 
151    * 
152    * @param vSequence
153    * @throws java.lang.IndexOutOfBoundsException
154    *           if the index given is outside the bounds of the collection
155    */
156   public void addSequence(final uk.ac.vamsas.objects.core.Sequence vSequence)
157       throws java.lang.IndexOutOfBoundsException {
158     this._sequenceList.addElement(vSequence);
159   }
160
161   /**
162    * 
163    * 
164    * @param index
165    * @param vSequence
166    * @throws java.lang.IndexOutOfBoundsException
167    *           if the index given is outside the bounds of the collection
168    */
169   public void addSequence(final int index,
170       final uk.ac.vamsas.objects.core.Sequence vSequence)
171       throws java.lang.IndexOutOfBoundsException {
172     this._sequenceList.add(index, vSequence);
173   }
174
175   /**
176    * 
177    * 
178    * @param vSequenceMapping
179    * @throws java.lang.IndexOutOfBoundsException
180    *           if the index given is outside the bounds of the collection
181    */
182   public void addSequenceMapping(
183       final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping)
184       throws java.lang.IndexOutOfBoundsException {
185     this._sequenceMappingList.addElement(vSequenceMapping);
186   }
187
188   /**
189    * 
190    * 
191    * @param index
192    * @param vSequenceMapping
193    * @throws java.lang.IndexOutOfBoundsException
194    *           if the index given is outside the bounds of the collection
195    */
196   public void addSequenceMapping(final int index,
197       final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping)
198       throws java.lang.IndexOutOfBoundsException {
199     this._sequenceMappingList.add(index, vSequenceMapping);
200   }
201
202   /**
203    * 
204    * 
205    * @param vTree
206    * @throws java.lang.IndexOutOfBoundsException
207    *           if the index given is outside the bounds of the collection
208    */
209   public void addTree(final uk.ac.vamsas.objects.core.Tree vTree)
210       throws java.lang.IndexOutOfBoundsException {
211     this._treeList.addElement(vTree);
212   }
213
214   /**
215    * 
216    * 
217    * @param index
218    * @param vTree
219    * @throws java.lang.IndexOutOfBoundsException
220    *           if the index given is outside the bounds of the collection
221    */
222   public void addTree(final int index,
223       final uk.ac.vamsas.objects.core.Tree vTree)
224       throws java.lang.IndexOutOfBoundsException {
225     this._treeList.add(index, vTree);
226   }
227
228   /**
229    * Method enumerateAlignment.
230    * 
231    * @return an Enumeration over all uk.ac.vamsas.objects.core.Alignment
232    *         elements
233    */
234   public java.util.Enumeration enumerateAlignment() {
235     return this._alignmentList.elements();
236   }
237
238   /**
239    * Method enumerateDataSetAnnotations.
240    * 
241    * @return an Enumeration over all
242    *         uk.ac.vamsas.objects.core.DataSetAnnotations elements
243    */
244   public java.util.Enumeration enumerateDataSetAnnotations() {
245     return this._dataSetAnnotationsList.elements();
246   }
247
248   /**
249    * Method enumerateSequence.
250    * 
251    * @return an Enumeration over all uk.ac.vamsas.objects.core.Sequence elements
252    */
253   public java.util.Enumeration enumerateSequence() {
254     return this._sequenceList.elements();
255   }
256
257   /**
258    * Method enumerateSequenceMapping.
259    * 
260    * @return an Enumeration over all uk.ac.vamsas.objects.core.SequenceMapping
261    *         elements
262    */
263   public java.util.Enumeration enumerateSequenceMapping() {
264     return this._sequenceMappingList.elements();
265   }
266
267   /**
268    * Method enumerateTree.
269    * 
270    * @return an Enumeration over all uk.ac.vamsas.objects.core.Tree elements
271    */
272   public java.util.Enumeration enumerateTree() {
273     return this._treeList.elements();
274   }
275
276   /**
277    * Overrides the java.lang.Object.equals method.
278    * 
279    * @param obj
280    * @return true if the objects are equal.
281    */
282   public boolean equals(final java.lang.Object obj) {
283     if (this == obj)
284       return true;
285
286     if (super.equals(obj) == false)
287       return false;
288
289     if (obj instanceof DataSet) {
290
291       DataSet temp = (DataSet) obj;
292       boolean thcycle;
293       boolean tmcycle;
294       if (this._id != null) {
295         if (temp._id == null)
296           return false;
297         if (this._id != temp._id) {
298           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
299           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
300           if (thcycle != tmcycle) {
301             if (!thcycle) {
302               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
303             }
304             ;
305             if (!tmcycle) {
306               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
307             }
308             ;
309             return false;
310           }
311           if (!thcycle) {
312             if (!this._id.equals(temp._id)) {
313               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
314               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
315               return false;
316             }
317             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
318             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
319           }
320         }
321       } else if (temp._id != null)
322         return false;
323       if (this._sequenceList != null) {
324         if (temp._sequenceList == null)
325           return false;
326         if (this._sequenceList != temp._sequenceList) {
327           thcycle = org.castor.util.CycleBreaker
328               .startingToCycle(this._sequenceList);
329           tmcycle = org.castor.util.CycleBreaker
330               .startingToCycle(temp._sequenceList);
331           if (thcycle != tmcycle) {
332             if (!thcycle) {
333               org.castor.util.CycleBreaker
334                   .releaseCycleHandle(this._sequenceList);
335             }
336             ;
337             if (!tmcycle) {
338               org.castor.util.CycleBreaker
339                   .releaseCycleHandle(temp._sequenceList);
340             }
341             ;
342             return false;
343           }
344           if (!thcycle) {
345             if (!this._sequenceList.equals(temp._sequenceList)) {
346               org.castor.util.CycleBreaker
347                   .releaseCycleHandle(this._sequenceList);
348               org.castor.util.CycleBreaker
349                   .releaseCycleHandle(temp._sequenceList);
350               return false;
351             }
352             org.castor.util.CycleBreaker.releaseCycleHandle(this._sequenceList);
353             org.castor.util.CycleBreaker.releaseCycleHandle(temp._sequenceList);
354           }
355         }
356       } else if (temp._sequenceList != null)
357         return false;
358       if (this._sequenceMappingList != null) {
359         if (temp._sequenceMappingList == null)
360           return false;
361         if (this._sequenceMappingList != temp._sequenceMappingList) {
362           thcycle = org.castor.util.CycleBreaker
363               .startingToCycle(this._sequenceMappingList);
364           tmcycle = org.castor.util.CycleBreaker
365               .startingToCycle(temp._sequenceMappingList);
366           if (thcycle != tmcycle) {
367             if (!thcycle) {
368               org.castor.util.CycleBreaker
369                   .releaseCycleHandle(this._sequenceMappingList);
370             }
371             ;
372             if (!tmcycle) {
373               org.castor.util.CycleBreaker
374                   .releaseCycleHandle(temp._sequenceMappingList);
375             }
376             ;
377             return false;
378           }
379           if (!thcycle) {
380             if (!this._sequenceMappingList.equals(temp._sequenceMappingList)) {
381               org.castor.util.CycleBreaker
382                   .releaseCycleHandle(this._sequenceMappingList);
383               org.castor.util.CycleBreaker
384                   .releaseCycleHandle(temp._sequenceMappingList);
385               return false;
386             }
387             org.castor.util.CycleBreaker
388                 .releaseCycleHandle(this._sequenceMappingList);
389             org.castor.util.CycleBreaker
390                 .releaseCycleHandle(temp._sequenceMappingList);
391           }
392         }
393       } else if (temp._sequenceMappingList != null)
394         return false;
395       if (this._dataSetAnnotationsList != null) {
396         if (temp._dataSetAnnotationsList == null)
397           return false;
398         if (this._dataSetAnnotationsList != temp._dataSetAnnotationsList) {
399           thcycle = org.castor.util.CycleBreaker
400               .startingToCycle(this._dataSetAnnotationsList);
401           tmcycle = org.castor.util.CycleBreaker
402               .startingToCycle(temp._dataSetAnnotationsList);
403           if (thcycle != tmcycle) {
404             if (!thcycle) {
405               org.castor.util.CycleBreaker
406                   .releaseCycleHandle(this._dataSetAnnotationsList);
407             }
408             ;
409             if (!tmcycle) {
410               org.castor.util.CycleBreaker
411                   .releaseCycleHandle(temp._dataSetAnnotationsList);
412             }
413             ;
414             return false;
415           }
416           if (!thcycle) {
417             if (!this._dataSetAnnotationsList
418                 .equals(temp._dataSetAnnotationsList)) {
419               org.castor.util.CycleBreaker
420                   .releaseCycleHandle(this._dataSetAnnotationsList);
421               org.castor.util.CycleBreaker
422                   .releaseCycleHandle(temp._dataSetAnnotationsList);
423               return false;
424             }
425             org.castor.util.CycleBreaker
426                 .releaseCycleHandle(this._dataSetAnnotationsList);
427             org.castor.util.CycleBreaker
428                 .releaseCycleHandle(temp._dataSetAnnotationsList);
429           }
430         }
431       } else if (temp._dataSetAnnotationsList != null)
432         return false;
433       if (this._alignmentList != null) {
434         if (temp._alignmentList == null)
435           return false;
436         if (this._alignmentList != temp._alignmentList) {
437           thcycle = org.castor.util.CycleBreaker
438               .startingToCycle(this._alignmentList);
439           tmcycle = org.castor.util.CycleBreaker
440               .startingToCycle(temp._alignmentList);
441           if (thcycle != tmcycle) {
442             if (!thcycle) {
443               org.castor.util.CycleBreaker
444                   .releaseCycleHandle(this._alignmentList);
445             }
446             ;
447             if (!tmcycle) {
448               org.castor.util.CycleBreaker
449                   .releaseCycleHandle(temp._alignmentList);
450             }
451             ;
452             return false;
453           }
454           if (!thcycle) {
455             if (!this._alignmentList.equals(temp._alignmentList)) {
456               org.castor.util.CycleBreaker
457                   .releaseCycleHandle(this._alignmentList);
458               org.castor.util.CycleBreaker
459                   .releaseCycleHandle(temp._alignmentList);
460               return false;
461             }
462             org.castor.util.CycleBreaker
463                 .releaseCycleHandle(this._alignmentList);
464             org.castor.util.CycleBreaker
465                 .releaseCycleHandle(temp._alignmentList);
466           }
467         }
468       } else if (temp._alignmentList != null)
469         return false;
470       if (this._treeList != null) {
471         if (temp._treeList == null)
472           return false;
473         if (this._treeList != temp._treeList) {
474           thcycle = org.castor.util.CycleBreaker
475               .startingToCycle(this._treeList);
476           tmcycle = org.castor.util.CycleBreaker
477               .startingToCycle(temp._treeList);
478           if (thcycle != tmcycle) {
479             if (!thcycle) {
480               org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList);
481             }
482             ;
483             if (!tmcycle) {
484               org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList);
485             }
486             ;
487             return false;
488           }
489           if (!thcycle) {
490             if (!this._treeList.equals(temp._treeList)) {
491               org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList);
492               org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList);
493               return false;
494             }
495             org.castor.util.CycleBreaker.releaseCycleHandle(this._treeList);
496             org.castor.util.CycleBreaker.releaseCycleHandle(temp._treeList);
497           }
498         }
499       } else if (temp._treeList != null)
500         return false;
501       if (this._provenance != null) {
502         if (temp._provenance == null)
503           return false;
504         if (this._provenance != temp._provenance) {
505           thcycle = org.castor.util.CycleBreaker
506               .startingToCycle(this._provenance);
507           tmcycle = org.castor.util.CycleBreaker
508               .startingToCycle(temp._provenance);
509           if (thcycle != tmcycle) {
510             if (!thcycle) {
511               org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
512             }
513             ;
514             if (!tmcycle) {
515               org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
516             }
517             ;
518             return false;
519           }
520           if (!thcycle) {
521             if (!this._provenance.equals(temp._provenance)) {
522               org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
523               org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
524               return false;
525             }
526             org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
527             org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
528           }
529         }
530       } else if (temp._provenance != null)
531         return false;
532       return true;
533     }
534     return false;
535   }
536
537   /**
538    * Method getAlignment.
539    * 
540    * @param index
541    * @throws java.lang.IndexOutOfBoundsException
542    *           if the index given is outside the bounds of the collection
543    * @return the value of the uk.ac.vamsas.objects.core.Alignment at the given
544    *         index
545    */
546   public uk.ac.vamsas.objects.core.Alignment getAlignment(final int index)
547       throws java.lang.IndexOutOfBoundsException {
548     // check bounds for index
549     if (index < 0 || index >= this._alignmentList.size()) {
550       throw new IndexOutOfBoundsException("getAlignment: Index value '" + index
551           + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
552     }
553
554     return (uk.ac.vamsas.objects.core.Alignment) _alignmentList.get(index);
555   }
556
557   /**
558    * Method getAlignment.Returns the contents of the collection in an Array.
559    * <p>
560    * Note: Just in case the collection contents are changing in another thread,
561    * we pass a 0-length Array of the correct type into the API call. This way we
562    * <i>know</i> that the Array returned is of exactly the correct length.
563    * 
564    * @return this collection as an Array
565    */
566   public uk.ac.vamsas.objects.core.Alignment[] getAlignment() {
567     uk.ac.vamsas.objects.core.Alignment[] array = new uk.ac.vamsas.objects.core.Alignment[0];
568     return (uk.ac.vamsas.objects.core.Alignment[]) this._alignmentList
569         .toArray(array);
570   }
571
572   /**
573    * Method getAlignmentAsReference.Returns a reference to '_alignmentList'. No
574    * type checking is performed on any modifications to the Vector.
575    * 
576    * @return a reference to the Vector backing this class
577    */
578   public java.util.Vector getAlignmentAsReference() {
579     return this._alignmentList;
580   }
581
582   /**
583    * Method getAlignmentCount.
584    * 
585    * @return the size of this collection
586    */
587   public int getAlignmentCount() {
588     return this._alignmentList.size();
589   }
590
591   /**
592    * Method getDataSetAnnotations.
593    * 
594    * @param index
595    * @throws java.lang.IndexOutOfBoundsException
596    *           if the index given is outside the bounds of the collection
597    * @return the value of the uk.ac.vamsas.objects.core.DataSetAnnotations at
598    *         the given index
599    */
600   public uk.ac.vamsas.objects.core.DataSetAnnotations getDataSetAnnotations(
601       final int index) throws java.lang.IndexOutOfBoundsException {
602     // check bounds for index
603     if (index < 0 || index >= this._dataSetAnnotationsList.size()) {
604       throw new IndexOutOfBoundsException(
605           "getDataSetAnnotations: Index value '" + index
606               + "' not in range [0.."
607               + (this._dataSetAnnotationsList.size() - 1) + "]");
608     }
609
610     return (uk.ac.vamsas.objects.core.DataSetAnnotations) _dataSetAnnotationsList
611         .get(index);
612   }
613
614   /**
615    * Method getDataSetAnnotations.Returns the contents of the collection in an
616    * Array.
617    * <p>
618    * Note: Just in case the collection contents are changing in another thread,
619    * we pass a 0-length Array of the correct type into the API call. This way we
620    * <i>know</i> that the Array returned is of exactly the correct length.
621    * 
622    * @return this collection as an Array
623    */
624   public uk.ac.vamsas.objects.core.DataSetAnnotations[] getDataSetAnnotations() {
625     uk.ac.vamsas.objects.core.DataSetAnnotations[] array = new uk.ac.vamsas.objects.core.DataSetAnnotations[0];
626     return (uk.ac.vamsas.objects.core.DataSetAnnotations[]) this._dataSetAnnotationsList
627         .toArray(array);
628   }
629
630   /**
631    * Method getDataSetAnnotationsAsReference.Returns a reference to
632    * '_dataSetAnnotationsList'. No type checking is performed on any
633    * modifications to the Vector.
634    * 
635    * @return a reference to the Vector backing this class
636    */
637   public java.util.Vector getDataSetAnnotationsAsReference() {
638     return this._dataSetAnnotationsList;
639   }
640
641   /**
642    * Method getDataSetAnnotationsCount.
643    * 
644    * @return the size of this collection
645    */
646   public int getDataSetAnnotationsCount() {
647     return this._dataSetAnnotationsList.size();
648   }
649
650   /**
651    * Returns the value of field 'id'. The field 'id' has the following
652    * description: Primary Key for vamsas object referencing
653    * 
654    * @return the value of field 'Id'.
655    */
656   public java.lang.String getId() {
657     return this._id;
658   }
659
660   /**
661    * Returns the value of field 'provenance'.
662    * 
663    * @return the value of field 'Provenance'.
664    */
665   public uk.ac.vamsas.objects.core.Provenance getProvenance() {
666     return this._provenance;
667   }
668
669   /**
670    * Method getSequence.
671    * 
672    * @param index
673    * @throws java.lang.IndexOutOfBoundsException
674    *           if the index given is outside the bounds of the collection
675    * @return the value of the uk.ac.vamsas.objects.core.Sequence at the given
676    *         index
677    */
678   public uk.ac.vamsas.objects.core.Sequence getSequence(final int index)
679       throws java.lang.IndexOutOfBoundsException {
680     // check bounds for index
681     if (index < 0 || index >= this._sequenceList.size()) {
682       throw new IndexOutOfBoundsException("getSequence: Index value '" + index
683           + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
684     }
685
686     return (uk.ac.vamsas.objects.core.Sequence) _sequenceList.get(index);
687   }
688
689   /**
690    * Method getSequence.Returns the contents of the collection in an Array.
691    * <p>
692    * Note: Just in case the collection contents are changing in another thread,
693    * we pass a 0-length Array of the correct type into the API call. This way we
694    * <i>know</i> that the Array returned is of exactly the correct length.
695    * 
696    * @return this collection as an Array
697    */
698   public uk.ac.vamsas.objects.core.Sequence[] getSequence() {
699     uk.ac.vamsas.objects.core.Sequence[] array = new uk.ac.vamsas.objects.core.Sequence[0];
700     return (uk.ac.vamsas.objects.core.Sequence[]) this._sequenceList
701         .toArray(array);
702   }
703
704   /**
705    * Method getSequenceAsReference.Returns a reference to '_sequenceList'. No
706    * type checking is performed on any modifications to the Vector.
707    * 
708    * @return a reference to the Vector backing this class
709    */
710   public java.util.Vector getSequenceAsReference() {
711     return this._sequenceList;
712   }
713
714   /**
715    * Method getSequenceCount.
716    * 
717    * @return the size of this collection
718    */
719   public int getSequenceCount() {
720     return this._sequenceList.size();
721   }
722
723   /**
724    * Method getSequenceMapping.
725    * 
726    * @param index
727    * @throws java.lang.IndexOutOfBoundsException
728    *           if the index given is outside the bounds of the collection
729    * @return the value of the uk.ac.vamsas.objects.core.SequenceMapping at the
730    *         given index
731    */
732   public uk.ac.vamsas.objects.core.SequenceMapping getSequenceMapping(
733       final int index) throws java.lang.IndexOutOfBoundsException {
734     // check bounds for index
735     if (index < 0 || index >= this._sequenceMappingList.size()) {
736       throw new IndexOutOfBoundsException("getSequenceMapping: Index value '"
737           + index + "' not in range [0.."
738           + (this._sequenceMappingList.size() - 1) + "]");
739     }
740
741     return (uk.ac.vamsas.objects.core.SequenceMapping) _sequenceMappingList
742         .get(index);
743   }
744
745   /**
746    * Method getSequenceMapping.Returns the contents of the collection in an
747    * Array.
748    * <p>
749    * Note: Just in case the collection contents are changing in another thread,
750    * we pass a 0-length Array of the correct type into the API call. This way we
751    * <i>know</i> that the Array returned is of exactly the correct length.
752    * 
753    * @return this collection as an Array
754    */
755   public uk.ac.vamsas.objects.core.SequenceMapping[] getSequenceMapping() {
756     uk.ac.vamsas.objects.core.SequenceMapping[] array = new uk.ac.vamsas.objects.core.SequenceMapping[0];
757     return (uk.ac.vamsas.objects.core.SequenceMapping[]) this._sequenceMappingList
758         .toArray(array);
759   }
760
761   /**
762    * Method getSequenceMappingAsReference.Returns a reference to
763    * '_sequenceMappingList'. No type checking is performed on any modifications
764    * to the Vector.
765    * 
766    * @return a reference to the Vector backing this class
767    */
768   public java.util.Vector getSequenceMappingAsReference() {
769     return this._sequenceMappingList;
770   }
771
772   /**
773    * Method getSequenceMappingCount.
774    * 
775    * @return the size of this collection
776    */
777   public int getSequenceMappingCount() {
778     return this._sequenceMappingList.size();
779   }
780
781   /**
782    * Method getTree.
783    * 
784    * @param index
785    * @throws java.lang.IndexOutOfBoundsException
786    *           if the index given is outside the bounds of the collection
787    * @return the value of the uk.ac.vamsas.objects.core.Tree at the given index
788    */
789   public uk.ac.vamsas.objects.core.Tree getTree(final int index)
790       throws java.lang.IndexOutOfBoundsException {
791     // check bounds for index
792     if (index < 0 || index >= this._treeList.size()) {
793       throw new IndexOutOfBoundsException("getTree: Index value '" + index
794           + "' not in range [0.." + (this._treeList.size() - 1) + "]");
795     }
796
797     return (uk.ac.vamsas.objects.core.Tree) _treeList.get(index);
798   }
799
800   /**
801    * Method getTree.Returns the contents of the collection in an Array.
802    * <p>
803    * Note: Just in case the collection contents are changing in another thread,
804    * we pass a 0-length Array of the correct type into the API call. This way we
805    * <i>know</i> that the Array returned is of exactly the correct length.
806    * 
807    * @return this collection as an Array
808    */
809   public uk.ac.vamsas.objects.core.Tree[] getTree() {
810     uk.ac.vamsas.objects.core.Tree[] array = new uk.ac.vamsas.objects.core.Tree[0];
811     return (uk.ac.vamsas.objects.core.Tree[]) this._treeList.toArray(array);
812   }
813
814   /**
815    * Method getTreeAsReference.Returns a reference to '_treeList'. No type
816    * checking is performed on any modifications to the Vector.
817    * 
818    * @return a reference to the Vector backing this class
819    */
820   public java.util.Vector getTreeAsReference() {
821     return this._treeList;
822   }
823
824   /**
825    * Method getTreeCount.
826    * 
827    * @return the size of this collection
828    */
829   public int getTreeCount() {
830     return this._treeList.size();
831   }
832
833   /**
834    * Overrides the java.lang.Object.hashCode method.
835    * <p>
836    * The following steps came from <b>Effective Java Programming Language
837    * Guide</b> by Joshua Bloch, Chapter 3
838    * 
839    * @return a hash code value for the object.
840    */
841   public int hashCode() {
842     int result = super.hashCode();
843
844     long tmp;
845     if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
846       result = 37 * result + _id.hashCode();
847       org.castor.util.CycleBreaker.releaseCycleHandle(_id);
848     }
849     if (_sequenceList != null
850         && !org.castor.util.CycleBreaker.startingToCycle(_sequenceList)) {
851       result = 37 * result + _sequenceList.hashCode();
852       org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceList);
853     }
854     if (_sequenceMappingList != null
855         && !org.castor.util.CycleBreaker.startingToCycle(_sequenceMappingList)) {
856       result = 37 * result + _sequenceMappingList.hashCode();
857       org.castor.util.CycleBreaker.releaseCycleHandle(_sequenceMappingList);
858     }
859     if (_dataSetAnnotationsList != null
860         && !org.castor.util.CycleBreaker
861             .startingToCycle(_dataSetAnnotationsList)) {
862       result = 37 * result + _dataSetAnnotationsList.hashCode();
863       org.castor.util.CycleBreaker.releaseCycleHandle(_dataSetAnnotationsList);
864     }
865     if (_alignmentList != null
866         && !org.castor.util.CycleBreaker.startingToCycle(_alignmentList)) {
867       result = 37 * result + _alignmentList.hashCode();
868       org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentList);
869     }
870     if (_treeList != null
871         && !org.castor.util.CycleBreaker.startingToCycle(_treeList)) {
872       result = 37 * result + _treeList.hashCode();
873       org.castor.util.CycleBreaker.releaseCycleHandle(_treeList);
874     }
875     if (_provenance != null
876         && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
877       result = 37 * result + _provenance.hashCode();
878       org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
879     }
880
881     return result;
882   }
883
884   /**
885    * Method isValid.
886    * 
887    * @return true if this object is valid according to the schema
888    */
889   public boolean isValid() {
890     try {
891       validate();
892     } catch (org.exolab.castor.xml.ValidationException vex) {
893       return false;
894     }
895     return true;
896   }
897
898   /**
899    * 
900    * 
901    * @param out
902    * @throws org.exolab.castor.xml.MarshalException
903    *           if object is null or if any SAXException is thrown during
904    *           marshaling
905    * @throws org.exolab.castor.xml.ValidationException
906    *           if this object is an invalid instance according to the schema
907    */
908   public void marshal(final java.io.Writer out)
909       throws org.exolab.castor.xml.MarshalException,
910       org.exolab.castor.xml.ValidationException {
911     Marshaller.marshal(this, out);
912   }
913
914   /**
915    * 
916    * 
917    * @param handler
918    * @throws java.io.IOException
919    *           if an IOException occurs during marshaling
920    * @throws org.exolab.castor.xml.ValidationException
921    *           if this object is an invalid instance according to the schema
922    * @throws org.exolab.castor.xml.MarshalException
923    *           if object is null or if any SAXException is thrown during
924    *           marshaling
925    */
926   public void marshal(final org.xml.sax.ContentHandler handler)
927       throws java.io.IOException, org.exolab.castor.xml.MarshalException,
928       org.exolab.castor.xml.ValidationException {
929     Marshaller.marshal(this, handler);
930   }
931
932   /**
933    * Method removeAlignment.
934    * 
935    * @param vAlignment
936    * @return true if the object was removed from the collection.
937    */
938   public boolean removeAlignment(
939       final uk.ac.vamsas.objects.core.Alignment vAlignment) {
940     boolean removed = _alignmentList.remove(vAlignment);
941     return removed;
942   }
943
944   /**
945    * Method removeAlignmentAt.
946    * 
947    * @param index
948    * @return the element removed from the collection
949    */
950   public uk.ac.vamsas.objects.core.Alignment removeAlignmentAt(final int index) {
951     java.lang.Object obj = this._alignmentList.remove(index);
952     return (uk.ac.vamsas.objects.core.Alignment) obj;
953   }
954
955   /**
956      */
957   public void removeAllAlignment() {
958     this._alignmentList.clear();
959   }
960
961   /**
962      */
963   public void removeAllDataSetAnnotations() {
964     this._dataSetAnnotationsList.clear();
965   }
966
967   /**
968      */
969   public void removeAllSequence() {
970     this._sequenceList.clear();
971   }
972
973   /**
974      */
975   public void removeAllSequenceMapping() {
976     this._sequenceMappingList.clear();
977   }
978
979   /**
980      */
981   public void removeAllTree() {
982     this._treeList.clear();
983   }
984
985   /**
986    * Method removeDataSetAnnotations.
987    * 
988    * @param vDataSetAnnotations
989    * @return true if the object was removed from the collection.
990    */
991   public boolean removeDataSetAnnotations(
992       final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations) {
993     boolean removed = _dataSetAnnotationsList.remove(vDataSetAnnotations);
994     return removed;
995   }
996
997   /**
998    * Method removeDataSetAnnotationsAt.
999    * 
1000    * @param index
1001    * @return the element removed from the collection
1002    */
1003   public uk.ac.vamsas.objects.core.DataSetAnnotations removeDataSetAnnotationsAt(
1004       final int index) {
1005     java.lang.Object obj = this._dataSetAnnotationsList.remove(index);
1006     return (uk.ac.vamsas.objects.core.DataSetAnnotations) obj;
1007   }
1008
1009   /**
1010    * Method removeSequence.
1011    * 
1012    * @param vSequence
1013    * @return true if the object was removed from the collection.
1014    */
1015   public boolean removeSequence(
1016       final uk.ac.vamsas.objects.core.Sequence vSequence) {
1017     boolean removed = _sequenceList.remove(vSequence);
1018     return removed;
1019   }
1020
1021   /**
1022    * Method removeSequenceAt.
1023    * 
1024    * @param index
1025    * @return the element removed from the collection
1026    */
1027   public uk.ac.vamsas.objects.core.Sequence removeSequenceAt(final int index) {
1028     java.lang.Object obj = this._sequenceList.remove(index);
1029     return (uk.ac.vamsas.objects.core.Sequence) obj;
1030   }
1031
1032   /**
1033    * Method removeSequenceMapping.
1034    * 
1035    * @param vSequenceMapping
1036    * @return true if the object was removed from the collection.
1037    */
1038   public boolean removeSequenceMapping(
1039       final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping) {
1040     boolean removed = _sequenceMappingList.remove(vSequenceMapping);
1041     return removed;
1042   }
1043
1044   /**
1045    * Method removeSequenceMappingAt.
1046    * 
1047    * @param index
1048    * @return the element removed from the collection
1049    */
1050   public uk.ac.vamsas.objects.core.SequenceMapping removeSequenceMappingAt(
1051       final int index) {
1052     java.lang.Object obj = this._sequenceMappingList.remove(index);
1053     return (uk.ac.vamsas.objects.core.SequenceMapping) obj;
1054   }
1055
1056   /**
1057    * Method removeTree.
1058    * 
1059    * @param vTree
1060    * @return true if the object was removed from the collection.
1061    */
1062   public boolean removeTree(final uk.ac.vamsas.objects.core.Tree vTree) {
1063     boolean removed = _treeList.remove(vTree);
1064     return removed;
1065   }
1066
1067   /**
1068    * Method removeTreeAt.
1069    * 
1070    * @param index
1071    * @return the element removed from the collection
1072    */
1073   public uk.ac.vamsas.objects.core.Tree removeTreeAt(final int index) {
1074     java.lang.Object obj = this._treeList.remove(index);
1075     return (uk.ac.vamsas.objects.core.Tree) obj;
1076   }
1077
1078   /**
1079    * 
1080    * 
1081    * @param index
1082    * @param vAlignment
1083    * @throws java.lang.IndexOutOfBoundsException
1084    *           if the index given is outside the bounds of the collection
1085    */
1086   public void setAlignment(final int index,
1087       final uk.ac.vamsas.objects.core.Alignment vAlignment)
1088       throws java.lang.IndexOutOfBoundsException {
1089     // check bounds for index
1090     if (index < 0 || index >= this._alignmentList.size()) {
1091       throw new IndexOutOfBoundsException("setAlignment: Index value '" + index
1092           + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
1093     }
1094
1095     this._alignmentList.set(index, vAlignment);
1096   }
1097
1098   /**
1099    * 
1100    * 
1101    * @param vAlignmentArray
1102    */
1103   public void setAlignment(
1104       final uk.ac.vamsas.objects.core.Alignment[] vAlignmentArray) {
1105     // -- copy array
1106     _alignmentList.clear();
1107
1108     for (int i = 0; i < vAlignmentArray.length; i++) {
1109       this._alignmentList.add(vAlignmentArray[i]);
1110     }
1111   }
1112
1113   /**
1114    * Sets the value of '_alignmentList' by copying the given Vector. All
1115    * elements will be checked for type safety.
1116    * 
1117    * @param vAlignmentList
1118    *          the Vector to copy.
1119    */
1120   public void setAlignment(final java.util.Vector vAlignmentList) {
1121     // copy vector
1122     this._alignmentList.clear();
1123
1124     this._alignmentList.addAll(vAlignmentList);
1125   }
1126
1127   /**
1128    * Sets the value of '_alignmentList' by setting it to the given Vector. No
1129    * type checking is performed.
1130    * 
1131    * @deprecated
1132    * 
1133    * @param alignmentVector
1134    *          the Vector to set.
1135    */
1136   public void setAlignmentAsReference(final java.util.Vector alignmentVector) {
1137     this._alignmentList = alignmentVector;
1138   }
1139
1140   /**
1141    * 
1142    * 
1143    * @param index
1144    * @param vDataSetAnnotations
1145    * @throws java.lang.IndexOutOfBoundsException
1146    *           if the index given is outside the bounds of the collection
1147    */
1148   public void setDataSetAnnotations(final int index,
1149       final uk.ac.vamsas.objects.core.DataSetAnnotations vDataSetAnnotations)
1150       throws java.lang.IndexOutOfBoundsException {
1151     // check bounds for index
1152     if (index < 0 || index >= this._dataSetAnnotationsList.size()) {
1153       throw new IndexOutOfBoundsException(
1154           "setDataSetAnnotations: Index value '" + index
1155               + "' not in range [0.."
1156               + (this._dataSetAnnotationsList.size() - 1) + "]");
1157     }
1158
1159     this._dataSetAnnotationsList.set(index, vDataSetAnnotations);
1160   }
1161
1162   /**
1163    * 
1164    * 
1165    * @param vDataSetAnnotationsArray
1166    */
1167   public void setDataSetAnnotations(
1168       final uk.ac.vamsas.objects.core.DataSetAnnotations[] vDataSetAnnotationsArray) {
1169     // -- copy array
1170     _dataSetAnnotationsList.clear();
1171
1172     for (int i = 0; i < vDataSetAnnotationsArray.length; i++) {
1173       this._dataSetAnnotationsList.add(vDataSetAnnotationsArray[i]);
1174     }
1175   }
1176
1177   /**
1178    * Sets the value of '_dataSetAnnotationsList' by copying the given Vector.
1179    * All elements will be checked for type safety.
1180    * 
1181    * @param vDataSetAnnotationsList
1182    *          the Vector to copy.
1183    */
1184   public void setDataSetAnnotations(
1185       final java.util.Vector vDataSetAnnotationsList) {
1186     // copy vector
1187     this._dataSetAnnotationsList.clear();
1188
1189     this._dataSetAnnotationsList.addAll(vDataSetAnnotationsList);
1190   }
1191
1192   /**
1193    * Sets the value of '_dataSetAnnotationsList' by setting it to the given
1194    * Vector. No type checking is performed.
1195    * 
1196    * @deprecated
1197    * 
1198    * @param dataSetAnnotationsVector
1199    *          the Vector to set.
1200    */
1201   public void setDataSetAnnotationsAsReference(
1202       final java.util.Vector dataSetAnnotationsVector) {
1203     this._dataSetAnnotationsList = dataSetAnnotationsVector;
1204   }
1205
1206   /**
1207    * Sets the value of field 'id'. The field 'id' has the following description:
1208    * Primary Key for vamsas object referencing
1209    * 
1210    * @param id
1211    *          the value of field 'id'.
1212    */
1213   public void setId(final java.lang.String id) {
1214     this._id = id;
1215   }
1216
1217   /**
1218    * Sets the value of field 'provenance'.
1219    * 
1220    * @param provenance
1221    *          the value of field 'provenance'.
1222    */
1223   public void setProvenance(
1224       final uk.ac.vamsas.objects.core.Provenance provenance) {
1225     this._provenance = provenance;
1226   }
1227
1228   /**
1229    * 
1230    * 
1231    * @param index
1232    * @param vSequence
1233    * @throws java.lang.IndexOutOfBoundsException
1234    *           if the index given is outside the bounds of the collection
1235    */
1236   public void setSequence(final int index,
1237       final uk.ac.vamsas.objects.core.Sequence vSequence)
1238       throws java.lang.IndexOutOfBoundsException {
1239     // check bounds for index
1240     if (index < 0 || index >= this._sequenceList.size()) {
1241       throw new IndexOutOfBoundsException("setSequence: Index value '" + index
1242           + "' not in range [0.." + (this._sequenceList.size() - 1) + "]");
1243     }
1244
1245     this._sequenceList.set(index, vSequence);
1246   }
1247
1248   /**
1249    * 
1250    * 
1251    * @param vSequenceArray
1252    */
1253   public void setSequence(
1254       final uk.ac.vamsas.objects.core.Sequence[] vSequenceArray) {
1255     // -- copy array
1256     _sequenceList.clear();
1257
1258     for (int i = 0; i < vSequenceArray.length; i++) {
1259       this._sequenceList.add(vSequenceArray[i]);
1260     }
1261   }
1262
1263   /**
1264    * Sets the value of '_sequenceList' by copying the given Vector. All elements
1265    * will be checked for type safety.
1266    * 
1267    * @param vSequenceList
1268    *          the Vector to copy.
1269    */
1270   public void setSequence(final java.util.Vector vSequenceList) {
1271     // copy vector
1272     this._sequenceList.clear();
1273
1274     this._sequenceList.addAll(vSequenceList);
1275   }
1276
1277   /**
1278    * Sets the value of '_sequenceList' by setting it to the given Vector. No
1279    * type checking is performed.
1280    * 
1281    * @deprecated
1282    * 
1283    * @param sequenceVector
1284    *          the Vector to set.
1285    */
1286   public void setSequenceAsReference(final java.util.Vector sequenceVector) {
1287     this._sequenceList = sequenceVector;
1288   }
1289
1290   /**
1291    * 
1292    * 
1293    * @param index
1294    * @param vSequenceMapping
1295    * @throws java.lang.IndexOutOfBoundsException
1296    *           if the index given is outside the bounds of the collection
1297    */
1298   public void setSequenceMapping(final int index,
1299       final uk.ac.vamsas.objects.core.SequenceMapping vSequenceMapping)
1300       throws java.lang.IndexOutOfBoundsException {
1301     // check bounds for index
1302     if (index < 0 || index >= this._sequenceMappingList.size()) {
1303       throw new IndexOutOfBoundsException("setSequenceMapping: Index value '"
1304           + index + "' not in range [0.."
1305           + (this._sequenceMappingList.size() - 1) + "]");
1306     }
1307
1308     this._sequenceMappingList.set(index, vSequenceMapping);
1309   }
1310
1311   /**
1312    * 
1313    * 
1314    * @param vSequenceMappingArray
1315    */
1316   public void setSequenceMapping(
1317       final uk.ac.vamsas.objects.core.SequenceMapping[] vSequenceMappingArray) {
1318     // -- copy array
1319     _sequenceMappingList.clear();
1320
1321     for (int i = 0; i < vSequenceMappingArray.length; i++) {
1322       this._sequenceMappingList.add(vSequenceMappingArray[i]);
1323     }
1324   }
1325
1326   /**
1327    * Sets the value of '_sequenceMappingList' by copying the given Vector. All
1328    * elements will be checked for type safety.
1329    * 
1330    * @param vSequenceMappingList
1331    *          the Vector to copy.
1332    */
1333   public void setSequenceMapping(final java.util.Vector vSequenceMappingList) {
1334     // copy vector
1335     this._sequenceMappingList.clear();
1336
1337     this._sequenceMappingList.addAll(vSequenceMappingList);
1338   }
1339
1340   /**
1341    * Sets the value of '_sequenceMappingList' by setting it to the given Vector.
1342    * No type checking is performed.
1343    * 
1344    * @deprecated
1345    * 
1346    * @param sequenceMappingVector
1347    *          the Vector to set.
1348    */
1349   public void setSequenceMappingAsReference(
1350       final java.util.Vector sequenceMappingVector) {
1351     this._sequenceMappingList = sequenceMappingVector;
1352   }
1353
1354   /**
1355    * 
1356    * 
1357    * @param index
1358    * @param vTree
1359    * @throws java.lang.IndexOutOfBoundsException
1360    *           if the index given is outside the bounds of the collection
1361    */
1362   public void setTree(final int index,
1363       final uk.ac.vamsas.objects.core.Tree vTree)
1364       throws java.lang.IndexOutOfBoundsException {
1365     // check bounds for index
1366     if (index < 0 || index >= this._treeList.size()) {
1367       throw new IndexOutOfBoundsException("setTree: Index value '" + index
1368           + "' not in range [0.." + (this._treeList.size() - 1) + "]");
1369     }
1370
1371     this._treeList.set(index, vTree);
1372   }
1373
1374   /**
1375    * 
1376    * 
1377    * @param vTreeArray
1378    */
1379   public void setTree(final uk.ac.vamsas.objects.core.Tree[] vTreeArray) {
1380     // -- copy array
1381     _treeList.clear();
1382
1383     for (int i = 0; i < vTreeArray.length; i++) {
1384       this._treeList.add(vTreeArray[i]);
1385     }
1386   }
1387
1388   /**
1389    * Sets the value of '_treeList' by copying the given Vector. All elements
1390    * will be checked for type safety.
1391    * 
1392    * @param vTreeList
1393    *          the Vector to copy.
1394    */
1395   public void setTree(final java.util.Vector vTreeList) {
1396     // copy vector
1397     this._treeList.clear();
1398
1399     this._treeList.addAll(vTreeList);
1400   }
1401
1402   /**
1403    * Sets the value of '_treeList' by setting it to the given Vector. No type
1404    * checking is performed.
1405    * 
1406    * @deprecated
1407    * 
1408    * @param treeVector
1409    *          the Vector to set.
1410    */
1411   public void setTreeAsReference(final java.util.Vector treeVector) {
1412     this._treeList = treeVector;
1413   }
1414
1415   /**
1416    * Method unmarshal.
1417    * 
1418    * @param reader
1419    * @throws org.exolab.castor.xml.MarshalException
1420    *           if object is null or if any SAXException is thrown during
1421    *           marshaling
1422    * @throws org.exolab.castor.xml.ValidationException
1423    *           if this object is an invalid instance according to the schema
1424    * @return the unmarshaled uk.ac.vamsas.objects.core.DataSet
1425    */
1426   public static uk.ac.vamsas.objects.core.DataSet unmarshal(
1427       final java.io.Reader reader)
1428       throws org.exolab.castor.xml.MarshalException,
1429       org.exolab.castor.xml.ValidationException {
1430     return (uk.ac.vamsas.objects.core.DataSet) Unmarshaller.unmarshal(
1431         uk.ac.vamsas.objects.core.DataSet.class, reader);
1432   }
1433
1434   /**
1435    * 
1436    * 
1437    * @throws org.exolab.castor.xml.ValidationException
1438    *           if this object is an invalid instance according to the schema
1439    */
1440   public void validate() throws org.exolab.castor.xml.ValidationException {
1441     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1442     validator.validate(this);
1443   }
1444
1445 }