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;
20 * @version $Revision$ $Date$
22 public class Sequence extends uk.ac.vamsas.objects.core.SequenceType
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * Primary Key for vamsas object referencing
35 private java.lang.String _id;
38 * symbol class for sequence
41 private java.lang.String _dictionary;
44 * Store a list of database references
45 * for this sequence record - with optional mapping
46 * from database sequence to the given sequence record
48 private java.util.Vector _dbRefList;
51 * explicitly named cross reference to
52 * other objects in the document.
54 private java.util.Vector _vxrefList;
63 this._dbRefList = new java.util.Vector();
64 this._vxrefList = new java.util.Vector();
76 * @throws java.lang.IndexOutOfBoundsException if the index
77 * given is outside the bounds of the collection
80 final uk.ac.vamsas.objects.core.DbRef vDbRef)
81 throws java.lang.IndexOutOfBoundsException {
82 this._dbRefList.addElement(vDbRef);
90 * @throws java.lang.IndexOutOfBoundsException if the index
91 * given is outside the bounds of the collection
95 final uk.ac.vamsas.objects.core.DbRef vDbRef)
96 throws java.lang.IndexOutOfBoundsException {
97 this._dbRefList.add(index, vDbRef);
104 * @throws java.lang.IndexOutOfBoundsException if the index
105 * given is outside the bounds of the collection
107 public void addVxref(
108 final uk.ac.vamsas.objects.core.Vxref vVxref)
109 throws java.lang.IndexOutOfBoundsException {
110 this._vxrefList.addElement(vVxref);
118 * @throws java.lang.IndexOutOfBoundsException if the index
119 * given is outside the bounds of the collection
121 public void addVxref(
123 final uk.ac.vamsas.objects.core.Vxref vVxref)
124 throws java.lang.IndexOutOfBoundsException {
125 this._vxrefList.add(index, vVxref);
129 * Method enumerateDbRef.
131 * @return an Enumeration over all
132 * uk.ac.vamsas.objects.core.DbRef elements
134 public java.util.Enumeration enumerateDbRef(
136 return this._dbRefList.elements();
140 * Method enumerateVxref.
142 * @return an Enumeration over all
143 * uk.ac.vamsas.objects.core.Vxref elements
145 public java.util.Enumeration enumerateVxref(
147 return this._vxrefList.elements();
151 * Overrides the java.lang.Object.equals method.
154 * @return true if the objects are equal.
156 public boolean equals(
157 final java.lang.Object obj) {
161 if (super.equals(obj)==false)
164 if (obj instanceof Sequence) {
166 Sequence temp = (Sequence)obj;
169 if (this._id != null) {
170 if (temp._id == null) return false;
171 if (this._id != temp._id) {
172 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
173 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
174 if (thcycle!=tmcycle) {
175 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
176 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
180 if (!this._id.equals(temp._id)) {
181 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
182 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
185 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
186 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
189 } else if (temp._id != null)
191 if (this._dictionary != null) {
192 if (temp._dictionary == null) return false;
193 if (this._dictionary != temp._dictionary) {
194 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dictionary);
195 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dictionary);
196 if (thcycle!=tmcycle) {
197 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary); };
198 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary); };
202 if (!this._dictionary.equals(temp._dictionary)) {
203 org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary);
204 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary);
207 org.castor.util.CycleBreaker.releaseCycleHandle(this._dictionary);
208 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dictionary);
211 } else if (temp._dictionary != null)
213 if (this._dbRefList != null) {
214 if (temp._dbRefList == null) return false;
215 if (this._dbRefList != temp._dbRefList) {
216 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dbRefList);
217 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dbRefList);
218 if (thcycle!=tmcycle) {
219 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList); };
220 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList); };
224 if (!this._dbRefList.equals(temp._dbRefList)) {
225 org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList);
226 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList);
229 org.castor.util.CycleBreaker.releaseCycleHandle(this._dbRefList);
230 org.castor.util.CycleBreaker.releaseCycleHandle(temp._dbRefList);
233 } else if (temp._dbRefList != null)
235 if (this._vxrefList != null) {
236 if (temp._vxrefList == null) return false;
237 if (this._vxrefList != temp._vxrefList) {
238 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._vxrefList);
239 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._vxrefList);
240 if (thcycle!=tmcycle) {
241 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList); };
242 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList); };
246 if (!this._vxrefList.equals(temp._vxrefList)) {
247 org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList);
248 org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList);
251 org.castor.util.CycleBreaker.releaseCycleHandle(this._vxrefList);
252 org.castor.util.CycleBreaker.releaseCycleHandle(temp._vxrefList);
255 } else if (temp._vxrefList != null)
266 * @throws java.lang.IndexOutOfBoundsException if the index
267 * given is outside the bounds of the collection
268 * @return the value of the uk.ac.vamsas.objects.core.DbRef at
271 public uk.ac.vamsas.objects.core.DbRef getDbRef(
273 throws java.lang.IndexOutOfBoundsException {
274 // check bounds for index
275 if (index < 0 || index >= this._dbRefList.size()) {
276 throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
279 return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index);
283 * Method getDbRef.Returns the contents of the collection in an
284 * Array. <p>Note: Just in case the collection contents are
285 * changing in another thread, we pass a 0-length Array of the
286 * correct type into the API call. This way we <i>know</i>
287 * that the Array returned is of exactly the correct length.
289 * @return this collection as an Array
291 public uk.ac.vamsas.objects.core.DbRef[] getDbRef(
293 uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0];
294 return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array);
298 * Method getDbRefAsReference.Returns a reference to
299 * '_dbRefList'. No type checking is performed on any
300 * modifications to the Vector.
302 * @return a reference to the Vector backing this class
304 public java.util.Vector getDbRefAsReference(
306 return this._dbRefList;
310 * Method getDbRefCount.
312 * @return the size of this collection
314 public int getDbRefCount(
316 return this._dbRefList.size();
320 * Returns the value of field 'dictionary'. The field
321 * 'dictionary' has the following description: symbol class for
325 * @return the value of field 'Dictionary'.
327 public java.lang.String getDictionary(
329 return this._dictionary;
333 * Returns the value of field 'id'. The field 'id' has the
334 * following description: Primary Key for vamsas object
338 * @return the value of field 'Id'.
340 public java.lang.String getId(
349 * @throws java.lang.IndexOutOfBoundsException if the index
350 * given is outside the bounds of the collection
351 * @return the value of the uk.ac.vamsas.objects.core.Vxref at
354 public uk.ac.vamsas.objects.core.Vxref getVxref(
356 throws java.lang.IndexOutOfBoundsException {
357 // check bounds for index
358 if (index < 0 || index >= this._vxrefList.size()) {
359 throw new IndexOutOfBoundsException("getVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]");
362 return (uk.ac.vamsas.objects.core.Vxref) _vxrefList.get(index);
366 * Method getVxref.Returns the contents of the collection in an
367 * Array. <p>Note: Just in case the collection contents are
368 * changing in another thread, we pass a 0-length Array of the
369 * correct type into the API call. This way we <i>know</i>
370 * that the Array returned is of exactly the correct length.
372 * @return this collection as an Array
374 public uk.ac.vamsas.objects.core.Vxref[] getVxref(
376 uk.ac.vamsas.objects.core.Vxref[] array = new uk.ac.vamsas.objects.core.Vxref[0];
377 return (uk.ac.vamsas.objects.core.Vxref[]) this._vxrefList.toArray(array);
381 * Method getVxrefAsReference.Returns a reference to
382 * '_vxrefList'. No type checking is performed on any
383 * modifications to the Vector.
385 * @return a reference to the Vector backing this class
387 public java.util.Vector getVxrefAsReference(
389 return this._vxrefList;
393 * Method getVxrefCount.
395 * @return the size of this collection
397 public int getVxrefCount(
399 return this._vxrefList.size();
403 * Overrides the java.lang.Object.hashCode method.
405 * The following steps came from <b>Effective Java Programming
406 * Language Guide</b> by Joshua Bloch, Chapter 3
408 * @return a hash code value for the object.
412 int result = super.hashCode();
416 && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
417 result = 37 * result + _id.hashCode();
418 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
420 if (_dictionary != null
421 && !org.castor.util.CycleBreaker.startingToCycle(_dictionary)) {
422 result = 37 * result + _dictionary.hashCode();
423 org.castor.util.CycleBreaker.releaseCycleHandle(_dictionary);
425 if (_dbRefList != null
426 && !org.castor.util.CycleBreaker.startingToCycle(_dbRefList)) {
427 result = 37 * result + _dbRefList.hashCode();
428 org.castor.util.CycleBreaker.releaseCycleHandle(_dbRefList);
430 if (_vxrefList != null
431 && !org.castor.util.CycleBreaker.startingToCycle(_vxrefList)) {
432 result = 37 * result + _vxrefList.hashCode();
433 org.castor.util.CycleBreaker.releaseCycleHandle(_vxrefList);
442 * @return true if this object is valid according to the schema
444 public boolean isValid(
448 } catch (org.exolab.castor.xml.ValidationException vex) {
458 * @throws org.exolab.castor.xml.MarshalException if object is
459 * null or if any SAXException is thrown during marshaling
460 * @throws org.exolab.castor.xml.ValidationException if this
461 * object is an invalid instance according to the schema
464 final java.io.Writer out)
465 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
466 Marshaller.marshal(this, out);
473 * @throws java.io.IOException if an IOException occurs during
475 * @throws org.exolab.castor.xml.ValidationException if this
476 * object is an invalid instance according to the schema
477 * @throws org.exolab.castor.xml.MarshalException if object is
478 * null or if any SAXException is thrown during marshaling
481 final org.xml.sax.ContentHandler handler)
482 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
483 Marshaller.marshal(this, handler);
488 public void removeAllDbRef(
490 this._dbRefList.clear();
495 public void removeAllVxref(
497 this._vxrefList.clear();
501 * Method removeDbRef.
504 * @return true if the object was removed from the collection.
506 public boolean removeDbRef(
507 final uk.ac.vamsas.objects.core.DbRef vDbRef) {
508 boolean removed = _dbRefList.remove(vDbRef);
513 * Method removeDbRefAt.
516 * @return the element removed from the collection
518 public uk.ac.vamsas.objects.core.DbRef removeDbRefAt(
520 java.lang.Object obj = this._dbRefList.remove(index);
521 return (uk.ac.vamsas.objects.core.DbRef) obj;
525 * Method removeVxref.
528 * @return true if the object was removed from the collection.
530 public boolean removeVxref(
531 final uk.ac.vamsas.objects.core.Vxref vVxref) {
532 boolean removed = _vxrefList.remove(vVxref);
537 * Method removeVxrefAt.
540 * @return the element removed from the collection
542 public uk.ac.vamsas.objects.core.Vxref removeVxrefAt(
544 java.lang.Object obj = this._vxrefList.remove(index);
545 return (uk.ac.vamsas.objects.core.Vxref) obj;
553 * @throws java.lang.IndexOutOfBoundsException if the index
554 * given is outside the bounds of the collection
556 public void setDbRef(
558 final uk.ac.vamsas.objects.core.DbRef vDbRef)
559 throws java.lang.IndexOutOfBoundsException {
560 // check bounds for index
561 if (index < 0 || index >= this._dbRefList.size()) {
562 throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
565 this._dbRefList.set(index, vDbRef);
573 public void setDbRef(
574 final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) {
578 for (int i = 0; i < vDbRefArray.length; i++) {
579 this._dbRefList.add(vDbRefArray[i]);
584 * Sets the value of '_dbRefList' by copying the given Vector.
585 * All elements will be checked for type safety.
587 * @param vDbRefList the Vector to copy.
589 public void setDbRef(
590 final java.util.Vector vDbRefList) {
592 this._dbRefList.clear();
594 this._dbRefList.addAll(vDbRefList);
598 * Sets the value of '_dbRefList' by setting it to the given
599 * Vector. No type checking is performed.
602 * @param dbRefVector the Vector to set.
604 public void setDbRefAsReference(
605 final java.util.Vector dbRefVector) {
606 this._dbRefList = dbRefVector;
610 * Sets the value of field 'dictionary'. The field 'dictionary'
611 * has the following description: symbol class for sequence
614 * @param dictionary the value of field 'dictionary'.
616 public void setDictionary(
617 final java.lang.String dictionary) {
618 this._dictionary = dictionary;
622 * Sets the value of field 'id'. The field 'id' has the
623 * following description: Primary Key for vamsas object
627 * @param id the value of field 'id'.
630 final java.lang.String id) {
639 * @throws java.lang.IndexOutOfBoundsException if the index
640 * given is outside the bounds of the collection
642 public void setVxref(
644 final uk.ac.vamsas.objects.core.Vxref vVxref)
645 throws java.lang.IndexOutOfBoundsException {
646 // check bounds for index
647 if (index < 0 || index >= this._vxrefList.size()) {
648 throw new IndexOutOfBoundsException("setVxref: Index value '" + index + "' not in range [0.." + (this._vxrefList.size() - 1) + "]");
651 this._vxrefList.set(index, vVxref);
659 public void setVxref(
660 final uk.ac.vamsas.objects.core.Vxref[] vVxrefArray) {
664 for (int i = 0; i < vVxrefArray.length; i++) {
665 this._vxrefList.add(vVxrefArray[i]);
670 * Sets the value of '_vxrefList' by copying the given Vector.
671 * All elements will be checked for type safety.
673 * @param vVxrefList the Vector to copy.
675 public void setVxref(
676 final java.util.Vector vVxrefList) {
678 this._vxrefList.clear();
680 this._vxrefList.addAll(vVxrefList);
684 * Sets the value of '_vxrefList' by setting it to the given
685 * Vector. No type checking is performed.
688 * @param vxrefVector the Vector to set.
690 public void setVxrefAsReference(
691 final java.util.Vector vxrefVector) {
692 this._vxrefList = vxrefVector;
699 * @throws org.exolab.castor.xml.MarshalException if object is
700 * null or if any SAXException is thrown during marshaling
701 * @throws org.exolab.castor.xml.ValidationException if this
702 * object is an invalid instance according to the schema
703 * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
705 public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
706 final java.io.Reader reader)
707 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
708 return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
714 * @throws org.exolab.castor.xml.ValidationException if this
715 * object is an invalid instance according to the schema
717 public void validate(
719 throws org.exolab.castor.xml.ValidationException {
720 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
721 validator.validate(this);