refactored org to uk
[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 0.9.9M2</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 java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /**
27  * Class ApplicationData.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class ApplicationData extends uk.ac.vamsas.objects.core.AppData 
32 implements java.io.Serializable
33 {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * Version string describing the application specific
42      *  data storage version used
43      */
44     private java.lang.String _version;
45
46     /**
47      * Canonical name of application 
48      */
49     private java.lang.String _name;
50
51     /**
52      * Field _userList
53      */
54     private java.util.Vector _userList;
55
56     /**
57      * Field _common
58      */
59     private uk.ac.vamsas.objects.core.Common _common;
60
61     /**
62      * Field _instanceList
63      */
64     private java.util.Vector _instanceList;
65
66
67       //----------------/
68      //- Constructors -/
69     //----------------/
70
71     public ApplicationData() 
72      {
73         super();
74         _userList = new Vector();
75         _instanceList = new Vector();
76     } //-- uk.ac.vamsas.objects.core.ApplicationData()
77
78
79       //-----------/
80      //- Methods -/
81     //-----------/
82
83     /**
84      * Method addInstance
85      * 
86      * 
87      * 
88      * @param vInstance
89      */
90     public void addInstance(uk.ac.vamsas.objects.core.Instance vInstance)
91         throws java.lang.IndexOutOfBoundsException
92     {
93         _instanceList.addElement(vInstance);
94     } //-- void addInstance(uk.ac.vamsas.objects.core.Instance) 
95
96     /**
97      * Method addInstance
98      * 
99      * 
100      * 
101      * @param index
102      * @param vInstance
103      */
104     public void addInstance(int index, uk.ac.vamsas.objects.core.Instance vInstance)
105         throws java.lang.IndexOutOfBoundsException
106     {
107         _instanceList.insertElementAt(vInstance, index);
108     } //-- void addInstance(int, uk.ac.vamsas.objects.core.Instance) 
109
110     /**
111      * Method addUser
112      * 
113      * 
114      * 
115      * @param vUser
116      */
117     public void addUser(uk.ac.vamsas.objects.core.User vUser)
118         throws java.lang.IndexOutOfBoundsException
119     {
120         _userList.addElement(vUser);
121     } //-- void addUser(uk.ac.vamsas.objects.core.User) 
122
123     /**
124      * Method addUser
125      * 
126      * 
127      * 
128      * @param index
129      * @param vUser
130      */
131     public void addUser(int index, uk.ac.vamsas.objects.core.User vUser)
132         throws java.lang.IndexOutOfBoundsException
133     {
134         _userList.insertElementAt(vUser, index);
135     } //-- void addUser(int, uk.ac.vamsas.objects.core.User) 
136
137     /**
138      * Method enumerateInstance
139      * 
140      * 
141      * 
142      * @return Enumeration
143      */
144     public java.util.Enumeration enumerateInstance()
145     {
146         return _instanceList.elements();
147     } //-- java.util.Enumeration enumerateInstance() 
148
149     /**
150      * Method enumerateUser
151      * 
152      * 
153      * 
154      * @return Enumeration
155      */
156     public java.util.Enumeration enumerateUser()
157     {
158         return _userList.elements();
159     } //-- java.util.Enumeration enumerateUser() 
160
161     /**
162      * Note: hashCode() has not been overriden
163      * 
164      * @param obj
165      * @return boolean
166      */
167     public boolean equals(java.lang.Object obj)
168     {
169         if ( this == obj )
170             return true;
171         
172         if (super.equals(obj)==false)
173             return false;
174         
175         if (obj instanceof ApplicationData) {
176         
177             ApplicationData temp = (ApplicationData)obj;
178             if (this._version != null) {
179                 if (temp._version == null) return false;
180                 else if (!(this._version.equals(temp._version))) 
181                     return false;
182             }
183             else if (temp._version != null)
184                 return false;
185             if (this._name != null) {
186                 if (temp._name == null) return false;
187                 else if (!(this._name.equals(temp._name))) 
188                     return false;
189             }
190             else if (temp._name != null)
191                 return false;
192             if (this._userList != null) {
193                 if (temp._userList == null) return false;
194                 else if (!(this._userList.equals(temp._userList))) 
195                     return false;
196             }
197             else if (temp._userList != null)
198                 return false;
199             if (this._common != null) {
200                 if (temp._common == null) return false;
201                 else if (!(this._common.equals(temp._common))) 
202                     return false;
203             }
204             else if (temp._common != null)
205                 return false;
206             if (this._instanceList != null) {
207                 if (temp._instanceList == null) return false;
208                 else if (!(this._instanceList.equals(temp._instanceList))) 
209                     return false;
210             }
211             else if (temp._instanceList != null)
212                 return false;
213             return true;
214         }
215         return false;
216     } //-- boolean equals(java.lang.Object) 
217
218     /**
219      * Returns the value of field 'common'.
220      * 
221      * @return Common
222      * @return the value of field 'common'.
223      */
224     public uk.ac.vamsas.objects.core.Common getCommon()
225     {
226         return this._common;
227     } //-- uk.ac.vamsas.objects.core.Common getCommon() 
228
229     /**
230      * Method getInstance
231      * 
232      * 
233      * 
234      * @param index
235      * @return Instance
236      */
237     public uk.ac.vamsas.objects.core.Instance getInstance(int index)
238         throws java.lang.IndexOutOfBoundsException
239     {
240         //-- check bounds for index
241         if ((index < 0) || (index > _instanceList.size())) {
242             throw new IndexOutOfBoundsException("getInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]");
243         }
244         
245         return (uk.ac.vamsas.objects.core.Instance) _instanceList.elementAt(index);
246     } //-- uk.ac.vamsas.objects.core.Instance getInstance(int) 
247
248     /**
249      * Method getInstance
250      * 
251      * 
252      * 
253      * @return Instance
254      */
255     public uk.ac.vamsas.objects.core.Instance[] getInstance()
256     {
257         int size = _instanceList.size();
258         uk.ac.vamsas.objects.core.Instance[] mArray = new uk.ac.vamsas.objects.core.Instance[size];
259         for (int index = 0; index < size; index++) {
260             mArray[index] = (uk.ac.vamsas.objects.core.Instance) _instanceList.elementAt(index);
261         }
262         return mArray;
263     } //-- uk.ac.vamsas.objects.core.Instance[] getInstance() 
264
265     /**
266      * Method getInstanceCount
267      * 
268      * 
269      * 
270      * @return int
271      */
272     public int getInstanceCount()
273     {
274         return _instanceList.size();
275     } //-- int getInstanceCount() 
276
277     /**
278      * Returns the value of field 'name'. The field 'name' has the
279      * following description: Canonical name of application 
280      * 
281      * @return String
282      * @return the value of field 'name'.
283      */
284     public java.lang.String getName()
285     {
286         return this._name;
287     } //-- java.lang.String getName() 
288
289     /**
290      * Method getUser
291      * 
292      * 
293      * 
294      * @param index
295      * @return User
296      */
297     public uk.ac.vamsas.objects.core.User getUser(int index)
298         throws java.lang.IndexOutOfBoundsException
299     {
300         //-- check bounds for index
301         if ((index < 0) || (index > _userList.size())) {
302             throw new IndexOutOfBoundsException("getUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
303         }
304         
305         return (uk.ac.vamsas.objects.core.User) _userList.elementAt(index);
306     } //-- uk.ac.vamsas.objects.core.User getUser(int) 
307
308     /**
309      * Method getUser
310      * 
311      * 
312      * 
313      * @return User
314      */
315     public uk.ac.vamsas.objects.core.User[] getUser()
316     {
317         int size = _userList.size();
318         uk.ac.vamsas.objects.core.User[] mArray = new uk.ac.vamsas.objects.core.User[size];
319         for (int index = 0; index < size; index++) {
320             mArray[index] = (uk.ac.vamsas.objects.core.User) _userList.elementAt(index);
321         }
322         return mArray;
323     } //-- uk.ac.vamsas.objects.core.User[] getUser() 
324
325     /**
326      * Method getUserCount
327      * 
328      * 
329      * 
330      * @return int
331      */
332     public int getUserCount()
333     {
334         return _userList.size();
335     } //-- int getUserCount() 
336
337     /**
338      * Returns the value of field 'version'. The field 'version'
339      * has the following description: Version string describing the
340      * application specific
341      *  data storage version used
342      * 
343      * @return String
344      * @return the value of field 'version'.
345      */
346     public java.lang.String getVersion()
347     {
348         return this._version;
349     } //-- java.lang.String getVersion() 
350
351     /**
352      * Method isValid
353      * 
354      * 
355      * 
356      * @return boolean
357      */
358     public boolean isValid()
359     {
360         try {
361             validate();
362         }
363         catch (org.exolab.castor.xml.ValidationException vex) {
364             return false;
365         }
366         return true;
367     } //-- boolean isValid() 
368
369     /**
370      * Method marshal
371      * 
372      * 
373      * 
374      * @param out
375      */
376     public void marshal(java.io.Writer out)
377         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
378     {
379         
380         Marshaller.marshal(this, out);
381     } //-- void marshal(java.io.Writer) 
382
383     /**
384      * Method marshal
385      * 
386      * 
387      * 
388      * @param handler
389      */
390     public void marshal(org.xml.sax.ContentHandler handler)
391         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
392     {
393         
394         Marshaller.marshal(this, handler);
395     } //-- void marshal(org.xml.sax.ContentHandler) 
396
397     /**
398      * Method removeAllInstance
399      * 
400      */
401     public void removeAllInstance()
402     {
403         _instanceList.removeAllElements();
404     } //-- void removeAllInstance() 
405
406     /**
407      * Method removeAllUser
408      * 
409      */
410     public void removeAllUser()
411     {
412         _userList.removeAllElements();
413     } //-- void removeAllUser() 
414
415     /**
416      * Method removeInstance
417      * 
418      * 
419      * 
420      * @param index
421      * @return Instance
422      */
423     public uk.ac.vamsas.objects.core.Instance removeInstance(int index)
424     {
425         java.lang.Object obj = _instanceList.elementAt(index);
426         _instanceList.removeElementAt(index);
427         return (uk.ac.vamsas.objects.core.Instance) obj;
428     } //-- uk.ac.vamsas.objects.core.Instance removeInstance(int) 
429
430     /**
431      * Method removeUser
432      * 
433      * 
434      * 
435      * @param index
436      * @return User
437      */
438     public uk.ac.vamsas.objects.core.User removeUser(int index)
439     {
440         java.lang.Object obj = _userList.elementAt(index);
441         _userList.removeElementAt(index);
442         return (uk.ac.vamsas.objects.core.User) obj;
443     } //-- uk.ac.vamsas.objects.core.User removeUser(int) 
444
445     /**
446      * Sets the value of field 'common'.
447      * 
448      * @param common the value of field 'common'.
449      */
450     public void setCommon(uk.ac.vamsas.objects.core.Common common)
451     {
452         this._common = common;
453     } //-- void setCommon(uk.ac.vamsas.objects.core.Common) 
454
455     /**
456      * Method setInstance
457      * 
458      * 
459      * 
460      * @param index
461      * @param vInstance
462      */
463     public void setInstance(int index, uk.ac.vamsas.objects.core.Instance vInstance)
464         throws java.lang.IndexOutOfBoundsException
465     {
466         //-- check bounds for index
467         if ((index < 0) || (index > _instanceList.size())) {
468             throw new IndexOutOfBoundsException("setInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]");
469         }
470         _instanceList.setElementAt(vInstance, index);
471     } //-- void setInstance(int, uk.ac.vamsas.objects.core.Instance) 
472
473     /**
474      * Method setInstance
475      * 
476      * 
477      * 
478      * @param instanceArray
479      */
480     public void setInstance(uk.ac.vamsas.objects.core.Instance[] instanceArray)
481     {
482         //-- copy array
483         _instanceList.removeAllElements();
484         for (int i = 0; i < instanceArray.length; i++) {
485             _instanceList.addElement(instanceArray[i]);
486         }
487     } //-- void setInstance(uk.ac.vamsas.objects.core.Instance) 
488
489     /**
490      * Sets the value of field 'name'. The field 'name' has the
491      * following description: Canonical name of application 
492      * 
493      * @param name the value of field 'name'.
494      */
495     public void setName(java.lang.String name)
496     {
497         this._name = name;
498     } //-- void setName(java.lang.String) 
499
500     /**
501      * Method setUser
502      * 
503      * 
504      * 
505      * @param index
506      * @param vUser
507      */
508     public void setUser(int index, uk.ac.vamsas.objects.core.User vUser)
509         throws java.lang.IndexOutOfBoundsException
510     {
511         //-- check bounds for index
512         if ((index < 0) || (index > _userList.size())) {
513             throw new IndexOutOfBoundsException("setUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]");
514         }
515         _userList.setElementAt(vUser, index);
516     } //-- void setUser(int, uk.ac.vamsas.objects.core.User) 
517
518     /**
519      * Method setUser
520      * 
521      * 
522      * 
523      * @param userArray
524      */
525     public void setUser(uk.ac.vamsas.objects.core.User[] userArray)
526     {
527         //-- copy array
528         _userList.removeAllElements();
529         for (int i = 0; i < userArray.length; i++) {
530             _userList.addElement(userArray[i]);
531         }
532     } //-- void setUser(uk.ac.vamsas.objects.core.User) 
533
534     /**
535      * Sets the value of field 'version'. The field 'version' has
536      * the following description: Version string describing the
537      * application specific
538      *  data storage version used
539      * 
540      * @param version the value of field 'version'.
541      */
542     public void setVersion(java.lang.String version)
543     {
544         this._version = version;
545     } //-- void setVersion(java.lang.String) 
546
547     /**
548      * Method unmarshal
549      * 
550      * 
551      * 
552      * @param reader
553      * @return AppData
554      */
555     public static uk.ac.vamsas.objects.core.AppData unmarshal(java.io.Reader reader)
556         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
557     {
558         return (uk.ac.vamsas.objects.core.ApplicationData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ApplicationData.class, reader);
559     } //-- uk.ac.vamsas.objects.core.AppData unmarshal(java.io.Reader) 
560
561     /**
562      * Method validate
563      * 
564      */
565     public void validate()
566         throws org.exolab.castor.xml.ValidationException
567     {
568         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
569         validator.validate(this);
570     } //-- void validate() 
571
572 }