cyclic IDREF patched castor-1.1.1 source
[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             if (this._version != null) {
169                 if (temp._version == null) return false;
170                 else if (!(this._version.equals(temp._version))) 
171                     return false;
172             }
173             else if (temp._version != null)
174                 return false;
175             if (this._name != null) {
176                 if (temp._name == null) return false;
177                 else if (!(this._name.equals(temp._name))) 
178                     return false;
179             }
180             else if (temp._name != null)
181                 return false;
182             if (this._userList != null) {
183                 if (temp._userList == null) return false;
184                 else if (!(this._userList.equals(temp._userList))) 
185                     return false;
186             }
187             else if (temp._userList != null)
188                 return false;
189             if (this._common != null) {
190                 if (temp._common == null) return false;
191                 else if (!(this._common.equals(temp._common))) 
192                     return false;
193             }
194             else if (temp._common != null)
195                 return false;
196             if (this._instanceList != null) {
197                 if (temp._instanceList == null) return false;
198                 else if (!(this._instanceList.equals(temp._instanceList))) 
199                     return false;
200             }
201             else if (temp._instanceList != null)
202                 return false;
203             return true;
204         }
205         return false;
206     }
207
208     /**
209      * Returns the value of field 'common'.
210      * 
211      * @return the value of field 'Common'.
212      */
213     public uk.ac.vamsas.objects.core.Common getCommon(
214     ) {
215         return this._common;
216     }
217
218     /**
219      * Method getInstance.
220      * 
221      * @param index
222      * @throws java.lang.IndexOutOfBoundsException if the index
223      * given is outside the bounds of the collection
224      * @return the value of the uk.ac.vamsas.objects.core.Instance
225      * at the given index
226      */
227     public uk.ac.vamsas.objects.core.Instance getInstance(
228             final int index)
229     throws java.lang.IndexOutOfBoundsException {
230         // check bounds for index
231         if (index < 0 || index >= this._instanceList.size()) {
232             throw new IndexOutOfBoundsException("getInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]");
233         }
234         
235         return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index);
236     }
237
238     /**
239      * Method getInstance.Returns the contents of the collection in
240      * an Array.  <p>Note:  Just in case the collection contents
241      * are changing in another thread, we pass a 0-length Array of
242      * the correct type into the API call.  This way we <i>know</i>
243      * that the Array returned is of exactly the correct length.
244      * 
245      * @return this collection as an Array
246      */
247     public uk.ac.vamsas.objects.core.Instance[] getInstance(
248     ) {
249         uk.ac.vamsas.objects.core.Instance[] array = new uk.ac.vamsas.objects.core.Instance[0];
250         return (uk.ac.vamsas.objects.core.Instance[]) this._instanceList.toArray(array);
251     }
252
253     /**
254      * Method getInstanceAsReference.Returns a reference to
255      * '_instanceList'. No type checking is performed on any
256      * modifications to the Vector.
257      * 
258      * @return a reference to the Vector backing this class
259      */
260     public java.util.Vector getInstanceAsReference(
261     ) {
262         return this._instanceList;
263     }
264
265     /**
266      * Method getInstanceCount.
267      * 
268      * @return the size of this collection
269      */
270     public int getInstanceCount(
271     ) {
272         return this._instanceList.size();
273     }
274
275     /**
276      * Returns the value of field 'name'. The field 'name' has the
277      * following description: Canonical name of application 
278      * 
279      * @return the value of field 'Name'.
280      */
281     public java.lang.String getName(
282     ) {
283         return this._name;
284     }
285
286     /**
287      * Method getUser.
288      * 
289      * @param index
290      * @throws java.lang.IndexOutOfBoundsException if the index
291      * given is outside the bounds of the collection
292      * @return the value of the uk.ac.vamsas.objects.core.User at
293      * the given index
294      */
295     public uk.ac.vamsas.objects.core.User getUser(
296             final int index)
297     throws java.lang.IndexOutOfBoundsException {
298         // check bounds for index
299         if (index < 0 || index >= this._userList.size()) {
300             throw new IndexOutOfBoundsException("getUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]");
301         }
302         
303         return (uk.ac.vamsas.objects.core.User) _userList.get(index);
304     }
305
306     /**
307      * Method getUser.Returns the contents of the collection in an
308      * Array.  <p>Note:  Just in case the collection contents are
309      * changing in another thread, we pass a 0-length Array of the
310      * correct type into the API call.  This way we <i>know</i>
311      * that the Array returned is of exactly the correct length.
312      * 
313      * @return this collection as an Array
314      */
315     public uk.ac.vamsas.objects.core.User[] getUser(
316     ) {
317         uk.ac.vamsas.objects.core.User[] array = new uk.ac.vamsas.objects.core.User[0];
318         return (uk.ac.vamsas.objects.core.User[]) this._userList.toArray(array);
319     }
320
321     /**
322      * Method getUserAsReference.Returns a reference to
323      * '_userList'. No type checking is performed on any
324      * modifications to the Vector.
325      * 
326      * @return a reference to the Vector backing this class
327      */
328     public java.util.Vector getUserAsReference(
329     ) {
330         return this._userList;
331     }
332
333     /**
334      * Method getUserCount.
335      * 
336      * @return the size of this collection
337      */
338     public int getUserCount(
339     ) {
340         return this._userList.size();
341     }
342
343     /**
344      * Returns the value of field 'version'. The field 'version'
345      * has the following description: Version string describing the
346      * application specific
347      *  data storage version used
348      * 
349      * @return the value of field 'Version'.
350      */
351     public java.lang.String getVersion(
352     ) {
353         return this._version;
354     }
355
356     /**
357      * Overrides the java.lang.Object.hashCode method.
358      * <p>
359      * The following steps came from <b>Effective Java Programming
360      * Language Guide</b> by Joshua Bloch, Chapter 3
361      * 
362      * @return a hash code value for the object.
363      */
364     public int hashCode(
365     ) {
366         int result = super.hashCode();
367         
368         long tmp;
369         if (_version != null) {
370            result = 37 * result + _version.hashCode();
371         }
372         if (_name != null) {
373            result = 37 * result + _name.hashCode();
374         }
375         if (_userList != null) {
376            result = 37 * result + _userList.hashCode();
377         }
378         if (_common != null) {
379            result = 37 * result + _common.hashCode();
380         }
381         if (_instanceList != null) {
382            result = 37 * result + _instanceList.hashCode();
383         }
384         
385         return result;
386     }
387
388     /**
389      * Method isValid.
390      * 
391      * @return true if this object is valid according to the schema
392      */
393     public boolean isValid(
394     ) {
395         try {
396             validate();
397         } catch (org.exolab.castor.xml.ValidationException vex) {
398             return false;
399         }
400         return true;
401     }
402
403     /**
404      * 
405      * 
406      * @param out
407      * @throws org.exolab.castor.xml.MarshalException if object is
408      * null or if any SAXException is thrown during marshaling
409      * @throws org.exolab.castor.xml.ValidationException if this
410      * object is an invalid instance according to the schema
411      */
412     public void marshal(
413             final java.io.Writer out)
414     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
415         Marshaller.marshal(this, out);
416     }
417
418     /**
419      * 
420      * 
421      * @param handler
422      * @throws java.io.IOException if an IOException occurs during
423      * marshaling
424      * @throws org.exolab.castor.xml.ValidationException if this
425      * object is an invalid instance according to the schema
426      * @throws org.exolab.castor.xml.MarshalException if object is
427      * null or if any SAXException is thrown during marshaling
428      */
429     public void marshal(
430             final org.xml.sax.ContentHandler handler)
431     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
432         Marshaller.marshal(this, handler);
433     }
434
435     /**
436      */
437     public void removeAllInstance(
438     ) {
439         this._instanceList.clear();
440     }
441
442     /**
443      */
444     public void removeAllUser(
445     ) {
446         this._userList.clear();
447     }
448
449     /**
450      * Method removeInstance.
451      * 
452      * @param vInstance
453      * @return true if the object was removed from the collection.
454      */
455     public boolean removeInstance(
456             final uk.ac.vamsas.objects.core.Instance vInstance) {
457         boolean removed = _instanceList.remove(vInstance);
458         return removed;
459     }
460
461     /**
462      * Method removeInstanceAt.
463      * 
464      * @param index
465      * @return the element removed from the collection
466      */
467     public uk.ac.vamsas.objects.core.Instance removeInstanceAt(
468             final int index) {
469         java.lang.Object obj = this._instanceList.remove(index);
470         return (uk.ac.vamsas.objects.core.Instance) obj;
471     }
472
473     /**
474      * Method removeUser.
475      * 
476      * @param vUser
477      * @return true if the object was removed from the collection.
478      */
479     public boolean removeUser(
480             final uk.ac.vamsas.objects.core.User vUser) {
481         boolean removed = _userList.remove(vUser);
482         return removed;
483     }
484
485     /**
486      * Method removeUserAt.
487      * 
488      * @param index
489      * @return the element removed from the collection
490      */
491     public uk.ac.vamsas.objects.core.User removeUserAt(
492             final int index) {
493         java.lang.Object obj = this._userList.remove(index);
494         return (uk.ac.vamsas.objects.core.User) obj;
495     }
496
497     /**
498      * Sets the value of field 'common'.
499      * 
500      * @param common the value of field 'common'.
501      */
502     public void setCommon(
503             final uk.ac.vamsas.objects.core.Common common) {
504         this._common = common;
505     }
506
507     /**
508      * 
509      * 
510      * @param index
511      * @param vInstance
512      * @throws java.lang.IndexOutOfBoundsException if the index
513      * given is outside the bounds of the collection
514      */
515     public void setInstance(
516             final int index,
517             final uk.ac.vamsas.objects.core.Instance vInstance)
518     throws java.lang.IndexOutOfBoundsException {
519         // check bounds for index
520         if (index < 0 || index >= this._instanceList.size()) {
521             throw new IndexOutOfBoundsException("setInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]");
522         }
523         
524         this._instanceList.set(index, vInstance);
525     }
526
527     /**
528      * 
529      * 
530      * @param vInstanceArray
531      */
532     public void setInstance(
533             final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) {
534         //-- copy array
535         _instanceList.clear();
536         
537         for (int i = 0; i < vInstanceArray.length; i++) {
538                 this._instanceList.add(vInstanceArray[i]);
539         }
540     }
541
542     /**
543      * Sets the value of '_instanceList' by copying the given
544      * Vector. All elements will be checked for type safety.
545      * 
546      * @param vInstanceList the Vector to copy.
547      */
548     public void setInstance(
549             final java.util.Vector vInstanceList) {
550         // copy vector
551         this._instanceList.clear();
552         
553         this._instanceList.addAll(vInstanceList);
554     }
555
556     /**
557      * Sets the value of '_instanceList' by setting it to the given
558      * Vector. No type checking is performed.
559      * @deprecated
560      * 
561      * @param instanceVector the Vector to set.
562      */
563     public void setInstanceAsReference(
564             final java.util.Vector instanceVector) {
565         this._instanceList = instanceVector;
566     }
567
568     /**
569      * Sets the value of field 'name'. The field 'name' has the
570      * following description: Canonical name of application 
571      * 
572      * @param name the value of field 'name'.
573      */
574     public void setName(
575             final java.lang.String name) {
576         this._name = name;
577     }
578
579     /**
580      * 
581      * 
582      * @param index
583      * @param vUser
584      * @throws java.lang.IndexOutOfBoundsException if the index
585      * given is outside the bounds of the collection
586      */
587     public void setUser(
588             final int index,
589             final uk.ac.vamsas.objects.core.User vUser)
590     throws java.lang.IndexOutOfBoundsException {
591         // check bounds for index
592         if (index < 0 || index >= this._userList.size()) {
593             throw new IndexOutOfBoundsException("setUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]");
594         }
595         
596         this._userList.set(index, vUser);
597     }
598
599     /**
600      * 
601      * 
602      * @param vUserArray
603      */
604     public void setUser(
605             final uk.ac.vamsas.objects.core.User[] vUserArray) {
606         //-- copy array
607         _userList.clear();
608         
609         for (int i = 0; i < vUserArray.length; i++) {
610                 this._userList.add(vUserArray[i]);
611         }
612     }
613
614     /**
615      * Sets the value of '_userList' by copying the given Vector.
616      * All elements will be checked for type safety.
617      * 
618      * @param vUserList the Vector to copy.
619      */
620     public void setUser(
621             final java.util.Vector vUserList) {
622         // copy vector
623         this._userList.clear();
624         
625         this._userList.addAll(vUserList);
626     }
627
628     /**
629      * Sets the value of '_userList' by setting it to the given
630      * Vector. No type checking is performed.
631      * @deprecated
632      * 
633      * @param userVector the Vector to set.
634      */
635     public void setUserAsReference(
636             final java.util.Vector userVector) {
637         this._userList = userVector;
638     }
639
640     /**
641      * Sets the value of field 'version'. The field 'version' has
642      * the following description: Version string describing the
643      * application specific
644      *  data storage version used
645      * 
646      * @param version the value of field 'version'.
647      */
648     public void setVersion(
649             final java.lang.String version) {
650         this._version = version;
651     }
652
653     /**
654      * Method unmarshal.
655      * 
656      * @param reader
657      * @throws org.exolab.castor.xml.MarshalException if object is
658      * null or if any SAXException is thrown during marshaling
659      * @throws org.exolab.castor.xml.ValidationException if this
660      * object is an invalid instance according to the schema
661      * @return the unmarshaled uk.ac.vamsas.objects.core.AppData
662      */
663     public static uk.ac.vamsas.objects.core.AppData unmarshal(
664             final java.io.Reader reader)
665     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
666         return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ApplicationData.class, reader);
667     }
668
669     /**
670      * 
671      * 
672      * @throws org.exolab.castor.xml.ValidationException if this
673      * object is an invalid instance according to the schema
674      */
675     public void validate(
676     )
677     throws org.exolab.castor.xml.ValidationException {
678         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
679         validator.validate(this);
680     }
681
682 }