3e1f6da181a70c54000388f6da10b310b1166a94
[vamsas.git] / src / uk / ac / vamsas / objects / core / RangeType.java
1 /*\r
2  * This class was automatically generated with \r
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 \r
8 package uk.ac.vamsas.objects.core;\r
9 \r
10 /**\r
11  * Specify an ordered set of positions and/or regions on the\r
12  * principle\r
13  *  dimension of some associated vamsas object Keeping to jaxb-1.0\r
14  * specification for the moment - this choice should\r
15  *  become a substitution group when we use jaxb-2.0 capable\r
16  * bindings\r
17  *  \r
18  * \r
19  * @version $Revision$ $Date$\r
20  */\r
21 public abstract class RangeType extends uk.ac.vamsas.client.Vobject \r
22 implements java.io.Serializable\r
23 {\r
24 \r
25 \r
26       //--------------------------/\r
27      //- Class/Member Variables -/\r
28     //--------------------------/\r
29 \r
30     /**\r
31      * Internal choice value storage\r
32      */\r
33     private java.lang.Object _choiceValue;\r
34 \r
35     /**\r
36      * a position within the associated object's coordinate system\r
37      *  \r
38      */\r
39     private java.util.Vector _posList;\r
40 \r
41     /**\r
42      * a region from start to end, with flag for inclusivity of\r
43      *  terminii \r
44      */\r
45     private java.util.Vector _segList;\r
46 \r
47 \r
48       //----------------/\r
49      //- Constructors -/\r
50     //----------------/\r
51 \r
52     public RangeType() {\r
53         super();\r
54         this._posList = new java.util.Vector();\r
55         this._segList = new java.util.Vector();\r
56     }\r
57 \r
58 \r
59       //-----------/\r
60      //- Methods -/\r
61     //-----------/\r
62 \r
63     /**\r
64      * \r
65      * \r
66      * @param vPos\r
67      * @throws java.lang.IndexOutOfBoundsException if the index\r
68      * given is outside the bounds of the collection\r
69      */\r
70     public void addPos(\r
71             final uk.ac.vamsas.objects.core.Pos vPos)\r
72     throws java.lang.IndexOutOfBoundsException {\r
73         this._posList.addElement(vPos);\r
74     }\r
75 \r
76     /**\r
77      * \r
78      * \r
79      * @param index\r
80      * @param vPos\r
81      * @throws java.lang.IndexOutOfBoundsException if the index\r
82      * given is outside the bounds of the collection\r
83      */\r
84     public void addPos(\r
85             final int index,\r
86             final uk.ac.vamsas.objects.core.Pos vPos)\r
87     throws java.lang.IndexOutOfBoundsException {\r
88         this._posList.add(index, vPos);\r
89     }\r
90 \r
91     /**\r
92      * \r
93      * \r
94      * @param vSeg\r
95      * @throws java.lang.IndexOutOfBoundsException if the index\r
96      * given is outside the bounds of the collection\r
97      */\r
98     public void addSeg(\r
99             final uk.ac.vamsas.objects.core.Seg vSeg)\r
100     throws java.lang.IndexOutOfBoundsException {\r
101         this._segList.addElement(vSeg);\r
102     }\r
103 \r
104     /**\r
105      * \r
106      * \r
107      * @param index\r
108      * @param vSeg\r
109      * @throws java.lang.IndexOutOfBoundsException if the index\r
110      * given is outside the bounds of the collection\r
111      */\r
112     public void addSeg(\r
113             final int index,\r
114             final uk.ac.vamsas.objects.core.Seg vSeg)\r
115     throws java.lang.IndexOutOfBoundsException {\r
116         this._segList.add(index, vSeg);\r
117     }\r
118 \r
119     /**\r
120      * Method enumeratePos.\r
121      * \r
122      * @return an Enumeration over all\r
123      * uk.ac.vamsas.objects.core.Pos elements\r
124      */\r
125     public java.util.Enumeration enumeratePos(\r
126     ) {\r
127         return this._posList.elements();\r
128     }\r
129 \r
130     /**\r
131      * Method enumerateSeg.\r
132      * \r
133      * @return an Enumeration over all\r
134      * uk.ac.vamsas.objects.core.Seg elements\r
135      */\r
136     public java.util.Enumeration enumerateSeg(\r
137     ) {\r
138         return this._segList.elements();\r
139     }\r
140 \r
141     /**\r
142      * Overrides the java.lang.Object.equals method.\r
143      * \r
144      * @param obj\r
145      * @return true if the objects are equal.\r
146      */\r
147     public boolean equals(\r
148             final java.lang.Object obj) {\r
149         if ( this == obj )\r
150             return true;\r
151         \r
152         if (super.equals(obj)==false)\r
153             return false;\r
154         \r
155         if (obj instanceof RangeType) {\r
156         \r
157             RangeType temp = (RangeType)obj;\r
158             boolean thcycle;\r
159             boolean tmcycle;\r
160             if (this._choiceValue != null) {\r
161                 if (temp._choiceValue == null) return false;\r
162                 if (this._choiceValue != temp._choiceValue) {\r
163                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._choiceValue);\r
164                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._choiceValue);\r
165                     if (thcycle!=tmcycle) {\r
166                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue); };\r
167                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue); };\r
168                         return false;\r
169                     }\r
170                     if (!thcycle) {\r
171                         if (!this._choiceValue.equals(temp._choiceValue)) {\r
172                             org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue);\r
173                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue);\r
174                             return false;\r
175                         }\r
176                         org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue);\r
177                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue);\r
178                     }\r
179                 }\r
180             } else if (temp._choiceValue != null)\r
181                 return false;\r
182             if (this._posList != null) {\r
183                 if (temp._posList == null) return false;\r
184                 if (this._posList != temp._posList) {\r
185                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._posList);\r
186                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._posList);\r
187                     if (thcycle!=tmcycle) {\r
188                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._posList); };\r
189                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList); };\r
190                         return false;\r
191                     }\r
192                     if (!thcycle) {\r
193                         if (!this._posList.equals(temp._posList)) {\r
194                             org.castor.util.CycleBreaker.releaseCycleHandle(this._posList);\r
195                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList);\r
196                             return false;\r
197                         }\r
198                         org.castor.util.CycleBreaker.releaseCycleHandle(this._posList);\r
199                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList);\r
200                     }\r
201                 }\r
202             } else if (temp._posList != null)\r
203                 return false;\r
204             if (this._segList != null) {\r
205                 if (temp._segList == null) return false;\r
206                 if (this._segList != temp._segList) {\r
207                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._segList);\r
208                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._segList);\r
209                     if (thcycle!=tmcycle) {\r
210                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._segList); };\r
211                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList); };\r
212                         return false;\r
213                     }\r
214                     if (!thcycle) {\r
215                         if (!this._segList.equals(temp._segList)) {\r
216                             org.castor.util.CycleBreaker.releaseCycleHandle(this._segList);\r
217                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList);\r
218                             return false;\r
219                         }\r
220                         org.castor.util.CycleBreaker.releaseCycleHandle(this._segList);\r
221                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList);\r
222                     }\r
223                 }\r
224             } else if (temp._segList != null)\r
225                 return false;\r
226             return true;\r
227         }\r
228         return false;\r
229     }\r
230 \r
231     /**\r
232      * Returns the value of field 'choiceValue'. The field\r
233      * 'choiceValue' has the following description: Internal choice\r
234      * value storage\r
235      * \r
236      * @return the value of field 'ChoiceValue'.\r
237      */\r
238     public java.lang.Object getChoiceValue(\r
239     ) {\r
240         return this._choiceValue;\r
241     }\r
242 \r
243     /**\r
244      * Method getPos.\r
245      * \r
246      * @param index\r
247      * @throws java.lang.IndexOutOfBoundsException if the index\r
248      * given is outside the bounds of the collection\r
249      * @return the value of the uk.ac.vamsas.objects.core.Pos at\r
250      * the given index\r
251      */\r
252     public uk.ac.vamsas.objects.core.Pos getPos(\r
253             final int index)\r
254     throws java.lang.IndexOutOfBoundsException {\r
255         // check bounds for index\r
256         if (index < 0 || index >= this._posList.size()) {\r
257             throw new IndexOutOfBoundsException("getPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]");\r
258         }\r
259         \r
260         return (uk.ac.vamsas.objects.core.Pos) _posList.get(index);\r
261     }\r
262 \r
263     /**\r
264      * Method getPos.Returns the contents of the collection in an\r
265      * Array.  <p>Note:  Just in case the collection contents are\r
266      * changing in another thread, we pass a 0-length Array of the\r
267      * correct type into the API call.  This way we <i>know</i>\r
268      * that the Array returned is of exactly the correct length.\r
269      * \r
270      * @return this collection as an Array\r
271      */\r
272     public uk.ac.vamsas.objects.core.Pos[] getPos(\r
273     ) {\r
274         uk.ac.vamsas.objects.core.Pos[] array = new uk.ac.vamsas.objects.core.Pos[0];\r
275         return (uk.ac.vamsas.objects.core.Pos[]) this._posList.toArray(array);\r
276     }\r
277 \r
278     /**\r
279      * Method getPosAsReference.Returns a reference to '_posList'.\r
280      * No type checking is performed on any modifications to the\r
281      * Vector.\r
282      * \r
283      * @return a reference to the Vector backing this class\r
284      */\r
285     public java.util.Vector getPosAsReference(\r
286     ) {\r
287         return this._posList;\r
288     }\r
289 \r
290     /**\r
291      * Method getPosCount.\r
292      * \r
293      * @return the size of this collection\r
294      */\r
295     public int getPosCount(\r
296     ) {\r
297         return this._posList.size();\r
298     }\r
299 \r
300     /**\r
301      * Method getSeg.\r
302      * \r
303      * @param index\r
304      * @throws java.lang.IndexOutOfBoundsException if the index\r
305      * given is outside the bounds of the collection\r
306      * @return the value of the uk.ac.vamsas.objects.core.Seg at\r
307      * the given index\r
308      */\r
309     public uk.ac.vamsas.objects.core.Seg getSeg(\r
310             final int index)\r
311     throws java.lang.IndexOutOfBoundsException {\r
312         // check bounds for index\r
313         if (index < 0 || index >= this._segList.size()) {\r
314             throw new IndexOutOfBoundsException("getSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]");\r
315         }\r
316         \r
317         return (uk.ac.vamsas.objects.core.Seg) _segList.get(index);\r
318     }\r
319 \r
320     /**\r
321      * Method getSeg.Returns the contents of the collection in an\r
322      * Array.  <p>Note:  Just in case the collection contents are\r
323      * changing in another thread, we pass a 0-length Array of the\r
324      * correct type into the API call.  This way we <i>know</i>\r
325      * that the Array returned is of exactly the correct length.\r
326      * \r
327      * @return this collection as an Array\r
328      */\r
329     public uk.ac.vamsas.objects.core.Seg[] getSeg(\r
330     ) {\r
331         uk.ac.vamsas.objects.core.Seg[] array = new uk.ac.vamsas.objects.core.Seg[0];\r
332         return (uk.ac.vamsas.objects.core.Seg[]) this._segList.toArray(array);\r
333     }\r
334 \r
335     /**\r
336      * Method getSegAsReference.Returns a reference to '_segList'.\r
337      * No type checking is performed on any modifications to the\r
338      * Vector.\r
339      * \r
340      * @return a reference to the Vector backing this class\r
341      */\r
342     public java.util.Vector getSegAsReference(\r
343     ) {\r
344         return this._segList;\r
345     }\r
346 \r
347     /**\r
348      * Method getSegCount.\r
349      * \r
350      * @return the size of this collection\r
351      */\r
352     public int getSegCount(\r
353     ) {\r
354         return this._segList.size();\r
355     }\r
356 \r
357     /**\r
358      * Overrides the java.lang.Object.hashCode method.\r
359      * <p>\r
360      * The following steps came from <b>Effective Java Programming\r
361      * Language Guide</b> by Joshua Bloch, Chapter 3\r
362      * \r
363      * @return a hash code value for the object.\r
364      */\r
365     public int hashCode(\r
366     ) {\r
367         int result = super.hashCode();\r
368         \r
369         long tmp;\r
370         if (_choiceValue != null\r
371             && !org.castor.util.CycleBreaker.startingToCycle(_choiceValue)) {\r
372            result = 37 * result + _choiceValue.hashCode();\r
373            org.castor.util.CycleBreaker.releaseCycleHandle(_choiceValue);\r
374         }\r
375         if (_posList != null\r
376             && !org.castor.util.CycleBreaker.startingToCycle(_posList)) {\r
377            result = 37 * result + _posList.hashCode();\r
378            org.castor.util.CycleBreaker.releaseCycleHandle(_posList);\r
379         }\r
380         if (_segList != null\r
381             && !org.castor.util.CycleBreaker.startingToCycle(_segList)) {\r
382            result = 37 * result + _segList.hashCode();\r
383            org.castor.util.CycleBreaker.releaseCycleHandle(_segList);\r
384         }\r
385         \r
386         return result;\r
387     }\r
388 \r
389     /**\r
390      * Method isValid.\r
391      * \r
392      * @return true if this object is valid according to the schema\r
393      */\r
394     public boolean isValid(\r
395     ) {\r
396         try {\r
397             validate();\r
398         } catch (org.exolab.castor.xml.ValidationException vex) {\r
399             return false;\r
400         }\r
401         return true;\r
402     }\r
403 \r
404     /**\r
405      */\r
406     public void removeAllPos(\r
407     ) {\r
408         this._posList.clear();\r
409     }\r
410 \r
411     /**\r
412      */\r
413     public void removeAllSeg(\r
414     ) {\r
415         this._segList.clear();\r
416     }\r
417 \r
418     /**\r
419      * Method removePos.\r
420      * \r
421      * @param vPos\r
422      * @return true if the object was removed from the collection.\r
423      */\r
424     public boolean removePos(\r
425             final uk.ac.vamsas.objects.core.Pos vPos) {\r
426         boolean removed = _posList.remove(vPos);\r
427         return removed;\r
428     }\r
429 \r
430     /**\r
431      * Method removePosAt.\r
432      * \r
433      * @param index\r
434      * @return the element removed from the collection\r
435      */\r
436     public uk.ac.vamsas.objects.core.Pos removePosAt(\r
437             final int index) {\r
438         java.lang.Object obj = this._posList.remove(index);\r
439         return (uk.ac.vamsas.objects.core.Pos) obj;\r
440     }\r
441 \r
442     /**\r
443      * Method removeSeg.\r
444      * \r
445      * @param vSeg\r
446      * @return true if the object was removed from the collection.\r
447      */\r
448     public boolean removeSeg(\r
449             final uk.ac.vamsas.objects.core.Seg vSeg) {\r
450         boolean removed = _segList.remove(vSeg);\r
451         return removed;\r
452     }\r
453 \r
454     /**\r
455      * Method removeSegAt.\r
456      * \r
457      * @param index\r
458      * @return the element removed from the collection\r
459      */\r
460     public uk.ac.vamsas.objects.core.Seg removeSegAt(\r
461             final int index) {\r
462         java.lang.Object obj = this._segList.remove(index);\r
463         return (uk.ac.vamsas.objects.core.Seg) obj;\r
464     }\r
465 \r
466     /**\r
467      * \r
468      * \r
469      * @param index\r
470      * @param vPos\r
471      * @throws java.lang.IndexOutOfBoundsException if the index\r
472      * given is outside the bounds of the collection\r
473      */\r
474     public void setPos(\r
475             final int index,\r
476             final uk.ac.vamsas.objects.core.Pos vPos)\r
477     throws java.lang.IndexOutOfBoundsException {\r
478         // check bounds for index\r
479         if (index < 0 || index >= this._posList.size()) {\r
480             throw new IndexOutOfBoundsException("setPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]");\r
481         }\r
482         \r
483         this._posList.set(index, vPos);\r
484     }\r
485 \r
486     /**\r
487      * \r
488      * \r
489      * @param vPosArray\r
490      */\r
491     public void setPos(\r
492             final uk.ac.vamsas.objects.core.Pos[] vPosArray) {\r
493         //-- copy array\r
494         _posList.clear();\r
495         \r
496         for (int i = 0; i < vPosArray.length; i++) {\r
497                 this._posList.add(vPosArray[i]);\r
498         }\r
499     }\r
500 \r
501     /**\r
502      * Sets the value of '_posList' by copying the given Vector.\r
503      * All elements will be checked for type safety.\r
504      * \r
505      * @param vPosList the Vector to copy.\r
506      */\r
507     public void setPos(\r
508             final java.util.Vector vPosList) {\r
509         // copy vector\r
510         this._posList.clear();\r
511         \r
512         this._posList.addAll(vPosList);\r
513     }\r
514 \r
515     /**\r
516      * Sets the value of '_posList' by setting it to the given\r
517      * Vector. No type checking is performed.\r
518      * @deprecated\r
519      * \r
520      * @param posVector the Vector to set.\r
521      */\r
522     public void setPosAsReference(\r
523             final java.util.Vector posVector) {\r
524         this._posList = posVector;\r
525     }\r
526 \r
527     /**\r
528      * \r
529      * \r
530      * @param index\r
531      * @param vSeg\r
532      * @throws java.lang.IndexOutOfBoundsException if the index\r
533      * given is outside the bounds of the collection\r
534      */\r
535     public void setSeg(\r
536             final int index,\r
537             final uk.ac.vamsas.objects.core.Seg vSeg)\r
538     throws java.lang.IndexOutOfBoundsException {\r
539         // check bounds for index\r
540         if (index < 0 || index >= this._segList.size()) {\r
541             throw new IndexOutOfBoundsException("setSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]");\r
542         }\r
543         \r
544         this._segList.set(index, vSeg);\r
545     }\r
546 \r
547     /**\r
548      * \r
549      * \r
550      * @param vSegArray\r
551      */\r
552     public void setSeg(\r
553             final uk.ac.vamsas.objects.core.Seg[] vSegArray) {\r
554         //-- copy array\r
555         _segList.clear();\r
556         \r
557         for (int i = 0; i < vSegArray.length; i++) {\r
558                 this._segList.add(vSegArray[i]);\r
559         }\r
560     }\r
561 \r
562     /**\r
563      * Sets the value of '_segList' by copying the given Vector.\r
564      * All elements will be checked for type safety.\r
565      * \r
566      * @param vSegList the Vector to copy.\r
567      */\r
568     public void setSeg(\r
569             final java.util.Vector vSegList) {\r
570         // copy vector\r
571         this._segList.clear();\r
572         \r
573         this._segList.addAll(vSegList);\r
574     }\r
575 \r
576     /**\r
577      * Sets the value of '_segList' by setting it to the given\r
578      * Vector. No type checking is performed.\r
579      * @deprecated\r
580      * \r
581      * @param segVector the Vector to set.\r
582      */\r
583     public void setSegAsReference(\r
584             final java.util.Vector segVector) {\r
585         this._segList = segVector;\r
586     }\r
587 \r
588     /**\r
589      * \r
590      * \r
591      * @throws org.exolab.castor.xml.ValidationException if this\r
592      * object is an invalid instance according to the schema\r
593      */\r
594     public void validate(\r
595     )\r
596     throws org.exolab.castor.xml.ValidationException {\r
597         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
598         validator.validate(this);\r
599     }\r
600 \r
601 }\r