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