refactored org to uk
[vamsas.git] / src / uk / ac / vamsas / objects / core / DbRef.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /**
27  * Store a list of database references
28  *  for this sequence record - with optional mapping
29  *  from database sequence to the given sequence record 
30  * 
31  * @version $Revision$ $Date$
32  */
33 public class DbRef extends uk.ac.vamsas.client.Vobject 
34 implements java.io.Serializable
35 {
36
37
38       //--------------------------/
39      //- Class/Member Variables -/
40     //--------------------------/
41
42     /**
43      * TODO Database Naming
44      *  Convention: either start using LSID (so
45      *  change type to URI) or leave this as an
46      *  uncontrolled/unspecified string ID
47      *  
48      */
49     private java.lang.String _source;
50
51     /**
52      * Version must be specified -
53      *  
54      */
55     private java.lang.String _version;
56
57     /**
58      * TODO: make some specification
59      *  of the database field from which this
60      *  accessionId is taken from - should that be a
61      *  special property of the dbRef object ?
62      *  
63      */
64     private java.lang.String _accessionId;
65
66     /**
67      * Primary Key for vamsas object
68      *  referencing 
69      */
70     private java.lang.String _id;
71
72     /**
73      * From: Offset to first
74      *  position in dataset sequence record that
75      *  this database entry maps to To: Offset
76      *  to last position in dataset sequence
77      *  record that this database entry maps to
78      *  Start: Offset to first last position in
79      *  database entry that first (or offset)
80      *  position in sequence maps to End: Offset
81      *  to last position in database entry that
82      *  last (offset) position in sequence maps
83      *  to 
84      */
85     private java.util.Vector _mapList;
86
87     /**
88      * Field _linkList
89      */
90     private java.util.Vector _linkList;
91
92     /**
93      * Field _propertyList
94      */
95     private java.util.Vector _propertyList;
96
97
98       //----------------/
99      //- Constructors -/
100     //----------------/
101
102     public DbRef() 
103      {
104         super();
105         _mapList = new Vector();
106         _linkList = new Vector();
107         _propertyList = new Vector();
108     } //-- uk.ac.vamsas.objects.core.DbRef()
109
110
111       //-----------/
112      //- Methods -/
113     //-----------/
114
115     /**
116      * Method addLink
117      * 
118      * 
119      * 
120      * @param vLink
121      */
122     public void addLink(uk.ac.vamsas.objects.core.Link vLink)
123         throws java.lang.IndexOutOfBoundsException
124     {
125         _linkList.addElement(vLink);
126     } //-- void addLink(uk.ac.vamsas.objects.core.Link) 
127
128     /**
129      * Method addLink
130      * 
131      * 
132      * 
133      * @param index
134      * @param vLink
135      */
136     public void addLink(int index, uk.ac.vamsas.objects.core.Link vLink)
137         throws java.lang.IndexOutOfBoundsException
138     {
139         _linkList.insertElementAt(vLink, index);
140     } //-- void addLink(int, uk.ac.vamsas.objects.core.Link) 
141
142     /**
143      * Method addMap
144      * 
145      * 
146      * 
147      * @param vMap
148      */
149     public void addMap(uk.ac.vamsas.objects.core.Map vMap)
150         throws java.lang.IndexOutOfBoundsException
151     {
152         _mapList.addElement(vMap);
153     } //-- void addMap(uk.ac.vamsas.objects.core.Map) 
154
155     /**
156      * Method addMap
157      * 
158      * 
159      * 
160      * @param index
161      * @param vMap
162      */
163     public void addMap(int index, uk.ac.vamsas.objects.core.Map vMap)
164         throws java.lang.IndexOutOfBoundsException
165     {
166         _mapList.insertElementAt(vMap, index);
167     } //-- void addMap(int, uk.ac.vamsas.objects.core.Map) 
168
169     /**
170      * Method addProperty
171      * 
172      * 
173      * 
174      * @param vProperty
175      */
176     public void addProperty(uk.ac.vamsas.objects.core.Property vProperty)
177         throws java.lang.IndexOutOfBoundsException
178     {
179         _propertyList.addElement(vProperty);
180     } //-- void addProperty(uk.ac.vamsas.objects.core.Property) 
181
182     /**
183      * Method addProperty
184      * 
185      * 
186      * 
187      * @param index
188      * @param vProperty
189      */
190     public void addProperty(int index, uk.ac.vamsas.objects.core.Property vProperty)
191         throws java.lang.IndexOutOfBoundsException
192     {
193         _propertyList.insertElementAt(vProperty, index);
194     } //-- void addProperty(int, uk.ac.vamsas.objects.core.Property) 
195
196     /**
197      * Method enumerateLink
198      * 
199      * 
200      * 
201      * @return Enumeration
202      */
203     public java.util.Enumeration enumerateLink()
204     {
205         return _linkList.elements();
206     } //-- java.util.Enumeration enumerateLink() 
207
208     /**
209      * Method enumerateMap
210      * 
211      * 
212      * 
213      * @return Enumeration
214      */
215     public java.util.Enumeration enumerateMap()
216     {
217         return _mapList.elements();
218     } //-- java.util.Enumeration enumerateMap() 
219
220     /**
221      * Method enumerateProperty
222      * 
223      * 
224      * 
225      * @return Enumeration
226      */
227     public java.util.Enumeration enumerateProperty()
228     {
229         return _propertyList.elements();
230     } //-- java.util.Enumeration enumerateProperty() 
231
232     /**
233      * Note: hashCode() has not been overriden
234      * 
235      * @param obj
236      * @return boolean
237      */
238     public boolean equals(java.lang.Object obj)
239     {
240         if ( this == obj )
241             return true;
242         
243         if (super.equals(obj)==false)
244             return false;
245         
246         if (obj instanceof DbRef) {
247         
248             DbRef temp = (DbRef)obj;
249             if (this._source != null) {
250                 if (temp._source == null) return false;
251                 else if (!(this._source.equals(temp._source))) 
252                     return false;
253             }
254             else if (temp._source != null)
255                 return false;
256             if (this._version != null) {
257                 if (temp._version == null) return false;
258                 else if (!(this._version.equals(temp._version))) 
259                     return false;
260             }
261             else if (temp._version != null)
262                 return false;
263             if (this._accessionId != null) {
264                 if (temp._accessionId == null) return false;
265                 else if (!(this._accessionId.equals(temp._accessionId))) 
266                     return false;
267             }
268             else if (temp._accessionId != null)
269                 return false;
270             if (this._id != null) {
271                 if (temp._id == null) return false;
272                 else if (!(this._id.equals(temp._id))) 
273                     return false;
274             }
275             else if (temp._id != null)
276                 return false;
277             if (this._mapList != null) {
278                 if (temp._mapList == null) return false;
279                 else if (!(this._mapList.equals(temp._mapList))) 
280                     return false;
281             }
282             else if (temp._mapList != null)
283                 return false;
284             if (this._linkList != null) {
285                 if (temp._linkList == null) return false;
286                 else if (!(this._linkList.equals(temp._linkList))) 
287                     return false;
288             }
289             else if (temp._linkList != null)
290                 return false;
291             if (this._propertyList != null) {
292                 if (temp._propertyList == null) return false;
293                 else if (!(this._propertyList.equals(temp._propertyList))) 
294                     return false;
295             }
296             else if (temp._propertyList != null)
297                 return false;
298             return true;
299         }
300         return false;
301     } //-- boolean equals(java.lang.Object) 
302
303     /**
304      * Returns the value of field 'accessionId'. The field
305      * 'accessionId' has the following description: TODO: make some
306      * specification
307      *  of the database field from which this
308      *  accessionId is taken from - should that be a
309      *  special property of the dbRef object ?
310      *  
311      * 
312      * @return String
313      * @return the value of field 'accessionId'.
314      */
315     public java.lang.String getAccessionId()
316     {
317         return this._accessionId;
318     } //-- java.lang.String getAccessionId() 
319
320     /**
321      * Returns the value of field 'id'. The field 'id' has the
322      * following description: Primary Key for vamsas object
323      *  referencing 
324      * 
325      * @return String
326      * @return the value of field 'id'.
327      */
328     public java.lang.String getId()
329     {
330         return this._id;
331     } //-- java.lang.String getId() 
332
333     /**
334      * Method getLink
335      * 
336      * 
337      * 
338      * @param index
339      * @return Link
340      */
341     public uk.ac.vamsas.objects.core.Link getLink(int index)
342         throws java.lang.IndexOutOfBoundsException
343     {
344         //-- check bounds for index
345         if ((index < 0) || (index > _linkList.size())) {
346             throw new IndexOutOfBoundsException("getLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]");
347         }
348         
349         return (uk.ac.vamsas.objects.core.Link) _linkList.elementAt(index);
350     } //-- uk.ac.vamsas.objects.core.Link getLink(int) 
351
352     /**
353      * Method getLink
354      * 
355      * 
356      * 
357      * @return Link
358      */
359     public uk.ac.vamsas.objects.core.Link[] getLink()
360     {
361         int size = _linkList.size();
362         uk.ac.vamsas.objects.core.Link[] mArray = new uk.ac.vamsas.objects.core.Link[size];
363         for (int index = 0; index < size; index++) {
364             mArray[index] = (uk.ac.vamsas.objects.core.Link) _linkList.elementAt(index);
365         }
366         return mArray;
367     } //-- uk.ac.vamsas.objects.core.Link[] getLink() 
368
369     /**
370      * Method getLinkCount
371      * 
372      * 
373      * 
374      * @return int
375      */
376     public int getLinkCount()
377     {
378         return _linkList.size();
379     } //-- int getLinkCount() 
380
381     /**
382      * Method getMap
383      * 
384      * 
385      * 
386      * @param index
387      * @return Map
388      */
389     public uk.ac.vamsas.objects.core.Map getMap(int index)
390         throws java.lang.IndexOutOfBoundsException
391     {
392         //-- check bounds for index
393         if ((index < 0) || (index > _mapList.size())) {
394             throw new IndexOutOfBoundsException("getMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]");
395         }
396         
397         return (uk.ac.vamsas.objects.core.Map) _mapList.elementAt(index);
398     } //-- uk.ac.vamsas.objects.core.Map getMap(int) 
399
400     /**
401      * Method getMap
402      * 
403      * 
404      * 
405      * @return Map
406      */
407     public uk.ac.vamsas.objects.core.Map[] getMap()
408     {
409         int size = _mapList.size();
410         uk.ac.vamsas.objects.core.Map[] mArray = new uk.ac.vamsas.objects.core.Map[size];
411         for (int index = 0; index < size; index++) {
412             mArray[index] = (uk.ac.vamsas.objects.core.Map) _mapList.elementAt(index);
413         }
414         return mArray;
415     } //-- uk.ac.vamsas.objects.core.Map[] getMap() 
416
417     /**
418      * Method getMapCount
419      * 
420      * 
421      * 
422      * @return int
423      */
424     public int getMapCount()
425     {
426         return _mapList.size();
427     } //-- int getMapCount() 
428
429     /**
430      * Method getProperty
431      * 
432      * 
433      * 
434      * @param index
435      * @return Property
436      */
437     public uk.ac.vamsas.objects.core.Property getProperty(int index)
438         throws java.lang.IndexOutOfBoundsException
439     {
440         //-- check bounds for index
441         if ((index < 0) || (index > _propertyList.size())) {
442             throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]");
443         }
444         
445         return (uk.ac.vamsas.objects.core.Property) _propertyList.elementAt(index);
446     } //-- uk.ac.vamsas.objects.core.Property getProperty(int) 
447
448     /**
449      * Method getProperty
450      * 
451      * 
452      * 
453      * @return Property
454      */
455     public uk.ac.vamsas.objects.core.Property[] getProperty()
456     {
457         int size = _propertyList.size();
458         uk.ac.vamsas.objects.core.Property[] mArray = new uk.ac.vamsas.objects.core.Property[size];
459         for (int index = 0; index < size; index++) {
460             mArray[index] = (uk.ac.vamsas.objects.core.Property) _propertyList.elementAt(index);
461         }
462         return mArray;
463     } //-- uk.ac.vamsas.objects.core.Property[] getProperty() 
464
465     /**
466      * Method getPropertyCount
467      * 
468      * 
469      * 
470      * @return int
471      */
472     public int getPropertyCount()
473     {
474         return _propertyList.size();
475     } //-- int getPropertyCount() 
476
477     /**
478      * Returns the value of field 'source'. The field 'source' has
479      * the following description: TODO Database Naming
480      *  Convention: either start using LSID (so
481      *  change type to URI) or leave this as an
482      *  uncontrolled/unspecified string ID
483      *  
484      * 
485      * @return String
486      * @return the value of field 'source'.
487      */
488     public java.lang.String getSource()
489     {
490         return this._source;
491     } //-- java.lang.String getSource() 
492
493     /**
494      * Returns the value of field 'version'. The field 'version'
495      * has the following description: Version must be specified -
496      *  
497      * 
498      * @return String
499      * @return the value of field 'version'.
500      */
501     public java.lang.String getVersion()
502     {
503         return this._version;
504     } //-- java.lang.String getVersion() 
505
506     /**
507      * Method isValid
508      * 
509      * 
510      * 
511      * @return boolean
512      */
513     public boolean isValid()
514     {
515         try {
516             validate();
517         }
518         catch (org.exolab.castor.xml.ValidationException vex) {
519             return false;
520         }
521         return true;
522     } //-- boolean isValid() 
523
524     /**
525      * Method marshal
526      * 
527      * 
528      * 
529      * @param out
530      */
531     public void marshal(java.io.Writer out)
532         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
533     {
534         
535         Marshaller.marshal(this, out);
536     } //-- void marshal(java.io.Writer) 
537
538     /**
539      * Method marshal
540      * 
541      * 
542      * 
543      * @param handler
544      */
545     public void marshal(org.xml.sax.ContentHandler handler)
546         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
547     {
548         
549         Marshaller.marshal(this, handler);
550     } //-- void marshal(org.xml.sax.ContentHandler) 
551
552     /**
553      * Method removeAllLink
554      * 
555      */
556     public void removeAllLink()
557     {
558         _linkList.removeAllElements();
559     } //-- void removeAllLink() 
560
561     /**
562      * Method removeAllMap
563      * 
564      */
565     public void removeAllMap()
566     {
567         _mapList.removeAllElements();
568     } //-- void removeAllMap() 
569
570     /**
571      * Method removeAllProperty
572      * 
573      */
574     public void removeAllProperty()
575     {
576         _propertyList.removeAllElements();
577     } //-- void removeAllProperty() 
578
579     /**
580      * Method removeLink
581      * 
582      * 
583      * 
584      * @param index
585      * @return Link
586      */
587     public uk.ac.vamsas.objects.core.Link removeLink(int index)
588     {
589         java.lang.Object obj = _linkList.elementAt(index);
590         _linkList.removeElementAt(index);
591         return (uk.ac.vamsas.objects.core.Link) obj;
592     } //-- uk.ac.vamsas.objects.core.Link removeLink(int) 
593
594     /**
595      * Method removeMap
596      * 
597      * 
598      * 
599      * @param index
600      * @return Map
601      */
602     public uk.ac.vamsas.objects.core.Map removeMap(int index)
603     {
604         java.lang.Object obj = _mapList.elementAt(index);
605         _mapList.removeElementAt(index);
606         return (uk.ac.vamsas.objects.core.Map) obj;
607     } //-- uk.ac.vamsas.objects.core.Map removeMap(int) 
608
609     /**
610      * Method removeProperty
611      * 
612      * 
613      * 
614      * @param index
615      * @return Property
616      */
617     public uk.ac.vamsas.objects.core.Property removeProperty(int index)
618     {
619         java.lang.Object obj = _propertyList.elementAt(index);
620         _propertyList.removeElementAt(index);
621         return (uk.ac.vamsas.objects.core.Property) obj;
622     } //-- uk.ac.vamsas.objects.core.Property removeProperty(int) 
623
624     /**
625      * Sets the value of field 'accessionId'. The field
626      * 'accessionId' has the following description: TODO: make some
627      * specification
628      *  of the database field from which this
629      *  accessionId is taken from - should that be a
630      *  special property of the dbRef object ?
631      *  
632      * 
633      * @param accessionId the value of field 'accessionId'.
634      */
635     public void setAccessionId(java.lang.String accessionId)
636     {
637         this._accessionId = accessionId;
638     } //-- void setAccessionId(java.lang.String) 
639
640     /**
641      * Sets the value of field 'id'. The field 'id' has the
642      * following description: Primary Key for vamsas object
643      *  referencing 
644      * 
645      * @param id the value of field 'id'.
646      */
647     public void setId(java.lang.String id)
648     {
649         this._id = id;
650     } //-- void setId(java.lang.String) 
651
652     /**
653      * Method setLink
654      * 
655      * 
656      * 
657      * @param index
658      * @param vLink
659      */
660     public void setLink(int index, uk.ac.vamsas.objects.core.Link vLink)
661         throws java.lang.IndexOutOfBoundsException
662     {
663         //-- check bounds for index
664         if ((index < 0) || (index > _linkList.size())) {
665             throw new IndexOutOfBoundsException("setLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]");
666         }
667         _linkList.setElementAt(vLink, index);
668     } //-- void setLink(int, uk.ac.vamsas.objects.core.Link) 
669
670     /**
671      * Method setLink
672      * 
673      * 
674      * 
675      * @param linkArray
676      */
677     public void setLink(uk.ac.vamsas.objects.core.Link[] linkArray)
678     {
679         //-- copy array
680         _linkList.removeAllElements();
681         for (int i = 0; i < linkArray.length; i++) {
682             _linkList.addElement(linkArray[i]);
683         }
684     } //-- void setLink(uk.ac.vamsas.objects.core.Link) 
685
686     /**
687      * Method setMap
688      * 
689      * 
690      * 
691      * @param index
692      * @param vMap
693      */
694     public void setMap(int index, uk.ac.vamsas.objects.core.Map vMap)
695         throws java.lang.IndexOutOfBoundsException
696     {
697         //-- check bounds for index
698         if ((index < 0) || (index > _mapList.size())) {
699             throw new IndexOutOfBoundsException("setMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]");
700         }
701         _mapList.setElementAt(vMap, index);
702     } //-- void setMap(int, uk.ac.vamsas.objects.core.Map) 
703
704     /**
705      * Method setMap
706      * 
707      * 
708      * 
709      * @param mapArray
710      */
711     public void setMap(uk.ac.vamsas.objects.core.Map[] mapArray)
712     {
713         //-- copy array
714         _mapList.removeAllElements();
715         for (int i = 0; i < mapArray.length; i++) {
716             _mapList.addElement(mapArray[i]);
717         }
718     } //-- void setMap(uk.ac.vamsas.objects.core.Map) 
719
720     /**
721      * Method setProperty
722      * 
723      * 
724      * 
725      * @param index
726      * @param vProperty
727      */
728     public void setProperty(int index, uk.ac.vamsas.objects.core.Property vProperty)
729         throws java.lang.IndexOutOfBoundsException
730     {
731         //-- check bounds for index
732         if ((index < 0) || (index > _propertyList.size())) {
733             throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]");
734         }
735         _propertyList.setElementAt(vProperty, index);
736     } //-- void setProperty(int, uk.ac.vamsas.objects.core.Property) 
737
738     /**
739      * Method setProperty
740      * 
741      * 
742      * 
743      * @param propertyArray
744      */
745     public void setProperty(uk.ac.vamsas.objects.core.Property[] propertyArray)
746     {
747         //-- copy array
748         _propertyList.removeAllElements();
749         for (int i = 0; i < propertyArray.length; i++) {
750             _propertyList.addElement(propertyArray[i]);
751         }
752     } //-- void setProperty(uk.ac.vamsas.objects.core.Property) 
753
754     /**
755      * Sets the value of field 'source'. The field 'source' has the
756      * following description: TODO Database Naming
757      *  Convention: either start using LSID (so
758      *  change type to URI) or leave this as an
759      *  uncontrolled/unspecified string ID
760      *  
761      * 
762      * @param source the value of field 'source'.
763      */
764     public void setSource(java.lang.String source)
765     {
766         this._source = source;
767     } //-- void setSource(java.lang.String) 
768
769     /**
770      * Sets the value of field 'version'. The field 'version' has
771      * the following description: Version must be specified -
772      *  
773      * 
774      * @param version the value of field 'version'.
775      */
776     public void setVersion(java.lang.String version)
777     {
778         this._version = version;
779     } //-- void setVersion(java.lang.String) 
780
781     /**
782      * Method unmarshal
783      * 
784      * 
785      * 
786      * @param reader
787      * @return DbRef
788      */
789     public static uk.ac.vamsas.objects.core.DbRef unmarshal(java.io.Reader reader)
790         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
791     {
792         return (uk.ac.vamsas.objects.core.DbRef) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DbRef.class, reader);
793     } //-- uk.ac.vamsas.objects.core.DbRef unmarshal(java.io.Reader) 
794
795     /**
796      * Method validate
797      * 
798      */
799     public void validate()
800         throws org.exolab.castor.xml.ValidationException
801     {
802         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
803         validator.validate(this);
804     } //-- void validate() 
805
806 }