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