a47696123f0ec68883a83d40344c282ea748e4ae
[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             if (this._id != null) {
121                 if (temp._id == null) return false;
122                 else if (!(this._id.equals(temp._id))) 
123                     return false;
124             }
125             else if (temp._id != null)
126                 return false;
127             if (this._refid != null) {
128                 if (temp._refid == null) return false;
129                 else if (!(this._refid.equals(temp._refid))) 
130                     return false;
131             }
132             else if (temp._refid != null)
133                 return false;
134             if (this._alignmentSequenceAnnotationList != null) {
135                 if (temp._alignmentSequenceAnnotationList == null) return false;
136                 else if (!(this._alignmentSequenceAnnotationList.equals(temp._alignmentSequenceAnnotationList))) 
137                     return false;
138             }
139             else if (temp._alignmentSequenceAnnotationList != null)
140                 return false;
141             return true;
142         }
143         return false;
144     }
145
146     /**
147      * Method getAlignmentSequenceAnnotation.
148      * 
149      * @param index
150      * @throws java.lang.IndexOutOfBoundsException if the index
151      * given is outside the bounds of the collection
152      * @return the value of the
153      * uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation at the
154      * given index
155      */
156     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation getAlignmentSequenceAnnotation(
157             final int index)
158     throws java.lang.IndexOutOfBoundsException {
159         // check bounds for index
160         if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) {
161             throw new IndexOutOfBoundsException("getAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]");
162         }
163         
164         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) _alignmentSequenceAnnotationList.get(index);
165     }
166
167     /**
168      * Method getAlignmentSequenceAnnotation.Returns the contents
169      * of the collection in an Array.  <p>Note:  Just in case the
170      * collection contents are changing in another thread, we pass
171      * a 0-length Array of the correct type into the API call. 
172      * This way we <i>know</i> that the Array returned is of
173      * exactly the correct length.
174      * 
175      * @return this collection as an Array
176      */
177     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] getAlignmentSequenceAnnotation(
178     ) {
179         uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] array = new uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[0];
180         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[]) this._alignmentSequenceAnnotationList.toArray(array);
181     }
182
183     /**
184      * Method getAlignmentSequenceAnnotationAsReference.Returns a
185      * reference to '_alignmentSequenceAnnotationList'. No type
186      * checking is performed on any modifications to the Vector.
187      * 
188      * @return a reference to the Vector backing this class
189      */
190     public java.util.Vector getAlignmentSequenceAnnotationAsReference(
191     ) {
192         return this._alignmentSequenceAnnotationList;
193     }
194
195     /**
196      * Method getAlignmentSequenceAnnotationCount.
197      * 
198      * @return the size of this collection
199      */
200     public int getAlignmentSequenceAnnotationCount(
201     ) {
202         return this._alignmentSequenceAnnotationList.size();
203     }
204
205     /**
206      * Returns the value of field 'id'. The field 'id' has the
207      * following description: Primary Key for vamsas object
208      *  referencing 
209      * 
210      * @return the value of field 'Id'.
211      */
212     public java.lang.String getId(
213     ) {
214         return this._id;
215     }
216
217     /**
218      * Returns the value of field 'refid'. The field 'refid' has
219      * the following description: Dataset Sequence from which
220      *  this alignment sequence is taken from
221      *  
222      * 
223      * @return the value of field 'Refid'.
224      */
225     public java.lang.Object getRefid(
226     ) {
227         return this._refid;
228     }
229
230     /**
231      * Overrides the java.lang.Object.hashCode method.
232      * <p>
233      * The following steps came from <b>Effective Java Programming
234      * Language Guide</b> by Joshua Bloch, Chapter 3
235      * 
236      * @return a hash code value for the object.
237      */
238     public int hashCode(
239     ) {
240         int result = super.hashCode();
241         
242         long tmp;
243         if (_id != null) {
244            result = 37 * result + _id.hashCode();
245         }
246         if (_refid != null) {
247            result = 37 * result + _refid.hashCode();
248         }
249         if (_alignmentSequenceAnnotationList != null) {
250            result = 37 * result + _alignmentSequenceAnnotationList.hashCode();
251         }
252         
253         return result;
254     }
255
256     /**
257      * Method isValid.
258      * 
259      * @return true if this object is valid according to the schema
260      */
261     public boolean isValid(
262     ) {
263         try {
264             validate();
265         } catch (org.exolab.castor.xml.ValidationException vex) {
266             return false;
267         }
268         return true;
269     }
270
271     /**
272      * 
273      * 
274      * @param out
275      * @throws org.exolab.castor.xml.MarshalException if object is
276      * null or if any SAXException is thrown during marshaling
277      * @throws org.exolab.castor.xml.ValidationException if this
278      * object is an invalid instance according to the schema
279      */
280     public void marshal(
281             final java.io.Writer out)
282     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
283         Marshaller.marshal(this, out);
284     }
285
286     /**
287      * 
288      * 
289      * @param handler
290      * @throws java.io.IOException if an IOException occurs during
291      * marshaling
292      * @throws org.exolab.castor.xml.ValidationException if this
293      * object is an invalid instance according to the schema
294      * @throws org.exolab.castor.xml.MarshalException if object is
295      * null or if any SAXException is thrown during marshaling
296      */
297     public void marshal(
298             final org.xml.sax.ContentHandler handler)
299     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
300         Marshaller.marshal(this, handler);
301     }
302
303     /**
304      * Method removeAlignmentSequenceAnnotation.
305      * 
306      * @param vAlignmentSequenceAnnotation
307      * @return true if the object was removed from the collection.
308      */
309     public boolean removeAlignmentSequenceAnnotation(
310             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation) {
311         boolean removed = _alignmentSequenceAnnotationList.remove(vAlignmentSequenceAnnotation);
312         return removed;
313     }
314
315     /**
316      * Method removeAlignmentSequenceAnnotationAt.
317      * 
318      * @param index
319      * @return the element removed from the collection
320      */
321     public uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation removeAlignmentSequenceAnnotationAt(
322             final int index) {
323         java.lang.Object obj = this._alignmentSequenceAnnotationList.remove(index);
324         return (uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation) obj;
325     }
326
327     /**
328      */
329     public void removeAllAlignmentSequenceAnnotation(
330     ) {
331         this._alignmentSequenceAnnotationList.clear();
332     }
333
334     /**
335      * 
336      * 
337      * @param index
338      * @param vAlignmentSequenceAnnotation
339      * @throws java.lang.IndexOutOfBoundsException if the index
340      * given is outside the bounds of the collection
341      */
342     public void setAlignmentSequenceAnnotation(
343             final int index,
344             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation vAlignmentSequenceAnnotation)
345     throws java.lang.IndexOutOfBoundsException {
346         // check bounds for index
347         if (index < 0 || index >= this._alignmentSequenceAnnotationList.size()) {
348             throw new IndexOutOfBoundsException("setAlignmentSequenceAnnotation: Index value '" + index + "' not in range [0.." + (this._alignmentSequenceAnnotationList.size() - 1) + "]");
349         }
350         
351         this._alignmentSequenceAnnotationList.set(index, vAlignmentSequenceAnnotation);
352     }
353
354     /**
355      * 
356      * 
357      * @param vAlignmentSequenceAnnotationArray
358      */
359     public void setAlignmentSequenceAnnotation(
360             final uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation[] vAlignmentSequenceAnnotationArray) {
361         //-- copy array
362         _alignmentSequenceAnnotationList.clear();
363         
364         for (int i = 0; i < vAlignmentSequenceAnnotationArray.length; i++) {
365                 this._alignmentSequenceAnnotationList.add(vAlignmentSequenceAnnotationArray[i]);
366         }
367     }
368
369     /**
370      * Sets the value of '_alignmentSequenceAnnotationList' by
371      * copying the given Vector. All elements will be checked for
372      * type safety.
373      * 
374      * @param vAlignmentSequenceAnnotationList the Vector to copy.
375      */
376     public void setAlignmentSequenceAnnotation(
377             final java.util.Vector vAlignmentSequenceAnnotationList) {
378         // copy vector
379         this._alignmentSequenceAnnotationList.clear();
380         
381         this._alignmentSequenceAnnotationList.addAll(vAlignmentSequenceAnnotationList);
382     }
383
384     /**
385      * Sets the value of '_alignmentSequenceAnnotationList' by
386      * setting it to the given Vector. No type checking is
387      * performed.
388      * @deprecated
389      * 
390      * @param alignmentSequenceAnnotationVector the Vector to set.
391      */
392     public void setAlignmentSequenceAnnotationAsReference(
393             final java.util.Vector alignmentSequenceAnnotationVector) {
394         this._alignmentSequenceAnnotationList = alignmentSequenceAnnotationVector;
395     }
396
397     /**
398      * Sets the value of field 'id'. The field 'id' has the
399      * following description: Primary Key for vamsas object
400      *  referencing 
401      * 
402      * @param id the value of field 'id'.
403      */
404     public void setId(
405             final java.lang.String id) {
406         this._id = id;
407     }
408
409     /**
410      * Sets the value of field 'refid'. The field 'refid' has the
411      * following description: Dataset Sequence from which
412      *  this alignment sequence is taken from
413      *  
414      * 
415      * @param refid the value of field 'refid'.
416      */
417     public void setRefid(
418             final java.lang.Object refid) {
419         this._refid = refid;
420     }
421
422     /**
423      * Method unmarshal.
424      * 
425      * @param reader
426      * @throws org.exolab.castor.xml.MarshalException if object is
427      * null or if any SAXException is thrown during marshaling
428      * @throws org.exolab.castor.xml.ValidationException if this
429      * object is an invalid instance according to the schema
430      * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
431      */
432     public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
433             final java.io.Reader reader)
434     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
435         return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentSequence.class, reader);
436     }
437
438     /**
439      * 
440      * 
441      * @throws org.exolab.castor.xml.ValidationException if this
442      * object is an invalid instance according to the schema
443      */
444     public void validate(
445     )
446     throws org.exolab.castor.xml.ValidationException {
447         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
448         validator.validate(this);
449     }
450
451 }