2 * This class was automatically generated with
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
8 package uk.ac.vamsas.objects.core;
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
18 * Class ApplicationData.
20 * @version $Revision$ $Date$
22 public class ApplicationData extends uk.ac.vamsas.objects.core.AppData
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * Version string describing the application specific
33 * data storage version used
35 private java.lang.String _version;
38 * Canonical name of application
40 private java.lang.String _name;
45 private java.util.Vector _userList;
50 private uk.ac.vamsas.objects.core.Common _common;
53 * Field _instanceList.
55 private java.util.Vector _instanceList;
62 public ApplicationData() {
64 this._userList = new java.util.Vector();
65 this._instanceList = new java.util.Vector();
77 * @throws java.lang.IndexOutOfBoundsException if the index
78 * given is outside the bounds of the collection
80 public void addInstance(
81 final uk.ac.vamsas.objects.core.Instance vInstance)
82 throws java.lang.IndexOutOfBoundsException {
83 this._instanceList.addElement(vInstance);
91 * @throws java.lang.IndexOutOfBoundsException if the index
92 * given is outside the bounds of the collection
94 public void addInstance(
96 final uk.ac.vamsas.objects.core.Instance vInstance)
97 throws java.lang.IndexOutOfBoundsException {
98 this._instanceList.add(index, vInstance);
105 * @throws java.lang.IndexOutOfBoundsException if the index
106 * given is outside the bounds of the collection
109 final uk.ac.vamsas.objects.core.User vUser)
110 throws java.lang.IndexOutOfBoundsException {
111 this._userList.addElement(vUser);
119 * @throws java.lang.IndexOutOfBoundsException if the index
120 * given is outside the bounds of the collection
124 final uk.ac.vamsas.objects.core.User vUser)
125 throws java.lang.IndexOutOfBoundsException {
126 this._userList.add(index, vUser);
130 * Method enumerateInstance.
132 * @return an Enumeration over all
133 * uk.ac.vamsas.objects.core.Instance elements
135 public java.util.Enumeration enumerateInstance(
137 return this._instanceList.elements();
141 * Method enumerateUser.
143 * @return an Enumeration over all
144 * uk.ac.vamsas.objects.core.User elements
146 public java.util.Enumeration enumerateUser(
148 return this._userList.elements();
152 * Overrides the java.lang.Object.equals method.
155 * @return true if the objects are equal.
157 public boolean equals(
158 final java.lang.Object obj) {
162 if (super.equals(obj)==false)
165 if (obj instanceof ApplicationData) {
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)))
173 else if (temp._version != null)
175 if (this._name != null) {
176 if (temp._name == null) return false;
177 else if (!(this._name.equals(temp._name)))
180 else if (temp._name != null)
182 if (this._userList != null) {
183 if (temp._userList == null) return false;
184 else if (!(this._userList.equals(temp._userList)))
187 else if (temp._userList != null)
189 if (this._common != null) {
190 if (temp._common == null) return false;
191 else if (!(this._common.equals(temp._common)))
194 else if (temp._common != null)
196 if (this._instanceList != null) {
197 if (temp._instanceList == null) return false;
198 else if (!(this._instanceList.equals(temp._instanceList)))
201 else if (temp._instanceList != null)
209 * Returns the value of field 'common'.
211 * @return the value of field 'Common'.
213 public uk.ac.vamsas.objects.core.Common getCommon(
219 * Method getInstance.
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
227 public uk.ac.vamsas.objects.core.Instance getInstance(
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) + "]");
235 return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index);
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.
245 * @return this collection as an Array
247 public uk.ac.vamsas.objects.core.Instance[] getInstance(
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);
254 * Method getInstanceAsReference.Returns a reference to
255 * '_instanceList'. No type checking is performed on any
256 * modifications to the Vector.
258 * @return a reference to the Vector backing this class
260 public java.util.Vector getInstanceAsReference(
262 return this._instanceList;
266 * Method getInstanceCount.
268 * @return the size of this collection
270 public int getInstanceCount(
272 return this._instanceList.size();
276 * Returns the value of field 'name'. The field 'name' has the
277 * following description: Canonical name of application
279 * @return the value of field 'Name'.
281 public java.lang.String getName(
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
295 public uk.ac.vamsas.objects.core.User getUser(
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) + "]");
303 return (uk.ac.vamsas.objects.core.User) _userList.get(index);
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.
313 * @return this collection as an Array
315 public uk.ac.vamsas.objects.core.User[] getUser(
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);
322 * Method getUserAsReference.Returns a reference to
323 * '_userList'. No type checking is performed on any
324 * modifications to the Vector.
326 * @return a reference to the Vector backing this class
328 public java.util.Vector getUserAsReference(
330 return this._userList;
334 * Method getUserCount.
336 * @return the size of this collection
338 public int getUserCount(
340 return this._userList.size();
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
349 * @return the value of field 'Version'.
351 public java.lang.String getVersion(
353 return this._version;
357 * Overrides the java.lang.Object.hashCode method.
359 * The following steps came from <b>Effective Java Programming
360 * Language Guide</b> by Joshua Bloch, Chapter 3
362 * @return a hash code value for the object.
366 int result = super.hashCode();
369 if (_version != null) {
370 result = 37 * result + _version.hashCode();
373 result = 37 * result + _name.hashCode();
375 if (_userList != null) {
376 result = 37 * result + _userList.hashCode();
378 if (_common != null) {
379 result = 37 * result + _common.hashCode();
381 if (_instanceList != null) {
382 result = 37 * result + _instanceList.hashCode();
391 * @return true if this object is valid according to the schema
393 public boolean isValid(
397 } catch (org.exolab.castor.xml.ValidationException vex) {
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
413 final java.io.Writer out)
414 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
415 Marshaller.marshal(this, out);
422 * @throws java.io.IOException if an IOException occurs during
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
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);
437 public void removeAllInstance(
439 this._instanceList.clear();
444 public void removeAllUser(
446 this._userList.clear();
450 * Method removeInstance.
453 * @return true if the object was removed from the collection.
455 public boolean removeInstance(
456 final uk.ac.vamsas.objects.core.Instance vInstance) {
457 boolean removed = _instanceList.remove(vInstance);
462 * Method removeInstanceAt.
465 * @return the element removed from the collection
467 public uk.ac.vamsas.objects.core.Instance removeInstanceAt(
469 java.lang.Object obj = this._instanceList.remove(index);
470 return (uk.ac.vamsas.objects.core.Instance) obj;
477 * @return true if the object was removed from the collection.
479 public boolean removeUser(
480 final uk.ac.vamsas.objects.core.User vUser) {
481 boolean removed = _userList.remove(vUser);
486 * Method removeUserAt.
489 * @return the element removed from the collection
491 public uk.ac.vamsas.objects.core.User removeUserAt(
493 java.lang.Object obj = this._userList.remove(index);
494 return (uk.ac.vamsas.objects.core.User) obj;
498 * Sets the value of field 'common'.
500 * @param common the value of field 'common'.
502 public void setCommon(
503 final uk.ac.vamsas.objects.core.Common common) {
504 this._common = common;
512 * @throws java.lang.IndexOutOfBoundsException if the index
513 * given is outside the bounds of the collection
515 public void setInstance(
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) + "]");
524 this._instanceList.set(index, vInstance);
530 * @param vInstanceArray
532 public void setInstance(
533 final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) {
535 _instanceList.clear();
537 for (int i = 0; i < vInstanceArray.length; i++) {
538 this._instanceList.add(vInstanceArray[i]);
543 * Sets the value of '_instanceList' by copying the given
544 * Vector. All elements will be checked for type safety.
546 * @param vInstanceList the Vector to copy.
548 public void setInstance(
549 final java.util.Vector vInstanceList) {
551 this._instanceList.clear();
553 this._instanceList.addAll(vInstanceList);
557 * Sets the value of '_instanceList' by setting it to the given
558 * Vector. No type checking is performed.
561 * @param instanceVector the Vector to set.
563 public void setInstanceAsReference(
564 final java.util.Vector instanceVector) {
565 this._instanceList = instanceVector;
569 * Sets the value of field 'name'. The field 'name' has the
570 * following description: Canonical name of application
572 * @param name the value of field 'name'.
575 final java.lang.String name) {
584 * @throws java.lang.IndexOutOfBoundsException if the index
585 * given is outside the bounds of the collection
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) + "]");
596 this._userList.set(index, vUser);
605 final uk.ac.vamsas.objects.core.User[] vUserArray) {
609 for (int i = 0; i < vUserArray.length; i++) {
610 this._userList.add(vUserArray[i]);
615 * Sets the value of '_userList' by copying the given Vector.
616 * All elements will be checked for type safety.
618 * @param vUserList the Vector to copy.
621 final java.util.Vector vUserList) {
623 this._userList.clear();
625 this._userList.addAll(vUserList);
629 * Sets the value of '_userList' by setting it to the given
630 * Vector. No type checking is performed.
633 * @param userVector the Vector to set.
635 public void setUserAsReference(
636 final java.util.Vector userVector) {
637 this._userList = userVector;
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
646 * @param version the value of field 'version'.
648 public void setVersion(
649 final java.lang.String version) {
650 this._version = version;
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
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);
672 * @throws org.exolab.castor.xml.ValidationException if this
673 * object is an invalid instance according to the schema
675 public void validate(
677 throws org.exolab.castor.xml.ValidationException {
678 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
679 validator.validate(this);