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