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