applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / DbRef.java
1 /*
2  * This file is part of the Vamsas Client version 0.1. 
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
4  *  Andrew Waterhouse and Dominik Lindner.
5  * 
6  * Earlier versions have also been incorporated into Jalview version 2.4 
7  * since 2008, and TOPALi version 2 since 2007.
8  * 
9  * The Vamsas Client is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *  
14  * The Vamsas Client is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 package uk.ac.vamsas.objects.core;
23
24 //---------------------------------/
25 //- Imported classes and packages -/
26 //---------------------------------/
27
28 import org.exolab.castor.xml.Marshaller;
29 import org.exolab.castor.xml.Unmarshaller;
30
31 /**
32  * Store a list of database references for this sequence record - with optional
33  * mapping from database sequence to the given sequence record
34  * 
35  * @version $Revision$ $Date: 2007-06-29 13:23:12 +0100 (Fri, 29 Jun 2007)
36  *          $
37  */
38 public class DbRef extends uk.ac.vamsas.client.Vobject implements
39     java.io.Serializable {
40
41   // --------------------------/
42   // - Class/Member Variables -/
43   // --------------------------/
44
45   /**
46    * TODO Database Naming Convention: either start using LSID (so change type to
47    * URI) or leave this as an uncontrolled/unspecified string ID
48    * 
49    */
50   private java.lang.String _source;
51
52   /**
53    * Version must be specified -
54    * 
55    */
56   private java.lang.String _version;
57
58   /**
59    * TODO: make some specification of the database field from which this
60    * accessionId is taken from - should that be a special property of the dbRef
61    * object ?
62    * 
63    */
64   private java.lang.String _accessionId;
65
66   /**
67    * Primary Key for vamsas object referencing
68    */
69   private java.lang.String _id;
70
71   /**
72    * the local mapType maps from the parent sequence coordinate frame to the
73    * reference frame defined by the dbRef element. The mapped mapType is the
74    * mapped range defined on the dbRef element's reference frame.
75    * Conventionally, the unit attribute defaults to 1, or will be inferred from
76    * the local sequence's dictionary type and any dictionary type associated
77    * with the database being mapped to. However, it may be used to avoid
78    * ambiguity.
79    * 
80    */
81   private java.util.Vector _mapList;
82
83   /**
84    * Field _linkList.
85    */
86   private java.util.Vector _linkList;
87
88   /**
89    * Field _propertyList.
90    */
91   private java.util.Vector _propertyList;
92
93   // ----------------/
94   // - Constructors -/
95   // ----------------/
96
97   public DbRef() {
98     super();
99     this._mapList = new java.util.Vector();
100     this._linkList = new java.util.Vector();
101     this._propertyList = new java.util.Vector();
102   }
103
104   // -----------/
105   // - Methods -/
106   // -----------/
107
108   /**
109    * 
110    * 
111    * @param vLink
112    * @throws java.lang.IndexOutOfBoundsException
113    *           if the index given is outside the bounds of the collection
114    */
115   public void addLink(final uk.ac.vamsas.objects.core.Link vLink)
116       throws java.lang.IndexOutOfBoundsException {
117     this._linkList.addElement(vLink);
118   }
119
120   /**
121    * 
122    * 
123    * @param index
124    * @param vLink
125    * @throws java.lang.IndexOutOfBoundsException
126    *           if the index given is outside the bounds of the collection
127    */
128   public void addLink(final int index,
129       final uk.ac.vamsas.objects.core.Link vLink)
130       throws java.lang.IndexOutOfBoundsException {
131     this._linkList.add(index, vLink);
132   }
133
134   /**
135    * 
136    * 
137    * @param vMap
138    * @throws java.lang.IndexOutOfBoundsException
139    *           if the index given is outside the bounds of the collection
140    */
141   public void addMap(final uk.ac.vamsas.objects.core.Map vMap)
142       throws java.lang.IndexOutOfBoundsException {
143     this._mapList.addElement(vMap);
144   }
145
146   /**
147    * 
148    * 
149    * @param index
150    * @param vMap
151    * @throws java.lang.IndexOutOfBoundsException
152    *           if the index given is outside the bounds of the collection
153    */
154   public void addMap(final int index, final uk.ac.vamsas.objects.core.Map vMap)
155       throws java.lang.IndexOutOfBoundsException {
156     this._mapList.add(index, vMap);
157   }
158
159   /**
160    * 
161    * 
162    * @param vProperty
163    * @throws java.lang.IndexOutOfBoundsException
164    *           if the index given is outside the bounds of the collection
165    */
166   public void addProperty(final uk.ac.vamsas.objects.core.Property vProperty)
167       throws java.lang.IndexOutOfBoundsException {
168     this._propertyList.addElement(vProperty);
169   }
170
171   /**
172    * 
173    * 
174    * @param index
175    * @param vProperty
176    * @throws java.lang.IndexOutOfBoundsException
177    *           if the index given is outside the bounds of the collection
178    */
179   public void addProperty(final int index,
180       final uk.ac.vamsas.objects.core.Property vProperty)
181       throws java.lang.IndexOutOfBoundsException {
182     this._propertyList.add(index, vProperty);
183   }
184
185   /**
186    * Method enumerateLink.
187    * 
188    * @return an Enumeration over all uk.ac.vamsas.objects.core.Link elements
189    */
190   public java.util.Enumeration enumerateLink() {
191     return this._linkList.elements();
192   }
193
194   /**
195    * Method enumerateMap.
196    * 
197    * @return an Enumeration over all uk.ac.vamsas.objects.core.Map elements
198    */
199   public java.util.Enumeration enumerateMap() {
200     return this._mapList.elements();
201   }
202
203   /**
204    * Method enumerateProperty.
205    * 
206    * @return an Enumeration over all uk.ac.vamsas.objects.core.Property elements
207    */
208   public java.util.Enumeration enumerateProperty() {
209     return this._propertyList.elements();
210   }
211
212   /**
213    * Overrides the java.lang.Object.equals method.
214    * 
215    * @param obj
216    * @return true if the objects are equal.
217    */
218   public boolean equals(final java.lang.Object obj) {
219     if (this == obj)
220       return true;
221
222     if (super.equals(obj) == false)
223       return false;
224
225     if (obj instanceof DbRef) {
226
227       DbRef temp = (DbRef) obj;
228       boolean thcycle;
229       boolean tmcycle;
230       if (this._source != null) {
231         if (temp._source == null)
232           return false;
233         if (this._source != temp._source) {
234           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._source);
235           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._source);
236           if (thcycle != tmcycle) {
237             if (!thcycle) {
238               org.castor.util.CycleBreaker.releaseCycleHandle(this._source);
239             }
240             ;
241             if (!tmcycle) {
242               org.castor.util.CycleBreaker.releaseCycleHandle(temp._source);
243             }
244             ;
245             return false;
246           }
247           if (!thcycle) {
248             if (!this._source.equals(temp._source)) {
249               org.castor.util.CycleBreaker.releaseCycleHandle(this._source);
250               org.castor.util.CycleBreaker.releaseCycleHandle(temp._source);
251               return false;
252             }
253             org.castor.util.CycleBreaker.releaseCycleHandle(this._source);
254             org.castor.util.CycleBreaker.releaseCycleHandle(temp._source);
255           }
256         }
257       } else if (temp._source != null)
258         return false;
259       if (this._version != null) {
260         if (temp._version == null)
261           return false;
262         if (this._version != temp._version) {
263           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._version);
264           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._version);
265           if (thcycle != tmcycle) {
266             if (!thcycle) {
267               org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
268             }
269             ;
270             if (!tmcycle) {
271               org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
272             }
273             ;
274             return false;
275           }
276           if (!thcycle) {
277             if (!this._version.equals(temp._version)) {
278               org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
279               org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
280               return false;
281             }
282             org.castor.util.CycleBreaker.releaseCycleHandle(this._version);
283             org.castor.util.CycleBreaker.releaseCycleHandle(temp._version);
284           }
285         }
286       } else if (temp._version != null)
287         return false;
288       if (this._accessionId != null) {
289         if (temp._accessionId == null)
290           return false;
291         if (this._accessionId != temp._accessionId) {
292           thcycle = org.castor.util.CycleBreaker
293               .startingToCycle(this._accessionId);
294           tmcycle = org.castor.util.CycleBreaker
295               .startingToCycle(temp._accessionId);
296           if (thcycle != tmcycle) {
297             if (!thcycle) {
298               org.castor.util.CycleBreaker
299                   .releaseCycleHandle(this._accessionId);
300             }
301             ;
302             if (!tmcycle) {
303               org.castor.util.CycleBreaker
304                   .releaseCycleHandle(temp._accessionId);
305             }
306             ;
307             return false;
308           }
309           if (!thcycle) {
310             if (!this._accessionId.equals(temp._accessionId)) {
311               org.castor.util.CycleBreaker
312                   .releaseCycleHandle(this._accessionId);
313               org.castor.util.CycleBreaker
314                   .releaseCycleHandle(temp._accessionId);
315               return false;
316             }
317             org.castor.util.CycleBreaker.releaseCycleHandle(this._accessionId);
318             org.castor.util.CycleBreaker.releaseCycleHandle(temp._accessionId);
319           }
320         }
321       } else if (temp._accessionId != null)
322         return false;
323       if (this._id != null) {
324         if (temp._id == null)
325           return false;
326         if (this._id != temp._id) {
327           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
328           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
329           if (thcycle != tmcycle) {
330             if (!thcycle) {
331               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
332             }
333             ;
334             if (!tmcycle) {
335               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
336             }
337             ;
338             return false;
339           }
340           if (!thcycle) {
341             if (!this._id.equals(temp._id)) {
342               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
343               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
344               return false;
345             }
346             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
347             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
348           }
349         }
350       } else if (temp._id != null)
351         return false;
352       if (this._mapList != null) {
353         if (temp._mapList == null)
354           return false;
355         if (this._mapList != temp._mapList) {
356           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._mapList);
357           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._mapList);
358           if (thcycle != tmcycle) {
359             if (!thcycle) {
360               org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList);
361             }
362             ;
363             if (!tmcycle) {
364               org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList);
365             }
366             ;
367             return false;
368           }
369           if (!thcycle) {
370             if (!this._mapList.equals(temp._mapList)) {
371               org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList);
372               org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList);
373               return false;
374             }
375             org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList);
376             org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList);
377           }
378         }
379       } else if (temp._mapList != null)
380         return false;
381       if (this._linkList != null) {
382         if (temp._linkList == null)
383           return false;
384         if (this._linkList != temp._linkList) {
385           thcycle = org.castor.util.CycleBreaker
386               .startingToCycle(this._linkList);
387           tmcycle = org.castor.util.CycleBreaker
388               .startingToCycle(temp._linkList);
389           if (thcycle != tmcycle) {
390             if (!thcycle) {
391               org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList);
392             }
393             ;
394             if (!tmcycle) {
395               org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList);
396             }
397             ;
398             return false;
399           }
400           if (!thcycle) {
401             if (!this._linkList.equals(temp._linkList)) {
402               org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList);
403               org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList);
404               return false;
405             }
406             org.castor.util.CycleBreaker.releaseCycleHandle(this._linkList);
407             org.castor.util.CycleBreaker.releaseCycleHandle(temp._linkList);
408           }
409         }
410       } else if (temp._linkList != null)
411         return false;
412       if (this._propertyList != null) {
413         if (temp._propertyList == null)
414           return false;
415         if (this._propertyList != temp._propertyList) {
416           thcycle = org.castor.util.CycleBreaker
417               .startingToCycle(this._propertyList);
418           tmcycle = org.castor.util.CycleBreaker
419               .startingToCycle(temp._propertyList);
420           if (thcycle != tmcycle) {
421             if (!thcycle) {
422               org.castor.util.CycleBreaker
423                   .releaseCycleHandle(this._propertyList);
424             }
425             ;
426             if (!tmcycle) {
427               org.castor.util.CycleBreaker
428                   .releaseCycleHandle(temp._propertyList);
429             }
430             ;
431             return false;
432           }
433           if (!thcycle) {
434             if (!this._propertyList.equals(temp._propertyList)) {
435               org.castor.util.CycleBreaker
436                   .releaseCycleHandle(this._propertyList);
437               org.castor.util.CycleBreaker
438                   .releaseCycleHandle(temp._propertyList);
439               return false;
440             }
441             org.castor.util.CycleBreaker.releaseCycleHandle(this._propertyList);
442             org.castor.util.CycleBreaker.releaseCycleHandle(temp._propertyList);
443           }
444         }
445       } else if (temp._propertyList != null)
446         return false;
447       return true;
448     }
449     return false;
450   }
451
452   /**
453    * Returns the value of field 'accessionId'. The field 'accessionId' has the
454    * following description: TODO: make some specification of the database field
455    * from which this accessionId is taken from - should that be a special
456    * property of the dbRef object ?
457    * 
458    * 
459    * @return the value of field 'AccessionId'.
460    */
461   public java.lang.String getAccessionId() {
462     return this._accessionId;
463   }
464
465   /**
466    * Returns the value of field 'id'. The field 'id' has the following
467    * description: Primary Key for vamsas object referencing
468    * 
469    * @return the value of field 'Id'.
470    */
471   public java.lang.String getId() {
472     return this._id;
473   }
474
475   /**
476    * Method getLink.
477    * 
478    * @param index
479    * @throws java.lang.IndexOutOfBoundsException
480    *           if the index given is outside the bounds of the collection
481    * @return the value of the uk.ac.vamsas.objects.core.Link at the given index
482    */
483   public uk.ac.vamsas.objects.core.Link getLink(final int index)
484       throws java.lang.IndexOutOfBoundsException {
485     // check bounds for index
486     if (index < 0 || index >= this._linkList.size()) {
487       throw new IndexOutOfBoundsException("getLink: Index value '" + index
488           + "' not in range [0.." + (this._linkList.size() - 1) + "]");
489     }
490
491     return (uk.ac.vamsas.objects.core.Link) _linkList.get(index);
492   }
493
494   /**
495    * Method getLink.Returns the contents of the collection in an Array.
496    * <p>
497    * Note: Just in case the collection contents are changing in another thread,
498    * we pass a 0-length Array of the correct type into the API call. This way we
499    * <i>know</i> that the Array returned is of exactly the correct length.
500    * 
501    * @return this collection as an Array
502    */
503   public uk.ac.vamsas.objects.core.Link[] getLink() {
504     uk.ac.vamsas.objects.core.Link[] array = new uk.ac.vamsas.objects.core.Link[0];
505     return (uk.ac.vamsas.objects.core.Link[]) this._linkList.toArray(array);
506   }
507
508   /**
509    * Method getLinkAsReference.Returns a reference to '_linkList'. No type
510    * checking is performed on any modifications to the Vector.
511    * 
512    * @return a reference to the Vector backing this class
513    */
514   public java.util.Vector getLinkAsReference() {
515     return this._linkList;
516   }
517
518   /**
519    * Method getLinkCount.
520    * 
521    * @return the size of this collection
522    */
523   public int getLinkCount() {
524     return this._linkList.size();
525   }
526
527   /**
528    * Method getMap.
529    * 
530    * @param index
531    * @throws java.lang.IndexOutOfBoundsException
532    *           if the index given is outside the bounds of the collection
533    * @return the value of the uk.ac.vamsas.objects.core.Map at the given index
534    */
535   public uk.ac.vamsas.objects.core.Map getMap(final int index)
536       throws java.lang.IndexOutOfBoundsException {
537     // check bounds for index
538     if (index < 0 || index >= this._mapList.size()) {
539       throw new IndexOutOfBoundsException("getMap: Index value '" + index
540           + "' not in range [0.." + (this._mapList.size() - 1) + "]");
541     }
542
543     return (uk.ac.vamsas.objects.core.Map) _mapList.get(index);
544   }
545
546   /**
547    * Method getMap.Returns the contents of the collection in an Array.
548    * <p>
549    * Note: Just in case the collection contents are changing in another thread,
550    * we pass a 0-length Array of the correct type into the API call. This way we
551    * <i>know</i> that the Array returned is of exactly the correct length.
552    * 
553    * @return this collection as an Array
554    */
555   public uk.ac.vamsas.objects.core.Map[] getMap() {
556     uk.ac.vamsas.objects.core.Map[] array = new uk.ac.vamsas.objects.core.Map[0];
557     return (uk.ac.vamsas.objects.core.Map[]) this._mapList.toArray(array);
558   }
559
560   /**
561    * Method getMapAsReference.Returns a reference to '_mapList'. No type
562    * checking is performed on any modifications to the Vector.
563    * 
564    * @return a reference to the Vector backing this class
565    */
566   public java.util.Vector getMapAsReference() {
567     return this._mapList;
568   }
569
570   /**
571    * Method getMapCount.
572    * 
573    * @return the size of this collection
574    */
575   public int getMapCount() {
576     return this._mapList.size();
577   }
578
579   /**
580    * Method getProperty.
581    * 
582    * @param index
583    * @throws java.lang.IndexOutOfBoundsException
584    *           if the index given is outside the bounds of the collection
585    * @return the value of the uk.ac.vamsas.objects.core.Property at the given
586    *         index
587    */
588   public uk.ac.vamsas.objects.core.Property getProperty(final int index)
589       throws java.lang.IndexOutOfBoundsException {
590     // check bounds for index
591     if (index < 0 || index >= this._propertyList.size()) {
592       throw new IndexOutOfBoundsException("getProperty: Index value '" + index
593           + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
594     }
595
596     return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
597   }
598
599   /**
600    * Method getProperty.Returns the contents of the collection in an Array.
601    * <p>
602    * Note: Just in case the collection contents are changing in another thread,
603    * we pass a 0-length Array of the correct type into the API call. This way we
604    * <i>know</i> that the Array returned is of exactly the correct length.
605    * 
606    * @return this collection as an Array
607    */
608   public uk.ac.vamsas.objects.core.Property[] getProperty() {
609     uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
610     return (uk.ac.vamsas.objects.core.Property[]) this._propertyList
611         .toArray(array);
612   }
613
614   /**
615    * Method getPropertyAsReference.Returns a reference to '_propertyList'. No
616    * type checking is performed on any modifications to the Vector.
617    * 
618    * @return a reference to the Vector backing this class
619    */
620   public java.util.Vector getPropertyAsReference() {
621     return this._propertyList;
622   }
623
624   /**
625    * Method getPropertyCount.
626    * 
627    * @return the size of this collection
628    */
629   public int getPropertyCount() {
630     return this._propertyList.size();
631   }
632
633   /**
634    * Returns the value of field 'source'. The field 'source' has the following
635    * description: TODO Database Naming Convention: either start using LSID (so
636    * change type to URI) or leave this as an uncontrolled/unspecified string ID
637    * 
638    * 
639    * @return the value of field 'Source'.
640    */
641   public java.lang.String getSource() {
642     return this._source;
643   }
644
645   /**
646    * Returns the value of field 'version'. The field 'version' has the following
647    * description: Version must be specified -
648    * 
649    * 
650    * @return the value of field 'Version'.
651    */
652   public java.lang.String getVersion() {
653     return this._version;
654   }
655
656   /**
657    * Overrides the java.lang.Object.hashCode method.
658    * <p>
659    * The following steps came from <b>Effective Java Programming Language
660    * Guide</b> by Joshua Bloch, Chapter 3
661    * 
662    * @return a hash code value for the object.
663    */
664   public int hashCode() {
665     int result = super.hashCode();
666
667     long tmp;
668     if (_source != null
669         && !org.castor.util.CycleBreaker.startingToCycle(_source)) {
670       result = 37 * result + _source.hashCode();
671       org.castor.util.CycleBreaker.releaseCycleHandle(_source);
672     }
673     if (_version != null
674         && !org.castor.util.CycleBreaker.startingToCycle(_version)) {
675       result = 37 * result + _version.hashCode();
676       org.castor.util.CycleBreaker.releaseCycleHandle(_version);
677     }
678     if (_accessionId != null
679         && !org.castor.util.CycleBreaker.startingToCycle(_accessionId)) {
680       result = 37 * result + _accessionId.hashCode();
681       org.castor.util.CycleBreaker.releaseCycleHandle(_accessionId);
682     }
683     if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
684       result = 37 * result + _id.hashCode();
685       org.castor.util.CycleBreaker.releaseCycleHandle(_id);
686     }
687     if (_mapList != null
688         && !org.castor.util.CycleBreaker.startingToCycle(_mapList)) {
689       result = 37 * result + _mapList.hashCode();
690       org.castor.util.CycleBreaker.releaseCycleHandle(_mapList);
691     }
692     if (_linkList != null
693         && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) {
694       result = 37 * result + _linkList.hashCode();
695       org.castor.util.CycleBreaker.releaseCycleHandle(_linkList);
696     }
697     if (_propertyList != null
698         && !org.castor.util.CycleBreaker.startingToCycle(_propertyList)) {
699       result = 37 * result + _propertyList.hashCode();
700       org.castor.util.CycleBreaker.releaseCycleHandle(_propertyList);
701     }
702
703     return result;
704   }
705
706   /**
707    * Method isValid.
708    * 
709    * @return true if this object is valid according to the schema
710    */
711   public boolean isValid() {
712     try {
713       validate();
714     } catch (org.exolab.castor.xml.ValidationException vex) {
715       return false;
716     }
717     return true;
718   }
719
720   /**
721    * 
722    * 
723    * @param out
724    * @throws org.exolab.castor.xml.MarshalException
725    *           if object is null or if any SAXException is thrown during
726    *           marshaling
727    * @throws org.exolab.castor.xml.ValidationException
728    *           if this object is an invalid instance according to the schema
729    */
730   public void marshal(final java.io.Writer out)
731       throws org.exolab.castor.xml.MarshalException,
732       org.exolab.castor.xml.ValidationException {
733     Marshaller.marshal(this, out);
734   }
735
736   /**
737    * 
738    * 
739    * @param handler
740    * @throws java.io.IOException
741    *           if an IOException occurs during marshaling
742    * @throws org.exolab.castor.xml.ValidationException
743    *           if this object is an invalid instance according to the schema
744    * @throws org.exolab.castor.xml.MarshalException
745    *           if object is null or if any SAXException is thrown during
746    *           marshaling
747    */
748   public void marshal(final org.xml.sax.ContentHandler handler)
749       throws java.io.IOException, org.exolab.castor.xml.MarshalException,
750       org.exolab.castor.xml.ValidationException {
751     Marshaller.marshal(this, handler);
752   }
753
754   /**
755      */
756   public void removeAllLink() {
757     this._linkList.clear();
758   }
759
760   /**
761      */
762   public void removeAllMap() {
763     this._mapList.clear();
764   }
765
766   /**
767      */
768   public void removeAllProperty() {
769     this._propertyList.clear();
770   }
771
772   /**
773    * Method removeLink.
774    * 
775    * @param vLink
776    * @return true if the object was removed from the collection.
777    */
778   public boolean removeLink(final uk.ac.vamsas.objects.core.Link vLink) {
779     boolean removed = _linkList.remove(vLink);
780     return removed;
781   }
782
783   /**
784    * Method removeLinkAt.
785    * 
786    * @param index
787    * @return the element removed from the collection
788    */
789   public uk.ac.vamsas.objects.core.Link removeLinkAt(final int index) {
790     java.lang.Object obj = this._linkList.remove(index);
791     return (uk.ac.vamsas.objects.core.Link) obj;
792   }
793
794   /**
795    * Method removeMap.
796    * 
797    * @param vMap
798    * @return true if the object was removed from the collection.
799    */
800   public boolean removeMap(final uk.ac.vamsas.objects.core.Map vMap) {
801     boolean removed = _mapList.remove(vMap);
802     return removed;
803   }
804
805   /**
806    * Method removeMapAt.
807    * 
808    * @param index
809    * @return the element removed from the collection
810    */
811   public uk.ac.vamsas.objects.core.Map removeMapAt(final int index) {
812     java.lang.Object obj = this._mapList.remove(index);
813     return (uk.ac.vamsas.objects.core.Map) obj;
814   }
815
816   /**
817    * Method removeProperty.
818    * 
819    * @param vProperty
820    * @return true if the object was removed from the collection.
821    */
822   public boolean removeProperty(
823       final uk.ac.vamsas.objects.core.Property vProperty) {
824     boolean removed = _propertyList.remove(vProperty);
825     return removed;
826   }
827
828   /**
829    * Method removePropertyAt.
830    * 
831    * @param index
832    * @return the element removed from the collection
833    */
834   public uk.ac.vamsas.objects.core.Property removePropertyAt(final int index) {
835     java.lang.Object obj = this._propertyList.remove(index);
836     return (uk.ac.vamsas.objects.core.Property) obj;
837   }
838
839   /**
840    * Sets the value of field 'accessionId'. The field 'accessionId' has the
841    * following description: TODO: make some specification of the database field
842    * from which this accessionId is taken from - should that be a special
843    * property of the dbRef object ?
844    * 
845    * 
846    * @param accessionId
847    *          the value of field 'accessionId'.
848    */
849   public void setAccessionId(final java.lang.String accessionId) {
850     this._accessionId = accessionId;
851   }
852
853   /**
854    * Sets the value of field 'id'. The field 'id' has the following description:
855    * Primary Key for vamsas object referencing
856    * 
857    * @param id
858    *          the value of field 'id'.
859    */
860   public void setId(final java.lang.String id) {
861     this._id = id;
862   }
863
864   /**
865    * 
866    * 
867    * @param index
868    * @param vLink
869    * @throws java.lang.IndexOutOfBoundsException
870    *           if the index given is outside the bounds of the collection
871    */
872   public void setLink(final int index,
873       final uk.ac.vamsas.objects.core.Link vLink)
874       throws java.lang.IndexOutOfBoundsException {
875     // check bounds for index
876     if (index < 0 || index >= this._linkList.size()) {
877       throw new IndexOutOfBoundsException("setLink: Index value '" + index
878           + "' not in range [0.." + (this._linkList.size() - 1) + "]");
879     }
880
881     this._linkList.set(index, vLink);
882   }
883
884   /**
885    * 
886    * 
887    * @param vLinkArray
888    */
889   public void setLink(final uk.ac.vamsas.objects.core.Link[] vLinkArray) {
890     // -- copy array
891     _linkList.clear();
892
893     for (int i = 0; i < vLinkArray.length; i++) {
894       this._linkList.add(vLinkArray[i]);
895     }
896   }
897
898   /**
899    * Sets the value of '_linkList' by copying the given Vector. All elements
900    * will be checked for type safety.
901    * 
902    * @param vLinkList
903    *          the Vector to copy.
904    */
905   public void setLink(final java.util.Vector vLinkList) {
906     // copy vector
907     this._linkList.clear();
908
909     this._linkList.addAll(vLinkList);
910   }
911
912   /**
913    * Sets the value of '_linkList' by setting it to the given Vector. No type
914    * checking is performed.
915    * 
916    * @deprecated
917    * 
918    * @param linkVector
919    *          the Vector to set.
920    */
921   public void setLinkAsReference(final java.util.Vector linkVector) {
922     this._linkList = linkVector;
923   }
924
925   /**
926    * 
927    * 
928    * @param index
929    * @param vMap
930    * @throws java.lang.IndexOutOfBoundsException
931    *           if the index given is outside the bounds of the collection
932    */
933   public void setMap(final int index, final uk.ac.vamsas.objects.core.Map vMap)
934       throws java.lang.IndexOutOfBoundsException {
935     // check bounds for index
936     if (index < 0 || index >= this._mapList.size()) {
937       throw new IndexOutOfBoundsException("setMap: Index value '" + index
938           + "' not in range [0.." + (this._mapList.size() - 1) + "]");
939     }
940
941     this._mapList.set(index, vMap);
942   }
943
944   /**
945    * 
946    * 
947    * @param vMapArray
948    */
949   public void setMap(final uk.ac.vamsas.objects.core.Map[] vMapArray) {
950     // -- copy array
951     _mapList.clear();
952
953     for (int i = 0; i < vMapArray.length; i++) {
954       this._mapList.add(vMapArray[i]);
955     }
956   }
957
958   /**
959    * Sets the value of '_mapList' by copying the given Vector. All elements will
960    * be checked for type safety.
961    * 
962    * @param vMapList
963    *          the Vector to copy.
964    */
965   public void setMap(final java.util.Vector vMapList) {
966     // copy vector
967     this._mapList.clear();
968
969     this._mapList.addAll(vMapList);
970   }
971
972   /**
973    * Sets the value of '_mapList' by setting it to the given Vector. No type
974    * checking is performed.
975    * 
976    * @deprecated
977    * 
978    * @param mapVector
979    *          the Vector to set.
980    */
981   public void setMapAsReference(final java.util.Vector mapVector) {
982     this._mapList = mapVector;
983   }
984
985   /**
986    * 
987    * 
988    * @param index
989    * @param vProperty
990    * @throws java.lang.IndexOutOfBoundsException
991    *           if the index given is outside the bounds of the collection
992    */
993   public void setProperty(final int index,
994       final uk.ac.vamsas.objects.core.Property vProperty)
995       throws java.lang.IndexOutOfBoundsException {
996     // check bounds for index
997     if (index < 0 || index >= this._propertyList.size()) {
998       throw new IndexOutOfBoundsException("setProperty: Index value '" + index
999           + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
1000     }
1001
1002     this._propertyList.set(index, vProperty);
1003   }
1004
1005   /**
1006    * 
1007    * 
1008    * @param vPropertyArray
1009    */
1010   public void setProperty(
1011       final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
1012     // -- copy array
1013     _propertyList.clear();
1014
1015     for (int i = 0; i < vPropertyArray.length; i++) {
1016       this._propertyList.add(vPropertyArray[i]);
1017     }
1018   }
1019
1020   /**
1021    * Sets the value of '_propertyList' by copying the given Vector. All elements
1022    * will be checked for type safety.
1023    * 
1024    * @param vPropertyList
1025    *          the Vector to copy.
1026    */
1027   public void setProperty(final java.util.Vector vPropertyList) {
1028     // copy vector
1029     this._propertyList.clear();
1030
1031     this._propertyList.addAll(vPropertyList);
1032   }
1033
1034   /**
1035    * Sets the value of '_propertyList' by setting it to the given Vector. No
1036    * type checking is performed.
1037    * 
1038    * @deprecated
1039    * 
1040    * @param propertyVector
1041    *          the Vector to set.
1042    */
1043   public void setPropertyAsReference(final java.util.Vector propertyVector) {
1044     this._propertyList = propertyVector;
1045   }
1046
1047   /**
1048    * Sets the value of field 'source'. The field 'source' has the following
1049    * description: TODO Database Naming Convention: either start using LSID (so
1050    * change type to URI) or leave this as an uncontrolled/unspecified string ID
1051    * 
1052    * 
1053    * @param source
1054    *          the value of field 'source'.
1055    */
1056   public void setSource(final java.lang.String source) {
1057     this._source = source;
1058   }
1059
1060   /**
1061    * Sets the value of field 'version'. The field 'version' has the following
1062    * description: Version must be specified -
1063    * 
1064    * 
1065    * @param version
1066    *          the value of field 'version'.
1067    */
1068   public void setVersion(final java.lang.String version) {
1069     this._version = version;
1070   }
1071
1072   /**
1073    * Method unmarshal.
1074    * 
1075    * @param reader
1076    * @throws org.exolab.castor.xml.MarshalException
1077    *           if object is null or if any SAXException is thrown during
1078    *           marshaling
1079    * @throws org.exolab.castor.xml.ValidationException
1080    *           if this object is an invalid instance according to the schema
1081    * @return the unmarshaled uk.ac.vamsas.objects.core.DbRef
1082    */
1083   public static uk.ac.vamsas.objects.core.DbRef unmarshal(
1084       final java.io.Reader reader)
1085       throws org.exolab.castor.xml.MarshalException,
1086       org.exolab.castor.xml.ValidationException {
1087     return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(
1088         uk.ac.vamsas.objects.core.DbRef.class, reader);
1089   }
1090
1091   /**
1092    * 
1093    * 
1094    * @throws org.exolab.castor.xml.ValidationException
1095    *           if this object is an invalid instance according to the schema
1096    */
1097   public void validate() throws org.exolab.castor.xml.ValidationException {
1098     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
1099     validator.validate(this);
1100   }
1101
1102 }