schema changes: provenance-entry-date is now an xmlSchema:dateTime bound directly...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Sequence.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 Sequence.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class Sequence 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 referencing
33      *  
34      */
35     private java.lang.String _id;
36
37     /**
38      * symbol class for sequence
39      *  
40      */
41     private java.lang.String _dictionary;
42
43     /**
44      * Store a list of database references
45      *  for this sequence record - with optional mapping
46      *  from database sequence to the given sequence record 
47      */
48     private java.util.Vector _dbRefList;
49
50     /**
51      * explicitly named cross reference to other objects in the
52      * document.
53      *  
54      */
55     private java.util.Vector _vxrefList;
56
57
58       //----------------/
59      //- Constructors -/
60     //----------------/
61
62     public Sequence() {
63         super();
64         this._dbRefList = new java.util.Vector();
65         this._vxrefList = new java.util.Vector();
66     }
67
68
69       //-----------/
70      //- Methods -/
71     //-----------/
72
73     /**
74      * 
75      * 
76      * @param vDbRef
77      * @throws java.lang.IndexOutOfBoundsException if the index
78      * given is outside the bounds of the collection
79      */
80     public void addDbRef(
81             final uk.ac.vamsas.objects.core.DbRef vDbRef)
82     throws java.lang.IndexOutOfBoundsException {
83         this._dbRefList.addElement(vDbRef);
84     }
85
86     /**
87      * 
88      * 
89      * @param index
90      * @param vDbRef
91      * @throws java.lang.IndexOutOfBoundsException if the index
92      * given is outside the bounds of the collection
93      */
94     public void addDbRef(
95             final int index,
96             final uk.ac.vamsas.objects.core.DbRef vDbRef)
97     throws java.lang.IndexOutOfBoundsException {
98         this._dbRefList.add(index, vDbRef);
99     }
100
101     /**
102      * 
103      * 
104      * @param vVxref
105      * @throws java.lang.IndexOutOfBoundsException if the index
106      * given is outside the bounds of the collection
107      */
108     public void addVxref(
109             final uk.ac.vamsas.objects.core.Vxref vVxref)
110     throws java.lang.IndexOutOfBoundsException {
111         this._vxrefList.addElement(vVxref);
112     }
113
114     /**
115      * 
116      * 
117      * @param index
118      * @param vVxref
119      * @throws java.lang.IndexOutOfBoundsException if the index
120      * given is outside the bounds of the collection
121      */
122     public void addVxref(
123             final int index,
124             final uk.ac.vamsas.objects.core.Vxref vVxref)
125     throws java.lang.IndexOutOfBoundsException {
126         this._vxrefList.add(index, vVxref);
127     }
128
129     /**
130      * Method enumerateDbRef.
131      * 
132      * @return an Enumeration over all
133      * uk.ac.vamsas.objects.core.DbRef elements
134      */
135     public java.util.Enumeration enumerateDbRef(
136     ) {
137         return this._dbRefList.elements();
138     }
139
140     /**
141      * Method enumerateVxref.
142      * 
143      * @return an Enumeration over all
144      * uk.ac.vamsas.objects.core.Vxref elements
145      */
146     public java.util.Enumeration enumerateVxref(
147     ) {
148         return this._vxrefList.elements();
149     }
150
151     /**
152      * Overrides the java.lang.Object.equals method.
153      * 
154      * @param obj
155      * @return true if the objects are equal.
156      */
157     public boolean equals(
158             final java.lang.Object obj) {
159         if ( this == obj )
160             return true;
161         
162         if (super.equals(obj)==false)
163             return false;
164         
165         if (obj instanceof Sequence) {
166         
167             Sequence temp = (Sequence)obj;
168             if (this._id != null) {
169                 if (temp._id == null) return false;
170                 else if (!(this._id.equals(temp._id))) 
171                     return false;
172             }
173             else if (temp._id != null)
174                 return false;
175             if (this._dictionary != null) {
176                 if (temp._dictionary == null) return false;
177                 else if (!(this._dictionary.equals(temp._dictionary))) 
178                     return false;
179             }
180             else if (temp._dictionary != null)
181                 return false;
182             if (this._dbRefList != null) {
183                 if (temp._dbRefList == null) return false;
184                 else if (!(this._dbRefList.equals(temp._dbRefList))) 
185                     return false;
186             }
187             else if (temp._dbRefList != null)
188                 return false;
189             if (this._vxrefList != null) {
190                 if (temp._vxrefList == null) return false;
191                 else if (!(this._vxrefList.equals(temp._vxrefList))) 
192                     return false;
193             }
194             else if (temp._vxrefList != null)
195                 return false;
196             return true;
197         }
198         return false;
199     }
200
201     /**
202      * Method getDbRef.
203      * 
204      * @param index
205      * @throws java.lang.IndexOutOfBoundsException if the index
206      * given is outside the bounds of the collection
207      * @return the value of the uk.ac.vamsas.objects.core.DbRef at
208      * the given index
209      */
210     public uk.ac.vamsas.objects.core.DbRef getDbRef(
211             final int index)
212     throws java.lang.IndexOutOfBoundsException {
213         // check bounds for index
214         if (index < 0 || index >= this._dbRefList.size()) {
215             throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
216         }
217         
218         return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index);
219     }
220
221     /**
222      * Method getDbRef.Returns the contents of the collection in an
223      * Array.  <p>Note:  Just in case the collection contents are
224      * changing in another thread, we pass a 0-length Array of the
225      * correct type into the API call.  This way we <i>know</i>
226      * that the Array returned is of exactly the correct length.
227      * 
228      * @return this collection as an Array
229      */
230     public uk.ac.vamsas.objects.core.DbRef[] getDbRef(
231     ) {
232         uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0];
233         return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array);
234     }
235
236     /**
237      * Method getDbRefAsReference.Returns a reference to
238      * '_dbRefList'. No type checking is performed on any
239      * modifications to the Vector.
240      * 
241      * @return a reference to the Vector backing this class
242      */
243     public java.util.Vector getDbRefAsReference(
244     ) {
245         return this._dbRefList;
246     }
247
248     /**
249      * Method getDbRefCount.
250      * 
251      * @return the size of this collection
252      */
253     public int getDbRefCount(
254     ) {
255         return this._dbRefList.size();
256     }
257
258     /**
259      * Returns the value of field 'dictionary'. The field
260      * 'dictionary' has the following description: symbol class for
261      * sequence
262      *  
263      * 
264      * @return the value of field 'Dictionary'.
265      */
266     public java.lang.String getDictionary(
267     ) {
268         return this._dictionary;
269     }
270
271     /**
272      * Returns the value of field 'id'. The field 'id' has the
273      * following description: Primary Key for vamsas object
274      * referencing
275      *  
276      * 
277      * @return the value of field 'Id'.
278      */
279     public java.lang.String getId(
280     ) {
281         return this._id;
282     }
283
284     /**
285      * Method getVxref.
286      * 
287      * @param index
288      * @throws java.lang.IndexOutOfBoundsException if the index
289      * given is outside the bounds of the collection
290      * @return the value of the uk.ac.vamsas.objects.core.Vxref at
291      * the given index
292      */
293     public uk.ac.vamsas.objects.core.Vxref getVxref(
294             final int index)
295     throws java.lang.IndexOutOfBoundsException {
296         // check bounds for index
297         if (index < 0 || index >= this._vxrefList.size()) {
298             throw new IndexOutOfBoundsException("getVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]");
299         }
300         
301         return (uk.ac.vamsas.objects.core.Vxref) _vxrefList.get(index);
302     }
303
304     /**
305      * Method getVxref.Returns the contents of the collection in an
306      * Array.  <p>Note:  Just in case the collection contents are
307      * changing in another thread, we pass a 0-length Array of the
308      * correct type into the API call.  This way we <i>know</i>
309      * that the Array returned is of exactly the correct length.
310      * 
311      * @return this collection as an Array
312      */
313     public uk.ac.vamsas.objects.core.Vxref[] getVxref(
314     ) {
315         uk.ac.vamsas.objects.core.Vxref[] array = new uk.ac.vamsas.objects.core.Vxref[0];
316         return (uk.ac.vamsas.objects.core.Vxref[]) this._vxrefList.toArray(array);
317     }
318
319     /**
320      * Method getVxrefAsReference.Returns a reference to
321      * '_vxrefList'. No type checking is performed on any
322      * modifications to the Vector.
323      * 
324      * @return a reference to the Vector backing this class
325      */
326     public java.util.Vector getVxrefAsReference(
327     ) {
328         return this._vxrefList;
329     }
330
331     /**
332      * Method getVxrefCount.
333      * 
334      * @return the size of this collection
335      */
336     public int getVxrefCount(
337     ) {
338         return this._vxrefList.size();
339     }
340
341     /**
342      * Overrides the java.lang.Object.hashCode method.
343      * <p>
344      * The following steps came from <b>Effective Java Programming
345      * Language Guide</b> by Joshua Bloch, Chapter 3
346      * 
347      * @return a hash code value for the object.
348      */
349     public int hashCode(
350     ) {
351         int result = super.hashCode();
352         
353         long tmp;
354         if (_id != null) {
355            result = 37 * result + _id.hashCode();
356         }
357         if (_dictionary != null) {
358            result = 37 * result + _dictionary.hashCode();
359         }
360         if (_dbRefList != null) {
361            result = 37 * result + _dbRefList.hashCode();
362         }
363         if (_vxrefList != null) {
364            result = 37 * result + _vxrefList.hashCode();
365         }
366         
367         return result;
368     }
369
370     /**
371      * Method isValid.
372      * 
373      * @return true if this object is valid according to the schema
374      */
375     public boolean isValid(
376     ) {
377         try {
378             validate();
379         } catch (org.exolab.castor.xml.ValidationException vex) {
380             return false;
381         }
382         return true;
383     }
384
385     /**
386      * 
387      * 
388      * @param out
389      * @throws org.exolab.castor.xml.MarshalException if object is
390      * null or if any SAXException is thrown during marshaling
391      * @throws org.exolab.castor.xml.ValidationException if this
392      * object is an invalid instance according to the schema
393      */
394     public void marshal(
395             final java.io.Writer out)
396     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
397         Marshaller.marshal(this, out);
398     }
399
400     /**
401      * 
402      * 
403      * @param handler
404      * @throws java.io.IOException if an IOException occurs during
405      * marshaling
406      * @throws org.exolab.castor.xml.ValidationException if this
407      * object is an invalid instance according to the schema
408      * @throws org.exolab.castor.xml.MarshalException if object is
409      * null or if any SAXException is thrown during marshaling
410      */
411     public void marshal(
412             final org.xml.sax.ContentHandler handler)
413     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
414         Marshaller.marshal(this, handler);
415     }
416
417     /**
418      */
419     public void removeAllDbRef(
420     ) {
421         this._dbRefList.clear();
422     }
423
424     /**
425      */
426     public void removeAllVxref(
427     ) {
428         this._vxrefList.clear();
429     }
430
431     /**
432      * Method removeDbRef.
433      * 
434      * @param vDbRef
435      * @return true if the object was removed from the collection.
436      */
437     public boolean removeDbRef(
438             final uk.ac.vamsas.objects.core.DbRef vDbRef) {
439         boolean removed = _dbRefList.remove(vDbRef);
440         return removed;
441     }
442
443     /**
444      * Method removeDbRefAt.
445      * 
446      * @param index
447      * @return the element removed from the collection
448      */
449     public uk.ac.vamsas.objects.core.DbRef removeDbRefAt(
450             final int index) {
451         java.lang.Object obj = this._dbRefList.remove(index);
452         return (uk.ac.vamsas.objects.core.DbRef) obj;
453     }
454
455     /**
456      * Method removeVxref.
457      * 
458      * @param vVxref
459      * @return true if the object was removed from the collection.
460      */
461     public boolean removeVxref(
462             final uk.ac.vamsas.objects.core.Vxref vVxref) {
463         boolean removed = _vxrefList.remove(vVxref);
464         return removed;
465     }
466
467     /**
468      * Method removeVxrefAt.
469      * 
470      * @param index
471      * @return the element removed from the collection
472      */
473     public uk.ac.vamsas.objects.core.Vxref removeVxrefAt(
474             final int index) {
475         java.lang.Object obj = this._vxrefList.remove(index);
476         return (uk.ac.vamsas.objects.core.Vxref) obj;
477     }
478
479     /**
480      * 
481      * 
482      * @param index
483      * @param vDbRef
484      * @throws java.lang.IndexOutOfBoundsException if the index
485      * given is outside the bounds of the collection
486      */
487     public void setDbRef(
488             final int index,
489             final uk.ac.vamsas.objects.core.DbRef vDbRef)
490     throws java.lang.IndexOutOfBoundsException {
491         // check bounds for index
492         if (index < 0 || index >= this._dbRefList.size()) {
493             throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
494         }
495         
496         this._dbRefList.set(index, vDbRef);
497     }
498
499     /**
500      * 
501      * 
502      * @param vDbRefArray
503      */
504     public void setDbRef(
505             final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) {
506         //-- copy array
507         _dbRefList.clear();
508         
509         for (int i = 0; i < vDbRefArray.length; i++) {
510                 this._dbRefList.add(vDbRefArray[i]);
511         }
512     }
513
514     /**
515      * Sets the value of '_dbRefList' by copying the given Vector.
516      * All elements will be checked for type safety.
517      * 
518      * @param vDbRefList the Vector to copy.
519      */
520     public void setDbRef(
521             final java.util.Vector vDbRefList) {
522         // copy vector
523         this._dbRefList.clear();
524         
525         this._dbRefList.addAll(vDbRefList);
526     }
527
528     /**
529      * Sets the value of '_dbRefList' by setting it to the given
530      * Vector. No type checking is performed.
531      * @deprecated
532      * 
533      * @param dbRefVector the Vector to set.
534      */
535     public void setDbRefAsReference(
536             final java.util.Vector dbRefVector) {
537         this._dbRefList = dbRefVector;
538     }
539
540     /**
541      * Sets the value of field 'dictionary'. The field 'dictionary'
542      * has the following description: symbol class for sequence
543      *  
544      * 
545      * @param dictionary the value of field 'dictionary'.
546      */
547     public void setDictionary(
548             final java.lang.String dictionary) {
549         this._dictionary = dictionary;
550     }
551
552     /**
553      * Sets the value of field 'id'. The field 'id' has the
554      * following description: Primary Key for vamsas object
555      * referencing
556      *  
557      * 
558      * @param id the value of field 'id'.
559      */
560     public void setId(
561             final java.lang.String id) {
562         this._id = id;
563     }
564
565     /**
566      * 
567      * 
568      * @param index
569      * @param vVxref
570      * @throws java.lang.IndexOutOfBoundsException if the index
571      * given is outside the bounds of the collection
572      */
573     public void setVxref(
574             final int index,
575             final uk.ac.vamsas.objects.core.Vxref vVxref)
576     throws java.lang.IndexOutOfBoundsException {
577         // check bounds for index
578         if (index < 0 || index >= this._vxrefList.size()) {
579             throw new IndexOutOfBoundsException("setVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]");
580         }
581         
582         this._vxrefList.set(index, vVxref);
583     }
584
585     /**
586      * 
587      * 
588      * @param vVxrefArray
589      */
590     public void setVxref(
591             final uk.ac.vamsas.objects.core.Vxref[] vVxrefArray) {
592         //-- copy array
593         _vxrefList.clear();
594         
595         for (int i = 0; i < vVxrefArray.length; i++) {
596                 this._vxrefList.add(vVxrefArray[i]);
597         }
598     }
599
600     /**
601      * Sets the value of '_vxrefList' by copying the given Vector.
602      * All elements will be checked for type safety.
603      * 
604      * @param vVxrefList the Vector to copy.
605      */
606     public void setVxref(
607             final java.util.Vector vVxrefList) {
608         // copy vector
609         this._vxrefList.clear();
610         
611         this._vxrefList.addAll(vVxrefList);
612     }
613
614     /**
615      * Sets the value of '_vxrefList' by setting it to the given
616      * Vector. No type checking is performed.
617      * @deprecated
618      * 
619      * @param vxrefVector the Vector to set.
620      */
621     public void setVxrefAsReference(
622             final java.util.Vector vxrefVector) {
623         this._vxrefList = vxrefVector;
624     }
625
626     /**
627      * Method unmarshal.
628      * 
629      * @param reader
630      * @throws org.exolab.castor.xml.MarshalException if object is
631      * null or if any SAXException is thrown during marshaling
632      * @throws org.exolab.castor.xml.ValidationException if this
633      * object is an invalid instance according to the schema
634      * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
635      */
636     public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
637             final java.io.Reader reader)
638     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
639         return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
640     }
641
642     /**
643      * 
644      * 
645      * @throws org.exolab.castor.xml.ValidationException if this
646      * object is an invalid instance according to the schema
647      */
648     public void validate(
649     )
650     throws org.exolab.castor.xml.ValidationException {
651         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
652         validator.validate(this);
653     }
654
655 }