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;
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); };
181 if (!this._version.equals(temp._version)) {
182 org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
183 org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
186 org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
187 org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
190 } else if (temp._version != null)
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); };
203 if (!this._name.equals(temp._name)) {
204 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
205 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
208 org.castor.util.CycleBreaker.releaseCycleHandle(this._name);
209 org.castor.util.CycleBreaker.releaseCycleHandle(temp._name);
212 } else if (temp._name != null)
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); };
225 if (!this._userList.equals(temp._userList)) {
226 org.castor.util.CycleBreaker.releaseCycleHandle(this._userList);
227 org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList);
230 org.castor.util.CycleBreaker.releaseCycleHandle(this._userList);
231 org.castor.util.CycleBreaker.releaseCycleHandle(temp._userList);
234 } else if (temp._userList != null)
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); };
247 if (!this._common.equals(temp._common)) {
248 org.castor.util.CycleBreaker.releaseCycleHandle(this._common);
249 org.castor.util.CycleBreaker.releaseCycleHandle(temp._common);
252 org.castor.util.CycleBreaker.releaseCycleHandle(this._common);
253 org.castor.util.CycleBreaker.releaseCycleHandle(temp._common);
256 } else if (temp._common != null)
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); };
269 if (!this._instanceList.equals(temp._instanceList)) {
270 org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList);
271 org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList);
274 org.castor.util.CycleBreaker.releaseCycleHandle(this._instanceList);
275 org.castor.util.CycleBreaker.releaseCycleHandle(temp._instanceList);
278 } else if (temp._instanceList != null)
286 * Returns the value of field 'common'.
288 * @return the value of field 'Common'.
290 public uk.ac.vamsas.objects.core.Common getCommon(
296 * Method getInstance.
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
304 public uk.ac.vamsas.objects.core.Instance getInstance(
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) + "]");
312 return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index);
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.
322 * @return this collection as an Array
324 public uk.ac.vamsas.objects.core.Instance[] getInstance(
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);
331 * Method getInstanceAsReference.Returns a reference to
332 * '_instanceList'. No type checking is performed on any
333 * modifications to the Vector.
335 * @return a reference to the Vector backing this class
337 public java.util.Vector getInstanceAsReference(
339 return this._instanceList;
343 * Method getInstanceCount.
345 * @return the size of this collection
347 public int getInstanceCount(
349 return this._instanceList.size();
353 * Returns the value of field 'name'. The field 'name' has the
354 * following description: Canonical name of application
356 * @return the value of field 'Name'.
358 public java.lang.String getName(
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
372 public uk.ac.vamsas.objects.core.User getUser(
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) + "]");
380 return (uk.ac.vamsas.objects.core.User) _userList.get(index);
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.
390 * @return this collection as an Array
392 public uk.ac.vamsas.objects.core.User[] getUser(
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);
399 * Method getUserAsReference.Returns a reference to
400 * '_userList'. No type checking is performed on any
401 * modifications to the Vector.
403 * @return a reference to the Vector backing this class
405 public java.util.Vector getUserAsReference(
407 return this._userList;
411 * Method getUserCount.
413 * @return the size of this collection
415 public int getUserCount(
417 return this._userList.size();
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
426 * @return the value of field 'Version'.
428 public java.lang.String getVersion(
430 return this._version;
434 * Overrides the java.lang.Object.hashCode method.
436 * The following steps came from <b>Effective Java Programming
437 * Language Guide</b> by Joshua Bloch, Chapter 3
439 * @return a hash code value for the object.
443 int result = super.hashCode();
447 && !org.castor.util.CycleBreaker.startingToCycle(_version)) {
448 result = 37 * result + _version.hashCode();
449 org.castor.util.CycleBreaker.releaseCycleHandle(_version);
452 && !org.castor.util.CycleBreaker.startingToCycle(_name)) {
453 result = 37 * result + _name.hashCode();
454 org.castor.util.CycleBreaker.releaseCycleHandle(_name);
456 if (_userList != null
457 && !org.castor.util.CycleBreaker.startingToCycle(_userList)) {
458 result = 37 * result + _userList.hashCode();
459 org.castor.util.CycleBreaker.releaseCycleHandle(_userList);
462 && !org.castor.util.CycleBreaker.startingToCycle(_common)) {
463 result = 37 * result + _common.hashCode();
464 org.castor.util.CycleBreaker.releaseCycleHandle(_common);
466 if (_instanceList != null
467 && !org.castor.util.CycleBreaker.startingToCycle(_instanceList)) {
468 result = 37 * result + _instanceList.hashCode();
469 org.castor.util.CycleBreaker.releaseCycleHandle(_instanceList);
478 * @return true if this object is valid according to the schema
480 public boolean isValid(
484 } catch (org.exolab.castor.xml.ValidationException vex) {
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
500 final java.io.Writer out)
501 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
502 Marshaller.marshal(this, out);
509 * @throws java.io.IOException if an IOException occurs during
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
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);
524 public void removeAllInstance(
526 this._instanceList.clear();
531 public void removeAllUser(
533 this._userList.clear();
537 * Method removeInstance.
540 * @return true if the object was removed from the collection.
542 public boolean removeInstance(
543 final uk.ac.vamsas.objects.core.Instance vInstance) {
544 boolean removed = _instanceList.remove(vInstance);
549 * Method removeInstanceAt.
552 * @return the element removed from the collection
554 public uk.ac.vamsas.objects.core.Instance removeInstanceAt(
556 java.lang.Object obj = this._instanceList.remove(index);
557 return (uk.ac.vamsas.objects.core.Instance) obj;
564 * @return true if the object was removed from the collection.
566 public boolean removeUser(
567 final uk.ac.vamsas.objects.core.User vUser) {
568 boolean removed = _userList.remove(vUser);
573 * Method removeUserAt.
576 * @return the element removed from the collection
578 public uk.ac.vamsas.objects.core.User removeUserAt(
580 java.lang.Object obj = this._userList.remove(index);
581 return (uk.ac.vamsas.objects.core.User) obj;
585 * Sets the value of field 'common'.
587 * @param common the value of field 'common'.
589 public void setCommon(
590 final uk.ac.vamsas.objects.core.Common common) {
591 this._common = common;
599 * @throws java.lang.IndexOutOfBoundsException if the index
600 * given is outside the bounds of the collection
602 public void setInstance(
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) + "]");
611 this._instanceList.set(index, vInstance);
617 * @param vInstanceArray
619 public void setInstance(
620 final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) {
622 _instanceList.clear();
624 for (int i = 0; i < vInstanceArray.length; i++) {
625 this._instanceList.add(vInstanceArray[i]);
630 * Sets the value of '_instanceList' by copying the given
631 * Vector. All elements will be checked for type safety.
633 * @param vInstanceList the Vector to copy.
635 public void setInstance(
636 final java.util.Vector vInstanceList) {
638 this._instanceList.clear();
640 this._instanceList.addAll(vInstanceList);
644 * Sets the value of '_instanceList' by setting it to the given
645 * Vector. No type checking is performed.
648 * @param instanceVector the Vector to set.
650 public void setInstanceAsReference(
651 final java.util.Vector instanceVector) {
652 this._instanceList = instanceVector;
656 * Sets the value of field 'name'. The field 'name' has the
657 * following description: Canonical name of application
659 * @param name the value of field 'name'.
662 final java.lang.String name) {
671 * @throws java.lang.IndexOutOfBoundsException if the index
672 * given is outside the bounds of the collection
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) + "]");
683 this._userList.set(index, vUser);
692 final uk.ac.vamsas.objects.core.User[] vUserArray) {
696 for (int i = 0; i < vUserArray.length; i++) {
697 this._userList.add(vUserArray[i]);
702 * Sets the value of '_userList' by copying the given Vector.
703 * All elements will be checked for type safety.
705 * @param vUserList the Vector to copy.
708 final java.util.Vector vUserList) {
710 this._userList.clear();
712 this._userList.addAll(vUserList);
716 * Sets the value of '_userList' by setting it to the given
717 * Vector. No type checking is performed.
720 * @param userVector the Vector to set.
722 public void setUserAsReference(
723 final java.util.Vector userVector) {
724 this._userList = userVector;
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
733 * @param version the value of field 'version'.
735 public void setVersion(
736 final java.lang.String version) {
737 this._version = version;
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
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);
759 * @throws org.exolab.castor.xml.ValidationException if this
760 * object is an invalid instance according to the schema
762 public void validate(
764 throws org.exolab.castor.xml.ValidationException {
765 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
766 validator.validate(this);