8192795e1b311b67decc95b05fe0a8115192e3e8
[vamsas.git] / src / uk / ac / vamsas / objects / core / AlignmentSequence.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
16
17 /**
18  * Class AlignmentSequence.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class AlignmentSequence extends uk.ac.vamsas.objects.core.SequenceType 
23 implements java.io.Serializable
24 {
25
26
27       //--------------------------/
28      //- Class/Member Variables -/
29     //--------------------------/
30
31     /**
32      * Primary Key for vamsas object
33      *  referencing 
34      */
35     private java.lang.String _id;
36
37     /**
38      * Dataset Sequence from which
39      *  this alignment sequence is taken from
40      *  
41      */
42     private java.lang.Object _refid;
43
44     /**
45      * Field _alignmentSequenceAnnotationList.
46      */
47     private java.util.Vector _alignmentSequenceAnnotationList;
48
49
50       //----------------/
51      //- Constructors -/
52     //----------------/
53
54     public AlignmentSequence() {
55         super();
56         this._alignmentSequenceAnnotationList = new java.util.Vector();
57     }
58
59
60       //-----------/
61      //- Methods -/
62     //-----------/
63
64     /**
65      * 
66      * 
67      * @param vAlignmentSequenceAnnotation
68      * @throws java.lang.IndexOutOfBoundsException if the index
69      * given is outside the bounds of the collection
70      */
71     public void addAlignmentSequenceAnnotation(
72             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation)
73     throws java.lang.IndexOutOfBoundsException {
74         this._alignmentSequenceAnnotationList.addElement(vAlignmentSequenceAnnotation);
75     }
76
77     /**
78      * 
79      * 
80      * @param index
81      * @param vAlignmentSequenceAnnotation
82      * @throws java.lang.IndexOutOfBoundsException if the index
83      * given is outside the bounds of the collection
84      */
85     public void addAlignmentSequenceAnnotation(
86             final int index,
87             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation)
88     throws java.lang.IndexOutOfBoundsException {
89         this._alignmentSequenceAnnotationList.add(index, vAlignmentSequenceAnnotation);
90     }
91
92     /**
93      * Method enumerateAlignmentSequenceAnnotation.
94      * 
95      * @return an Enumeration over all
96      * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation element
97      */
98     public java.util.Enumeration enumerateAlignmentSequenceAnnotation(
99     ) {
100         return this._alignmentSequenceAnnotationList.elements();
101     }
102
103     /**
104      * Overrides the java.lang.Object.equals method.
105      * 
106      * @param obj
107      * @return true if the objects are equal.
108      */
109     public boolean equals(
110             final java.lang.Object obj) {
111         if ( this == obj )
112             return true;
113         
114         if (super.equals(obj)==false)
115             return false;
116         
117         if (obj instanceof AlignmentSequence) {
118         
119             AlignmentSequence temp = (AlignmentSequence)obj;
120             boolean thcycle;
121             boolean tmcycle;
122             if (this._id != null) {
123                 if (temp._id == null) return false;
124                 if (this._id != temp._id) {
125                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
126                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
127                     if (thcycle!=tmcycle) {
128                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
129                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
130                         return false;
131                     }
132                     if (!thcycle) {
133                         if (!this._id.equals(temp._id)) {
134                             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
135                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
136                             return false;
137                         }
138                         org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
139                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
140                     }
141                 }
142             } else if (temp._id != null)
143                 return false;
144             if (this._refid != null) {
145                 if (temp._refid == null) return false;
146                 if (this._refid != temp._refid) {
147                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._refid);
148                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._refid);
149                     if (thcycle!=tmcycle) {
150                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._refid); };
151                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid); };
152                         return false;
153                     }
154                     if (!thcycle) {
155                         if (!this._refid.equals(temp._refid)) {
156                             org.castor.util.CycleBreaker.releaseCycleHandle(this._refid);
157                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid);
158                             return false;
159                         }
160                         org.castor.util.CycleBreaker.releaseCycleHandle(this._refid);
161                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._refid);
162                     }
163                 }
164             } else if (temp._refid != null)
165                 return false;
166             if (this._alignmentSequenceAnnotationList != null) {
167                 if (temp._alignmentSequenceAnnotationList == null) return false;
168                 if (this._alignmentSequenceAnnotationList != temp._alignmentSequenceAnnotationList) {
169                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._alignmentSequenceAnnotationList);
170                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._alignmentSequenceAnnotationList);
171                     if (thcycle!=tmcycle) {
172                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList); };
173                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList); };
174                         return false;
175                     }
176                     if (!thcycle) {
177                         if (!this._alignmentSequenceAnnotationList.equals(temp._alignmentSequenceAnnotationList)) {
178                             org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList);
179                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList);
180                             return false;
181                         }
182                         org.castor.util.CycleBreaker.releaseCycleHandle(this._alignmentSequenceAnnotationList);
183                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._alignmentSequenceAnnotationList);
184                     }
185                 }
186             } else if (temp._alignmentSequenceAnnotationList != null)
187                 return false;
188             return true;
189         }
190         return false;
191     }
192
193     /**
194      * Method getAlignmentSequenceAnnotation.
195      * 
196      * @param index
197      * @throws java.lang.IndexOutOfBoundsException if the index
198      * given is outside the bounds of the collection
199      * @return the value of the
200      * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation at the
201      * given index
202      */
203     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation(
204             final int index)
205     throws java.lang.IndexOutOfBoundsException {
206         // check bounds for index
207         if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) {
208             throw new IndexOutOfBoundsException("getAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]");
209         }
210         
211         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList.get(index);
212     }
213
214     /**
215      * Method getAlignmentSequenceAnnotation.Returns the contents
216      * of the collection in an Array.  <p>Note:  Just in case the
217      * collection contents are changing in another thread, we pass
218      * a 0-length Array of the correct type into the API call. 
219      * This way we <i>know</i> that the Array returned is of
220      * exactly the correct length.
221      * 
222      * @return this collection as an Array
223      */
224     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation(
225     ) {
226         uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[0];
227         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[]) this._alignmentSequenceAnnotationList.toArray(array);
228     }
229
230     /**
231      * Method getAlignmentSequenceAnnotationAsReference.Returns a
232      * reference to '_alignmentSequenceAnnotationList'. No type
233      * checking is performed on any modifications to the Vector.
234      * 
235      * @return a reference to the Vector backing this class
236      */
237     public java.util.Vector getAlignmentSequenceAnnotationAsReference(
238     ) {
239         return this._alignmentSequenceAnnotationList;
240     }
241
242     /**
243      * Method getAlignmentSequenceAnnotationCount.
244      * 
245      * @return the size of this collection
246      */
247     public int getAlignmentSequenceAnnotationCount(
248     ) {
249         return this._alignmentSequenceAnnotationList.size();
250     }
251
252     /**
253      * Returns the value of field 'id'. The field 'id' has the
254      * following description: Primary Key for vamsas object
255      *  referencing 
256      * 
257      * @return the value of field 'Id'.
258      */
259     public java.lang.String getId(
260     ) {
261         return this._id;
262     }
263
264     /**
265      * Returns the value of field 'refid'. The field 'refid' has
266      * the following description: Dataset Sequence from which
267      *  this alignment sequence is taken from
268      *  
269      * 
270      * @return the value of field 'Refid'.
271      */
272     public java.lang.Object getRefid(
273     ) {
274         return this._refid;
275     }
276
277     /**
278      * Overrides the java.lang.Object.hashCode method.
279      * <p>
280      * The following steps came from <b>Effective Java Programming
281      * Language Guide</b> by Joshua Bloch, Chapter 3
282      * 
283      * @return a hash code value for the object.
284      */
285     public int hashCode(
286     ) {
287         int result = super.hashCode();
288         
289         long tmp;
290         if (_id != null
291             && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
292            result = 37 * result + _id.hashCode();
293            org.castor.util.CycleBreaker.releaseCycleHandle(_id);
294         }
295         if (_refid != null
296             && !org.castor.util.CycleBreaker.startingToCycle(_refid)) {
297            result = 37 * result + _refid.hashCode();
298            org.castor.util.CycleBreaker.releaseCycleHandle(_refid);
299         }
300         if (_alignmentSequenceAnnotationList != null
301             && !org.castor.util.CycleBreaker.startingToCycle(_alignmentSequenceAnnotationList)) {
302            result = 37 * result + _alignmentSequenceAnnotationList.hashCode();
303            org.castor.util.CycleBreaker.releaseCycleHandle(_alignmentSequenceAnnotationList);
304         }
305         
306         return result;
307     }
308
309     /**
310      * Method isValid.
311      * 
312      * @return true if this object is valid according to the schema
313      */
314     public boolean isValid(
315     ) {
316         try {
317             validate();
318         } catch (org.exolab.castor.xml.ValidationException vex) {
319             return false;
320         }
321         return true;
322     }
323
324     /**
325      * 
326      * 
327      * @param out
328      * @throws org.exolab.castor.xml.MarshalException if object is
329      * null or if any SAXException is thrown during marshaling
330      * @throws org.exolab.castor.xml.ValidationException if this
331      * object is an invalid instance according to the schema
332      */
333     public void marshal(
334             final java.io.Writer out)
335     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
336         Marshaller.marshal(this, out);
337     }
338
339     /**
340      * 
341      * 
342      * @param handler
343      * @throws java.io.IOException if an IOException occurs during
344      * marshaling
345      * @throws org.exolab.castor.xml.ValidationException if this
346      * object is an invalid instance according to the schema
347      * @throws org.exolab.castor.xml.MarshalException if object is
348      * null or if any SAXException is thrown during marshaling
349      */
350     public void marshal(
351             final org.xml.sax.ContentHandler handler)
352     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
353         Marshaller.marshal(this, handler);
354     }
355
356     /**
357      * Method removeAlignmentSequenceAnnotation.
358      * 
359      * @param vAlignmentSequenceAnnotation
360      * @return true if the object was removed from the collection.
361      */
362     public boolean removeAlignmentSequenceAnnotation(
363             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) {
364         boolean removed = _alignmentSequenceAnnotationList.remove(vAlignmentSequenceAnnotation);
365         return removed;
366     }
367
368     /**
369      * Method removeAlignmentSequenceAnnotationAt.
370      * 
371      * @param index
372      * @return the element removed from the collection
373      */
374     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotationAt(
375             final int index) {
376         java.lang.Object obj = this._alignmentSequenceAnnotationList.remove(index);
377         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) obj;
378     }
379
380     /**
381      */
382     public void removeAllAlignmentSequenceAnnotation(
383     ) {
384         this._alignmentSequenceAnnotationList.clear();
385     }
386
387     /**
388      * 
389      * 
390      * @param index
391      * @param vAlignmentSequenceAnnotation
392      * @throws java.lang.IndexOutOfBoundsException if the index
393      * given is outside the bounds of the collection
394      */
395     public void setAlignmentSequenceAnnotation(
396             final int index,
397             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation)
398     throws java.lang.IndexOutOfBoundsException {
399         // check bounds for index
400         if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) {
401             throw new IndexOutOfBoundsException("setAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]");
402         }
403         
404         this._alignmentSequenceAnnotationList.set(index, vAlignmentSequenceAnnotation);
405     }
406
407     /**
408      * 
409      * 
410      * @param vAlignmentSequenceAnnotationArray
411      */
412     public void setAlignmentSequenceAnnotation(
413             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] vAlignmentSequenceAnnotationArray) {
414         //-- copy array
415         _alignmentSequenceAnnotationList.clear();
416         
417         for (int i = 0; i < vAlignmentSequenceAnnotationArray.length; i++) {
418                 this._alignmentSequenceAnnotationList.add(vAlignmentSequenceAnnotationArray[i]);
419         }
420     }
421
422     /**
423      * Sets the value of '_alignmentSequenceAnnotationList' by
424      * copying the given Vector. All elements will be checked for
425      * type safety.
426      * 
427      * @param vAlignmentSequenceAnnotationList the Vector to copy.
428      */
429     public void setAlignmentSequenceAnnotation(
430             final java.util.Vector vAlignmentSequenceAnnotationList) {
431         // copy vector
432         this._alignmentSequenceAnnotationList.clear();
433         
434         this._alignmentSequenceAnnotationList.addAll(vAlignmentSequenceAnnotationList);
435     }
436
437     /**
438      * Sets the value of '_alignmentSequenceAnnotationList' by
439      * setting it to the given Vector. No type checking is
440      * performed.
441      * @deprecated
442      * 
443      * @param alignmentSequenceAnnotationVector the Vector to set.
444      */
445     public void setAlignmentSequenceAnnotationAsReference(
446             final java.util.Vector alignmentSequenceAnnotationVector) {
447         this._alignmentSequenceAnnotationList = alignmentSequenceAnnotationVector;
448     }
449
450     /**
451      * Sets the value of field 'id'. The field 'id' has the
452      * following description: Primary Key for vamsas object
453      *  referencing 
454      * 
455      * @param id the value of field 'id'.
456      */
457     public void setId(
458             final java.lang.String id) {
459         this._id = id;
460     }
461
462     /**
463      * Sets the value of field 'refid'. The field 'refid' has the
464      * following description: Dataset Sequence from which
465      *  this alignment sequence is taken from
466      *  
467      * 
468      * @param refid the value of field 'refid'.
469      */
470     public void setRefid(
471             final java.lang.Object refid) {
472         this._refid = refid;
473     }
474
475     /**
476      * Method unmarshal.
477      * 
478      * @param reader
479      * @throws org.exolab.castor.xml.MarshalException if object is
480      * null or if any SAXException is thrown during marshaling
481      * @throws org.exolab.castor.xml.ValidationException if this
482      * object is an invalid instance according to the schema
483      * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
484      */
485     public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
486             final java.io.Reader reader)
487     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
488         return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentSequence.class, reader);
489     }
490
491     /**
492      * 
493      * 
494      * @throws org.exolab.castor.xml.ValidationException if this
495      * object is an invalid instance according to the schema
496      */
497     public void validate(
498     )
499     throws org.exolab.castor.xml.ValidationException {
500         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
501         validator.validate(this);
502     }
503
504 }