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 * From: Offset to first
65 * position in dataset sequence record that
66 * this database entry maps to To: Offset
67 * to last position in dataset sequence
68 * record that this database entry maps to
69 * Start: Offset to first last position in
70 * database entry that first (or offset)
71 * position in sequence maps to End: Offset
72 * to last position in database entry that
73 * last (offset) position in sequence maps
76 private java.util.Vector _mapList;
81 private java.util.Vector _linkList;
84 * Field _propertyList.
86 private java.util.Vector _propertyList;
95 this._mapList = new java.util.Vector();
96 this._linkList = new java.util.Vector();
97 this._propertyList = new java.util.Vector();
109 * @throws java.lang.IndexOutOfBoundsException if the index
110 * given is outside the bounds of the collection
113 final uk.ac.vamsas.objects.core.Link vLink)
114 throws java.lang.IndexOutOfBoundsException {
115 this._linkList.addElement(vLink);
123 * @throws java.lang.IndexOutOfBoundsException if the index
124 * given is outside the bounds of the collection
128 final uk.ac.vamsas.objects.core.Link vLink)
129 throws java.lang.IndexOutOfBoundsException {
130 this._linkList.add(index, vLink);
137 * @throws java.lang.IndexOutOfBoundsException if the index
138 * given is outside the bounds of the collection
141 final uk.ac.vamsas.objects.core.Map vMap)
142 throws java.lang.IndexOutOfBoundsException {
143 this._mapList.addElement(vMap);
151 * @throws java.lang.IndexOutOfBoundsException if the index
152 * given is outside the bounds of the collection
156 final uk.ac.vamsas.objects.core.Map vMap)
157 throws java.lang.IndexOutOfBoundsException {
158 this._mapList.add(index, vMap);
165 * @throws java.lang.IndexOutOfBoundsException if the index
166 * given is outside the bounds of the collection
168 public void addProperty(
169 final uk.ac.vamsas.objects.core.Property vProperty)
170 throws java.lang.IndexOutOfBoundsException {
171 this._propertyList.addElement(vProperty);
179 * @throws java.lang.IndexOutOfBoundsException if the index
180 * given is outside the bounds of the collection
182 public void addProperty(
184 final uk.ac.vamsas.objects.core.Property vProperty)
185 throws java.lang.IndexOutOfBoundsException {
186 this._propertyList.add(index, vProperty);
190 * Method enumerateLink.
192 * @return an Enumeration over all
193 * uk.ac.vamsas.objects.core.Link elements
195 public java.util.Enumeration enumerateLink(
197 return this._linkList.elements();
201 * Method enumerateMap.
203 * @return an Enumeration over all
204 * uk.ac.vamsas.objects.core.Map elements
206 public java.util.Enumeration enumerateMap(
208 return this._mapList.elements();
212 * Method enumerateProperty.
214 * @return an Enumeration over all
215 * uk.ac.vamsas.objects.core.Property elements
217 public java.util.Enumeration enumerateProperty(
219 return this._propertyList.elements();
223 * Overrides the java.lang.Object.equals method.
226 * @return true if the objects are equal.
228 public boolean equals(
229 final java.lang.Object obj) {
233 if (super.equals(obj)==false)
236 if (obj instanceof DbRef) {
238 DbRef temp = (DbRef)obj;
239 if (this._source != null) {
240 if (temp._source == null) return false;
241 else if (!(this._source.equals(temp._source)))
244 else if (temp._source != null)
246 if (this._version != null) {
247 if (temp._version == null) return false;
248 else if (!(this._version.equals(temp._version)))
251 else if (temp._version != null)
253 if (this._accessionId != null) {
254 if (temp._accessionId == null) return false;
255 else if (!(this._accessionId.equals(temp._accessionId)))
258 else if (temp._accessionId != null)
260 if (this._id != null) {
261 if (temp._id == null) return false;
262 else if (!(this._id.equals(temp._id)))
265 else if (temp._id != null)
267 if (this._mapList != null) {
268 if (temp._mapList == null) return false;
269 else if (!(this._mapList.equals(temp._mapList)))
272 else if (temp._mapList != null)
274 if (this._linkList != null) {
275 if (temp._linkList == null) return false;
276 else if (!(this._linkList.equals(temp._linkList)))
279 else if (temp._linkList != null)
281 if (this._propertyList != null) {
282 if (temp._propertyList == null) return false;
283 else if (!(this._propertyList.equals(temp._propertyList)))
286 else if (temp._propertyList != null)
294 * Returns the value of field 'accessionId'. The field
295 * 'accessionId' has the following description: TODO: make some
297 * of the database field from which this
298 * accessionId is taken from - should that be a
299 * special property of the dbRef object ?
302 * @return the value of field 'AccessionId'.
304 public java.lang.String getAccessionId(
306 return this._accessionId;
310 * Returns the value of field 'id'. The field 'id' has the
311 * following description: Primary Key for vamsas object
314 * @return the value of field 'Id'.
316 public java.lang.String getId(
325 * @throws java.lang.IndexOutOfBoundsException if the index
326 * given is outside the bounds of the collection
327 * @return the value of the uk.ac.vamsas.objects.core.Link at
330 public uk.ac.vamsas.objects.core.Link getLink(
332 throws java.lang.IndexOutOfBoundsException {
333 // check bounds for index
334 if (index < 0 || index >= this._linkList.size()) {
335 throw new IndexOutOfBoundsException("getLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]");
338 return (uk.ac.vamsas.objects.core.Link) _linkList.get(index);
342 * Method getLink.Returns the contents of the collection in an
343 * Array. <p>Note: Just in case the collection contents are
344 * changing in another thread, we pass a 0-length Array of the
345 * correct type into the API call. This way we <i>know</i>
346 * that the Array returned is of exactly the correct length.
348 * @return this collection as an Array
350 public uk.ac.vamsas.objects.core.Link[] getLink(
352 uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0];
353 return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array);
357 * Method getLinkAsReference.Returns a reference to
358 * '_linkList'. No type checking is performed on any
359 * modifications to the Vector.
361 * @return a reference to the Vector backing this class
363 public java.util.Vector getLinkAsReference(
365 return this._linkList;
369 * Method getLinkCount.
371 * @return the size of this collection
373 public int getLinkCount(
375 return this._linkList.size();
382 * @throws java.lang.IndexOutOfBoundsException if the index
383 * given is outside the bounds of the collection
384 * @return the value of the uk.ac.vamsas.objects.core.Map at
387 public uk.ac.vamsas.objects.core.Map getMap(
389 throws java.lang.IndexOutOfBoundsException {
390 // check bounds for index
391 if (index < 0 || index >= this._mapList.size()) {
392 throw new IndexOutOfBoundsException("getMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]");
395 return (uk.ac.vamsas.objects.core.Map) _mapList.get(index);
399 * Method getMap.Returns the contents of the collection in an
400 * Array. <p>Note: Just in case the collection contents are
401 * changing in another thread, we pass a 0-length Array of the
402 * correct type into the API call. This way we <i>know</i>
403 * that the Array returned is of exactly the correct length.
405 * @return this collection as an Array
407 public uk.ac.vamsas.objects.core.Map[] getMap(
409 uk.ac.vamsas.objects.core.Map[] array = new uk.ac.vamsas.objects.core.Map[0];
410 return (uk.ac.vamsas.objects.core.Map[]) this._mapList.toArray(array);
414 * Method getMapAsReference.Returns a reference to '_mapList'.
415 * No type checking is performed on any modifications to the
418 * @return a reference to the Vector backing this class
420 public java.util.Vector getMapAsReference(
422 return this._mapList;
426 * Method getMapCount.
428 * @return the size of this collection
430 public int getMapCount(
432 return this._mapList.size();
436 * Method getProperty.
439 * @throws java.lang.IndexOutOfBoundsException if the index
440 * given is outside the bounds of the collection
441 * @return the value of the uk.ac.vamsas.objects.core.Property
444 public uk.ac.vamsas.objects.core.Property getProperty(
446 throws java.lang.IndexOutOfBoundsException {
447 // check bounds for index
448 if (index < 0 || index >= this._propertyList.size()) {
449 throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
452 return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
456 * Method getProperty.Returns the contents of the collection in
457 * an Array. <p>Note: Just in case the collection contents
458 * are changing in another thread, we pass a 0-length Array of
459 * the correct type into the API call. This way we <i>know</i>
460 * that the Array returned is of exactly the correct length.
462 * @return this collection as an Array
464 public uk.ac.vamsas.objects.core.Property[] getProperty(
466 uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
467 return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array);
471 * Method getPropertyAsReference.Returns a reference to
472 * '_propertyList'. No type checking is performed on any
473 * modifications to the Vector.
475 * @return a reference to the Vector backing this class
477 public java.util.Vector getPropertyAsReference(
479 return this._propertyList;
483 * Method getPropertyCount.
485 * @return the size of this collection
487 public int getPropertyCount(
489 return this._propertyList.size();
493 * Returns the value of field 'source'. The field 'source' has
494 * the following description: TODO Database Naming
495 * Convention: either start using LSID (so
496 * change type to URI) or leave this as an
497 * uncontrolled/unspecified string ID
500 * @return the value of field 'Source'.
502 public java.lang.String getSource(
508 * Returns the value of field 'version'. The field 'version'
509 * has the following description: Version must be specified -
512 * @return the value of field 'Version'.
514 public java.lang.String getVersion(
516 return this._version;
520 * Overrides the java.lang.Object.hashCode method.
522 * The following steps came from <b>Effective Java Programming
523 * Language Guide</b> by Joshua Bloch, Chapter 3
525 * @return a hash code value for the object.
529 int result = super.hashCode();
532 if (_source != null) {
533 result = 37 * result + _source.hashCode();
535 if (_version != null) {
536 result = 37 * result + _version.hashCode();
538 if (_accessionId != null) {
539 result = 37 * result + _accessionId.hashCode();
542 result = 37 * result + _id.hashCode();
544 if (_mapList != null) {
545 result = 37 * result + _mapList.hashCode();
547 if (_linkList != null) {
548 result = 37 * result + _linkList.hashCode();
550 if (_propertyList != null) {
551 result = 37 * result + _propertyList.hashCode();
560 * @return true if this object is valid according to the schema
562 public boolean isValid(
566 } catch (org.exolab.castor.xml.ValidationException vex) {
576 * @throws org.exolab.castor.xml.MarshalException if object is
577 * null or if any SAXException is thrown during marshaling
578 * @throws org.exolab.castor.xml.ValidationException if this
579 * object is an invalid instance according to the schema
582 final java.io.Writer out)
583 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
584 Marshaller.marshal(this, out);
591 * @throws java.io.IOException if an IOException occurs during
593 * @throws org.exolab.castor.xml.ValidationException if this
594 * object is an invalid instance according to the schema
595 * @throws org.exolab.castor.xml.MarshalException if object is
596 * null or if any SAXException is thrown during marshaling
599 final org.xml.sax.ContentHandler handler)
600 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
601 Marshaller.marshal(this, handler);
606 public void removeAllLink(
608 this._linkList.clear();
613 public void removeAllMap(
615 this._mapList.clear();
620 public void removeAllProperty(
622 this._propertyList.clear();
629 * @return true if the object was removed from the collection.
631 public boolean removeLink(
632 final uk.ac.vamsas.objects.core.Link vLink) {
633 boolean removed = _linkList.remove(vLink);
638 * Method removeLinkAt.
641 * @return the element removed from the collection
643 public uk.ac.vamsas.objects.core.Link removeLinkAt(
645 java.lang.Object obj = this._linkList.remove(index);
646 return (uk.ac.vamsas.objects.core.Link) obj;
653 * @return true if the object was removed from the collection.
655 public boolean removeMap(
656 final uk.ac.vamsas.objects.core.Map vMap) {
657 boolean removed = _mapList.remove(vMap);
662 * Method removeMapAt.
665 * @return the element removed from the collection
667 public uk.ac.vamsas.objects.core.Map removeMapAt(
669 java.lang.Object obj = this._mapList.remove(index);
670 return (uk.ac.vamsas.objects.core.Map) obj;
674 * Method removeProperty.
677 * @return true if the object was removed from the collection.
679 public boolean removeProperty(
680 final uk.ac.vamsas.objects.core.Property vProperty) {
681 boolean removed = _propertyList.remove(vProperty);
686 * Method removePropertyAt.
689 * @return the element removed from the collection
691 public uk.ac.vamsas.objects.core.Property removePropertyAt(
693 java.lang.Object obj = this._propertyList.remove(index);
694 return (uk.ac.vamsas.objects.core.Property) obj;
698 * Sets the value of field 'accessionId'. The field
699 * 'accessionId' has the following description: TODO: make some
701 * of the database field from which this
702 * accessionId is taken from - should that be a
703 * special property of the dbRef object ?
706 * @param accessionId the value of field 'accessionId'.
708 public void setAccessionId(
709 final java.lang.String accessionId) {
710 this._accessionId = accessionId;
714 * Sets the value of field 'id'. The field 'id' has the
715 * following description: Primary Key for vamsas object
718 * @param id the value of field 'id'.
721 final java.lang.String id) {
730 * @throws java.lang.IndexOutOfBoundsException if the index
731 * given is outside the bounds of the collection
735 final uk.ac.vamsas.objects.core.Link vLink)
736 throws java.lang.IndexOutOfBoundsException {
737 // check bounds for index
738 if (index < 0 || index >= this._linkList.size()) {
739 throw new IndexOutOfBoundsException("setLink: Index value '" + index + "' not in range [0.." + (this._linkList.size() - 1) + "]");
742 this._linkList.set(index, vLink);
751 final uk.ac.vamsas.objects.core.Link[] vLinkArray) {
755 for (int i = 0; i < vLinkArray.length; i++) {
756 this._linkList.add(vLinkArray[i]);
761 * Sets the value of '_linkList' by copying the given Vector.
762 * All elements will be checked for type safety.
764 * @param vLinkList the Vector to copy.
767 final java.util.Vector vLinkList) {
769 this._linkList.clear();
771 this._linkList.addAll(vLinkList);
775 * Sets the value of '_linkList' by setting it to the given
776 * Vector. No type checking is performed.
779 * @param linkVector the Vector to set.
781 public void setLinkAsReference(
782 final java.util.Vector linkVector) {
783 this._linkList = linkVector;
791 * @throws java.lang.IndexOutOfBoundsException if the index
792 * given is outside the bounds of the collection
796 final uk.ac.vamsas.objects.core.Map vMap)
797 throws java.lang.IndexOutOfBoundsException {
798 // check bounds for index
799 if (index < 0 || index >= this._mapList.size()) {
800 throw new IndexOutOfBoundsException("setMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]");
803 this._mapList.set(index, vMap);
812 final uk.ac.vamsas.objects.core.Map[] vMapArray) {
816 for (int i = 0; i < vMapArray.length; i++) {
817 this._mapList.add(vMapArray[i]);
822 * Sets the value of '_mapList' by copying the given Vector.
823 * All elements will be checked for type safety.
825 * @param vMapList the Vector to copy.
828 final java.util.Vector vMapList) {
830 this._mapList.clear();
832 this._mapList.addAll(vMapList);
836 * Sets the value of '_mapList' by setting it to the given
837 * Vector. No type checking is performed.
840 * @param mapVector the Vector to set.
842 public void setMapAsReference(
843 final java.util.Vector mapVector) {
844 this._mapList = mapVector;
852 * @throws java.lang.IndexOutOfBoundsException if the index
853 * given is outside the bounds of the collection
855 public void setProperty(
857 final uk.ac.vamsas.objects.core.Property vProperty)
858 throws java.lang.IndexOutOfBoundsException {
859 // check bounds for index
860 if (index < 0 || index >= this._propertyList.size()) {
861 throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
864 this._propertyList.set(index, vProperty);
870 * @param vPropertyArray
872 public void setProperty(
873 final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
875 _propertyList.clear();
877 for (int i = 0; i < vPropertyArray.length; i++) {
878 this._propertyList.add(vPropertyArray[i]);
883 * Sets the value of '_propertyList' by copying the given
884 * Vector. All elements will be checked for type safety.
886 * @param vPropertyList the Vector to copy.
888 public void setProperty(
889 final java.util.Vector vPropertyList) {
891 this._propertyList.clear();
893 this._propertyList.addAll(vPropertyList);
897 * Sets the value of '_propertyList' by setting it to the given
898 * Vector. No type checking is performed.
901 * @param propertyVector the Vector to set.
903 public void setPropertyAsReference(
904 final java.util.Vector propertyVector) {
905 this._propertyList = propertyVector;
909 * Sets the value of field 'source'. The field 'source' has the
910 * following description: TODO Database Naming
911 * Convention: either start using LSID (so
912 * change type to URI) or leave this as an
913 * uncontrolled/unspecified string ID
916 * @param source the value of field 'source'.
918 public void setSource(
919 final java.lang.String source) {
920 this._source = source;
924 * Sets the value of field 'version'. The field 'version' has
925 * the following description: Version must be specified -
928 * @param version the value of field 'version'.
930 public void setVersion(
931 final java.lang.String version) {
932 this._version = version;
939 * @throws org.exolab.castor.xml.MarshalException if object is
940 * null or if any SAXException is thrown during marshaling
941 * @throws org.exolab.castor.xml.ValidationException if this
942 * object is an invalid instance according to the schema
943 * @return the unmarshaled uk.ac.vamsas.objects.core.DbRef
945 public static uk.ac.vamsas.objects.core.DbRef unmarshal(
946 final java.io.Reader reader)
947 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
948 return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DbRef.class, reader);
954 * @throws org.exolab.castor.xml.ValidationException if this
955 * object is an invalid instance according to the schema
957 public void validate(
959 throws org.exolab.castor.xml.ValidationException {
960 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
961 validator.validate(this);