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 * Store a list of database references
19 * for this sequence record - with optional mapping
20 * from database sequence to the given sequence record
22 * @version $Revision$ $Date$
24 public class DbRef extends uk.ac.vamsas.client.Vobject
25 implements java.io.Serializable
29 //--------------------------/
30 //- Class/Member Variables -/
31 //--------------------------/
34 * TODO Database Naming
35 * Convention: either start using LSID (so
36 * change type to URI) or leave this as an
37 * uncontrolled/unspecified string ID
40 private java.lang.String _source;
43 * Version must be specified -
46 private java.lang.String _version;
49 * TODO: make some specification
50 * of the database field from which this
51 * accessionId is taken from - should that be a
52 * special property of the dbRef object ?
55 private java.lang.String _accessionId;
58 * Primary Key for vamsas object
61 private java.lang.String _id;
64 * the local mapType maps from the parent
65 * sequence coordinate frame to the reference
66 * frame defined by the dbRef element.
67 * The mapped mapType is the mapped range defined
68 * on the dbRef element's reference frame.
69 * Conventionally, the unit attribute defaults to 1, or
70 * will be inferred from the local sequence's
71 * dictionary type and any dictionary type associated
72 * with the database being mapped to.
73 * However, it may be used to avoid ambiguity.
76 private uk.ac.vamsas.objects.core.Map _map;
81 private java.util.Vector _linkList;
84 * Field _propertyList.
86 private java.util.Vector _propertyList;
95 this._linkList = new java.util.Vector();
96 this._propertyList = new java.util.Vector();
108 * @throws java.lang.IndexOutOfBoundsException if the index
109 * given is outside the bounds of the collection
112 final uk.ac.vamsas.objects.core.Link vLink)
113 throws java.lang.IndexOutOfBoundsException {
114 this._linkList.addElement(vLink);
122 * @throws java.lang.IndexOutOfBoundsException if the index
123 * given is outside the bounds of the collection
127 final uk.ac.vamsas.objects.core.Link vLink)
128 throws java.lang.IndexOutOfBoundsException {
129 this._linkList.add(index, vLink);
136 * @throws java.lang.IndexOutOfBoundsException if the index
137 * given is outside the bounds of the collection
139 public void addProperty(
140 final uk.ac.vamsas.objects.core.Property vProperty)
141 throws java.lang.IndexOutOfBoundsException {
142 this._propertyList.addElement(vProperty);
150 * @throws java.lang.IndexOutOfBoundsException if the index
151 * given is outside the bounds of the collection
153 public void addProperty(
155 final uk.ac.vamsas.objects.core.Property vProperty)
156 throws java.lang.IndexOutOfBoundsException {
157 this._propertyList.add(index, vProperty);
161 * Method enumerateLink.
163 * @return an Enumeration over all
164 * uk.ac.vamsas.objects.core.Link elements
166 public java.util.Enumeration enumerateLink(
168 return this._linkList.elements();
172 * Method enumerateProperty.
174 * @return an Enumeration over all
175 * uk.ac.vamsas.objects.core.Property elements
177 public java.util.Enumeration enumerateProperty(
179 return this._propertyList.elements();
183 * Overrides the java.lang.Object.equals method.
186 * @return true if the objects are equal.
188 public boolean equals(
189 final java.lang.Object obj) {
193 if (super.equals(obj)==false)
196 if (obj instanceof DbRef) {
198 DbRef temp = (DbRef)obj;
201 if (this._source != null) {
202 if (temp._source == null) return false;
203 if (this._source != temp._source) {
204 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._source);
205 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._source);
206 if (thcycle!=tmcycle) {
207 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._source); };
208 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._source); };
212 if (!this._source.equals(temp._source)) {
213 org.castor.util.CycleBreaker.releaseCycleHandle(this._source);
214 org.castor.util.CycleBreaker.releaseCycleHandle(temp._source);
217 org.castor.util.CycleBreaker.releaseCycleHandle(this._source);
218 org.castor.util.CycleBreaker.releaseCycleHandle(temp._source);
221 } else if (temp._source != null)
223 if (this._version != null) {
224 if (temp._version == null) return false;
225 if (this._version != temp._version) {
226 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._version);
227 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._version);
228 if (thcycle!=tmcycle) {
229 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._version); };
230 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._version); };
234 if (!this._version.equals(temp._version)) {
235 org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
236 org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
239 org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
240 org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
243 } else if (temp._version != null)
245 if (this._accessionId != null) {
246 if (temp._accessionId == null) return false;
247 if (this._accessionId != temp._accessionId) {
248 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._accessionId);
249 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._accessionId);
250 if (thcycle!=tmcycle) {
251 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId); };
252 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId); };
256 if (!this._accessionId.equals(temp._accessionId)) {
257 org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId);
258 org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId);
261 org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId);
262 org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId);
265 } else if (temp._accessionId != null)
267 if (this._id != null) {
268 if (temp._id == null) return false;
269 if (this._id != temp._id) {
270 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
271 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
272 if (thcycle!=tmcycle) {
273 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
274 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
278 if (!this._id.equals(temp._id)) {
279 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
280 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
283 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
284 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
287 } else if (temp._id != null)
289 if (this._map != null) {
290 if (temp._map == null) return false;
291 if (this._map != temp._map) {
292 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._map);
293 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._map);
294 if (thcycle!=tmcycle) {
295 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._map); };
296 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); };
300 if (!this._map.equals(temp._map)) {
301 org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
302 org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
305 org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
306 org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
309 } else if (temp._map != null)
311 if (this._linkList != null) {
312 if (temp._linkList == null) return false;
313 if (this._linkList != temp._linkList) {
314 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._linkList);
315 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._linkList);
316 if (thcycle!=tmcycle) {
317 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList); };
318 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList); };
322 if (!this._linkList.equals(temp._linkList)) {
323 org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList);
324 org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList);
327 org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList);
328 org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList);
331 } else if (temp._linkList != null)
333 if (this._propertyList != null) {
334 if (temp._propertyList == null) return false;
335 if (this._propertyList != temp._propertyList) {
336 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._propertyList);
337 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._propertyList);
338 if (thcycle!=tmcycle) {
339 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList); };
340 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList); };
344 if (!this._propertyList.equals(temp._propertyList)) {
345 org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
346 org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
349 org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
350 org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
353 } else if (temp._propertyList != null)
361 * Returns the value of field 'accessionId'. The field
362 * 'accessionId' has the following description: TODO: make some
364 * of the database field from which this
365 * accessionId is taken from - should that be a
366 * special property of the dbRef object ?
369 * @return the value of field 'AccessionId'.
371 public java.lang.String getAccessionId(
373 return this._accessionId;
377 * Returns the value of field 'id'. The field 'id' has the
378 * following description: Primary Key for vamsas object
381 * @return the value of field 'Id'.
383 public java.lang.String getId(
392 * @throws java.lang.IndexOutOfBoundsException if the index
393 * given is outside the bounds of the collection
394 * @return the value of the uk.ac.vamsas.objects.core.Link at
397 public uk.ac.vamsas.objects.core.Link getLink(
399 throws java.lang.IndexOutOfBoundsException {
400 // check bounds for index
401 if (index < 0 || index >= this._linkList.size()) {
402 throw new IndexOutOfBoundsException("getLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]");
405 return (uk.ac.vamsas.objects.core.Link) _linkList.get(index);
409 * Method getLink.Returns the contents of the collection in an
410 * Array. <p>Note: Just in case the collection contents are
411 * changing in another thread, we pass a 0-length Array of the
412 * correct type into the API call. This way we <i>know</i>
413 * that the Array returned is of exactly the correct length.
415 * @return this collection as an Array
417 public uk.ac.vamsas.objects.core.Link[] getLink(
419 uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0];
420 return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array);
424 * Method getLinkAsReference.Returns a reference to
425 * '_linkList'. No type checking is performed on any
426 * modifications to the Vector.
428 * @return a reference to the Vector backing this class
430 public java.util.Vector getLinkAsReference(
432 return this._linkList;
436 * Method getLinkCount.
438 * @return the size of this collection
440 public int getLinkCount(
442 return this._linkList.size();
446 * Returns the value of field 'map'. The field 'map' has the
447 * following description: the local mapType maps from the
449 * sequence coordinate frame to the reference
450 * frame defined by the dbRef element.
451 * The mapped mapType is the mapped range defined
452 * on the dbRef element's reference frame.
453 * Conventionally, the unit attribute defaults to 1, or
454 * will be inferred from the local sequence's
455 * dictionary type and any dictionary type associated
456 * with the database being mapped to.
457 * However, it may be used to avoid ambiguity.
460 * @return the value of field 'Map'.
462 public uk.ac.vamsas.objects.core.Map getMap(
468 * Method getProperty.
471 * @throws java.lang.IndexOutOfBoundsException if the index
472 * given is outside the bounds of the collection
473 * @return the value of the uk.ac.vamsas.objects.core.Property
476 public uk.ac.vamsas.objects.core.Property getProperty(
478 throws java.lang.IndexOutOfBoundsException {
479 // check bounds for index
480 if (index < 0 || index >= this._propertyList.size()) {
481 throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
484 return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
488 * Method getProperty.Returns the contents of the collection in
489 * an Array. <p>Note: Just in case the collection contents
490 * are changing in another thread, we pass a 0-length Array of
491 * the correct type into the API call. This way we <i>know</i>
492 * that the Array returned is of exactly the correct length.
494 * @return this collection as an Array
496 public uk.ac.vamsas.objects.core.Property[] getProperty(
498 uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
499 return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array);
503 * Method getPropertyAsReference.Returns a reference to
504 * '_propertyList'. No type checking is performed on any
505 * modifications to the Vector.
507 * @return a reference to the Vector backing this class
509 public java.util.Vector getPropertyAsReference(
511 return this._propertyList;
515 * Method getPropertyCount.
517 * @return the size of this collection
519 public int getPropertyCount(
521 return this._propertyList.size();
525 * Returns the value of field 'source'. The field 'source' has
526 * the following description: TODO Database Naming
527 * Convention: either start using LSID (so
528 * change type to URI) or leave this as an
529 * uncontrolled/unspecified string ID
532 * @return the value of field 'Source'.
534 public java.lang.String getSource(
540 * Returns the value of field 'version'. The field 'version'
541 * has the following description: Version must be specified -
544 * @return the value of field 'Version'.
546 public java.lang.String getVersion(
548 return this._version;
552 * Overrides the java.lang.Object.hashCode method.
554 * The following steps came from <b>Effective Java Programming
555 * Language Guide</b> by Joshua Bloch, Chapter 3
557 * @return a hash code value for the object.
561 int result = super.hashCode();
565 && !org.castor.util.CycleBreaker.startingToCycle(_source)) {
566 result = 37 * result + _source.hashCode();
567 org.castor.util.CycleBreaker.releaseCycleHandle(_source);
570 && !org.castor.util.CycleBreaker.startingToCycle(_version)) {
571 result = 37 * result + _version.hashCode();
572 org.castor.util.CycleBreaker.releaseCycleHandle(_version);
574 if (_accessionId != null
575 && !org.castor.util.CycleBreaker.startingToCycle(_accessionId)) {
576 result = 37 * result + _accessionId.hashCode();
577 org.castor.util.CycleBreaker.releaseCycleHandle(_accessionId);
580 && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
581 result = 37 * result + _id.hashCode();
582 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
585 && !org.castor.util.CycleBreaker.startingToCycle(_map)) {
586 result = 37 * result + _map.hashCode();
587 org.castor.util.CycleBreaker.releaseCycleHandle(_map);
589 if (_linkList != null
590 && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) {
591 result = 37 * result + _linkList.hashCode();
592 org.castor.util.CycleBreaker.releaseCycleHandle(_linkList);
594 if (_propertyList != null
595 && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
596 result = 37 * result + _propertyList.hashCode();
597 org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
606 * @return true if this object is valid according to the schema
608 public boolean isValid(
612 } catch (org.exolab.castor.xml.ValidationException vex) {
622 * @throws org.exolab.castor.xml.MarshalException if object is
623 * null or if any SAXException is thrown during marshaling
624 * @throws org.exolab.castor.xml.ValidationException if this
625 * object is an invalid instance according to the schema
628 final java.io.Writer out)
629 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
630 Marshaller.marshal(this, out);
637 * @throws java.io.IOException if an IOException occurs during
639 * @throws org.exolab.castor.xml.ValidationException if this
640 * object is an invalid instance according to the schema
641 * @throws org.exolab.castor.xml.MarshalException if object is
642 * null or if any SAXException is thrown during marshaling
645 final org.xml.sax.ContentHandler handler)
646 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
647 Marshaller.marshal(this, handler);
652 public void removeAllLink(
654 this._linkList.clear();
659 public void removeAllProperty(
661 this._propertyList.clear();
668 * @return true if the object was removed from the collection.
670 public boolean removeLink(
671 final uk.ac.vamsas.objects.core.Link vLink) {
672 boolean removed = _linkList.remove(vLink);
677 * Method removeLinkAt.
680 * @return the element removed from the collection
682 public uk.ac.vamsas.objects.core.Link removeLinkAt(
684 java.lang.Object obj = this._linkList.remove(index);
685 return (uk.ac.vamsas.objects.core.Link) obj;
689 * Method removeProperty.
692 * @return true if the object was removed from the collection.
694 public boolean removeProperty(
695 final uk.ac.vamsas.objects.core.Property vProperty) {
696 boolean removed = _propertyList.remove(vProperty);
701 * Method removePropertyAt.
704 * @return the element removed from the collection
706 public uk.ac.vamsas.objects.core.Property removePropertyAt(
708 java.lang.Object obj = this._propertyList.remove(index);
709 return (uk.ac.vamsas.objects.core.Property) obj;
713 * Sets the value of field 'accessionId'. The field
714 * 'accessionId' has the following description: TODO: make some
716 * of the database field from which this
717 * accessionId is taken from - should that be a
718 * special property of the dbRef object ?
721 * @param accessionId the value of field 'accessionId'.
723 public void setAccessionId(
724 final java.lang.String accessionId) {
725 this._accessionId = accessionId;
729 * Sets the value of field 'id'. The field 'id' has the
730 * following description: Primary Key for vamsas object
733 * @param id the value of field 'id'.
736 final java.lang.String id) {
745 * @throws java.lang.IndexOutOfBoundsException if the index
746 * given is outside the bounds of the collection
750 final uk.ac.vamsas.objects.core.Link vLink)
751 throws java.lang.IndexOutOfBoundsException {
752 // check bounds for index
753 if (index < 0 || index >= this._linkList.size()) {
754 throw new IndexOutOfBoundsException("setLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]");
757 this._linkList.set(index, vLink);
766 final uk.ac.vamsas.objects.core.Link[] vLinkArray) {
770 for (int i = 0; i < vLinkArray.length; i++) {
771 this._linkList.add(vLinkArray[i]);
776 * Sets the value of '_linkList' by copying the given Vector.
777 * All elements will be checked for type safety.
779 * @param vLinkList the Vector to copy.
782 final java.util.Vector vLinkList) {
784 this._linkList.clear();
786 this._linkList.addAll(vLinkList);
790 * Sets the value of '_linkList' by setting it to the given
791 * Vector. No type checking is performed.
794 * @param linkVector the Vector to set.
796 public void setLinkAsReference(
797 final java.util.Vector linkVector) {
798 this._linkList = linkVector;
802 * Sets the value of field 'map'. The field 'map' has the
803 * following description: the local mapType maps from the
805 * sequence coordinate frame to the reference
806 * frame defined by the dbRef element.
807 * The mapped mapType is the mapped range defined
808 * on the dbRef element's reference frame.
809 * Conventionally, the unit attribute defaults to 1, or
810 * will be inferred from the local sequence's
811 * dictionary type and any dictionary type associated
812 * with the database being mapped to.
813 * However, it may be used to avoid ambiguity.
816 * @param map the value of field 'map'.
819 final uk.ac.vamsas.objects.core.Map map) {
828 * @throws java.lang.IndexOutOfBoundsException if the index
829 * given is outside the bounds of the collection
831 public void setProperty(
833 final uk.ac.vamsas.objects.core.Property vProperty)
834 throws java.lang.IndexOutOfBoundsException {
835 // check bounds for index
836 if (index < 0 || index >= this._propertyList.size()) {
837 throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
840 this._propertyList.set(index, vProperty);
846 * @param vPropertyArray
848 public void setProperty(
849 final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
851 _propertyList.clear();
853 for (int i = 0; i < vPropertyArray.length; i++) {
854 this._propertyList.add(vPropertyArray[i]);
859 * Sets the value of '_propertyList' by copying the given
860 * Vector. All elements will be checked for type safety.
862 * @param vPropertyList the Vector to copy.
864 public void setProperty(
865 final java.util.Vector vPropertyList) {
867 this._propertyList.clear();
869 this._propertyList.addAll(vPropertyList);
873 * Sets the value of '_propertyList' by setting it to the given
874 * Vector. No type checking is performed.
877 * @param propertyVector the Vector to set.
879 public void setPropertyAsReference(
880 final java.util.Vector propertyVector) {
881 this._propertyList = propertyVector;
885 * Sets the value of field 'source'. The field 'source' has the
886 * following description: TODO Database Naming
887 * Convention: either start using LSID (so
888 * change type to URI) or leave this as an
889 * uncontrolled/unspecified string ID
892 * @param source the value of field 'source'.
894 public void setSource(
895 final java.lang.String source) {
896 this._source = source;
900 * Sets the value of field 'version'. The field 'version' has
901 * the following description: Version must be specified -
904 * @param version the value of field 'version'.
906 public void setVersion(
907 final java.lang.String version) {
908 this._version = version;
915 * @throws org.exolab.castor.xml.MarshalException if object is
916 * null or if any SAXException is thrown during marshaling
917 * @throws org.exolab.castor.xml.ValidationException if this
918 * object is an invalid instance according to the schema
919 * @return the unmarshaled uk.ac.vamsas.objects.core.DbRef
921 public static uk.ac.vamsas.objects.core.DbRef unmarshal(
922 final java.io.Reader reader)
923 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
924 return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DbRef.class, reader);
930 * @throws org.exolab.castor.xml.ValidationException if this
931 * object is an invalid instance according to the schema
933 public void validate(
935 throws org.exolab.castor.xml.ValidationException {
936 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
937 validator.validate(this);