91338e28f4711b3176a3d3707cd0181e4cdb3aea
[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             if (this._choiceValue != null) {\r
159                 if (temp._choiceValue == null) return false;\r
160                 else if (!(this._choiceValue.equals(temp._choiceValue))) \r
161                     return false;\r
162             }\r
163             else if (temp._choiceValue != null)\r
164                 return false;\r
165             if (this._posList != null) {\r
166                 if (temp._posList == null) return false;\r
167                 else if (!(this._posList.equals(temp._posList))) \r
168                     return false;\r
169             }\r
170             else if (temp._posList != null)\r
171                 return false;\r
172             if (this._segList != null) {\r
173                 if (temp._segList == null) return false;\r
174                 else if (!(this._segList.equals(temp._segList))) \r
175                     return false;\r
176             }\r
177             else if (temp._segList != null)\r
178                 return false;\r
179             return true;\r
180         }\r
181         return false;\r
182     }\r
183 \r
184     /**\r
185      * Returns the value of field 'choiceValue'. The field\r
186      * 'choiceValue' has the following description: Internal choice\r
187      * value storage\r
188      * \r
189      * @return the value of field 'ChoiceValue'.\r
190      */\r
191     public java.lang.Object getChoiceValue(\r
192     ) {\r
193         return this._choiceValue;\r
194     }\r
195 \r
196     /**\r
197      * Method getPos.\r
198      * \r
199      * @param index\r
200      * @throws java.lang.IndexOutOfBoundsException if the index\r
201      * given is outside the bounds of the collection\r
202      * @return the value of the uk.ac.vamsas.objects.core.Pos at\r
203      * the given index\r
204      */\r
205     public uk.ac.vamsas.objects.core.Pos getPos(\r
206             final int index)\r
207     throws java.lang.IndexOutOfBoundsException {\r
208         // check bounds for index\r
209         if (index < 0 || index >= this._posList.size()) {\r
210             throw new IndexOutOfBoundsException("getPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]");\r
211         }\r
212         \r
213         return (uk.ac.vamsas.objects.core.Pos) _posList.get(index);\r
214     }\r
215 \r
216     /**\r
217      * Method getPos.Returns the contents of the collection in an\r
218      * Array.  <p>Note:  Just in case the collection contents are\r
219      * changing in another thread, we pass a 0-length Array of the\r
220      * correct type into the API call.  This way we <i>know</i>\r
221      * that the Array returned is of exactly the correct length.\r
222      * \r
223      * @return this collection as an Array\r
224      */\r
225     public uk.ac.vamsas.objects.core.Pos[] getPos(\r
226     ) {\r
227         uk.ac.vamsas.objects.core.Pos[] array = new uk.ac.vamsas.objects.core.Pos[0];\r
228         return (uk.ac.vamsas.objects.core.Pos[]) this._posList.toArray(array);\r
229     }\r
230 \r
231     /**\r
232      * Method getPosAsReference.Returns a reference to '_posList'.\r
233      * No type checking is performed on any modifications to the\r
234      * Vector.\r
235      * \r
236      * @return a reference to the Vector backing this class\r
237      */\r
238     public java.util.Vector getPosAsReference(\r
239     ) {\r
240         return this._posList;\r
241     }\r
242 \r
243     /**\r
244      * Method getPosCount.\r
245      * \r
246      * @return the size of this collection\r
247      */\r
248     public int getPosCount(\r
249     ) {\r
250         return this._posList.size();\r
251     }\r
252 \r
253     /**\r
254      * Method getSeg.\r
255      * \r
256      * @param index\r
257      * @throws java.lang.IndexOutOfBoundsException if the index\r
258      * given is outside the bounds of the collection\r
259      * @return the value of the uk.ac.vamsas.objects.core.Seg at\r
260      * the given index\r
261      */\r
262     public uk.ac.vamsas.objects.core.Seg getSeg(\r
263             final int index)\r
264     throws java.lang.IndexOutOfBoundsException {\r
265         // check bounds for index\r
266         if (index < 0 || index >= this._segList.size()) {\r
267             throw new IndexOutOfBoundsException("getSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]");\r
268         }\r
269         \r
270         return (uk.ac.vamsas.objects.core.Seg) _segList.get(index);\r
271     }\r
272 \r
273     /**\r
274      * Method getSeg.Returns the contents of the collection in an\r
275      * Array.  <p>Note:  Just in case the collection contents are\r
276      * changing in another thread, we pass a 0-length Array of the\r
277      * correct type into the API call.  This way we <i>know</i>\r
278      * that the Array returned is of exactly the correct length.\r
279      * \r
280      * @return this collection as an Array\r
281      */\r
282     public uk.ac.vamsas.objects.core.Seg[] getSeg(\r
283     ) {\r
284         uk.ac.vamsas.objects.core.Seg[] array = new uk.ac.vamsas.objects.core.Seg[0];\r
285         return (uk.ac.vamsas.objects.core.Seg[]) this._segList.toArray(array);\r
286     }\r
287 \r
288     /**\r
289      * Method getSegAsReference.Returns a reference to '_segList'.\r
290      * No type checking is performed on any modifications to the\r
291      * Vector.\r
292      * \r
293      * @return a reference to the Vector backing this class\r
294      */\r
295     public java.util.Vector getSegAsReference(\r
296     ) {\r
297         return this._segList;\r
298     }\r
299 \r
300     /**\r
301      * Method getSegCount.\r
302      * \r
303      * @return the size of this collection\r
304      */\r
305     public int getSegCount(\r
306     ) {\r
307         return this._segList.size();\r
308     }\r
309 \r
310     /**\r
311      * Overrides the java.lang.Object.hashCode method.\r
312      * <p>\r
313      * The following steps came from <b>Effective Java Programming\r
314      * Language Guide</b> by Joshua Bloch, Chapter 3\r
315      * \r
316      * @return a hash code value for the object.\r
317      */\r
318     public int hashCode(\r
319     ) {\r
320         int result = super.hashCode();\r
321         \r
322         long tmp;\r
323         if (_choiceValue != null) {\r
324            result = 37 * result + _choiceValue.hashCode();\r
325         }\r
326         if (_posList != null) {\r
327            result = 37 * result + _posList.hashCode();\r
328         }\r
329         if (_segList != null) {\r
330            result = 37 * result + _segList.hashCode();\r
331         }\r
332         \r
333         return result;\r
334     }\r
335 \r
336     /**\r
337      * Method isValid.\r
338      * \r
339      * @return true if this object is valid according to the schema\r
340      */\r
341     public boolean isValid(\r
342     ) {\r
343         try {\r
344             validate();\r
345         } catch (org.exolab.castor.xml.ValidationException vex) {\r
346             return false;\r
347         }\r
348         return true;\r
349     }\r
350 \r
351     /**\r
352      */\r
353     public void removeAllPos(\r
354     ) {\r
355         this._posList.clear();\r
356     }\r
357 \r
358     /**\r
359      */\r
360     public void removeAllSeg(\r
361     ) {\r
362         this._segList.clear();\r
363     }\r
364 \r
365     /**\r
366      * Method removePos.\r
367      * \r
368      * @param vPos\r
369      * @return true if the object was removed from the collection.\r
370      */\r
371     public boolean removePos(\r
372             final uk.ac.vamsas.objects.core.Pos vPos) {\r
373         boolean removed = _posList.remove(vPos);\r
374         return removed;\r
375     }\r
376 \r
377     /**\r
378      * Method removePosAt.\r
379      * \r
380      * @param index\r
381      * @return the element removed from the collection\r
382      */\r
383     public uk.ac.vamsas.objects.core.Pos removePosAt(\r
384             final int index) {\r
385         java.lang.Object obj = this._posList.remove(index);\r
386         return (uk.ac.vamsas.objects.core.Pos) obj;\r
387     }\r
388 \r
389     /**\r
390      * Method removeSeg.\r
391      * \r
392      * @param vSeg\r
393      * @return true if the object was removed from the collection.\r
394      */\r
395     public boolean removeSeg(\r
396             final uk.ac.vamsas.objects.core.Seg vSeg) {\r
397         boolean removed = _segList.remove(vSeg);\r
398         return removed;\r
399     }\r
400 \r
401     /**\r
402      * Method removeSegAt.\r
403      * \r
404      * @param index\r
405      * @return the element removed from the collection\r
406      */\r
407     public uk.ac.vamsas.objects.core.Seg removeSegAt(\r
408             final int index) {\r
409         java.lang.Object obj = this._segList.remove(index);\r
410         return (uk.ac.vamsas.objects.core.Seg) obj;\r
411     }\r
412 \r
413     /**\r
414      * \r
415      * \r
416      * @param index\r
417      * @param vPos\r
418      * @throws java.lang.IndexOutOfBoundsException if the index\r
419      * given is outside the bounds of the collection\r
420      */\r
421     public void setPos(\r
422             final int index,\r
423             final uk.ac.vamsas.objects.core.Pos vPos)\r
424     throws java.lang.IndexOutOfBoundsException {\r
425         // check bounds for index\r
426         if (index < 0 || index >= this._posList.size()) {\r
427             throw new IndexOutOfBoundsException("setPos: Index value '" + index + "' not in range [0.." + (this._posList.size() - 1) + "]");\r
428         }\r
429         \r
430         this._posList.set(index, vPos);\r
431     }\r
432 \r
433     /**\r
434      * \r
435      * \r
436      * @param vPosArray\r
437      */\r
438     public void setPos(\r
439             final uk.ac.vamsas.objects.core.Pos[] vPosArray) {\r
440         //-- copy array\r
441         _posList.clear();\r
442         \r
443         for (int i = 0; i < vPosArray.length; i++) {\r
444                 this._posList.add(vPosArray[i]);\r
445         }\r
446     }\r
447 \r
448     /**\r
449      * Sets the value of '_posList' by copying the given Vector.\r
450      * All elements will be checked for type safety.\r
451      * \r
452      * @param vPosList the Vector to copy.\r
453      */\r
454     public void setPos(\r
455             final java.util.Vector vPosList) {\r
456         // copy vector\r
457         this._posList.clear();\r
458         \r
459         this._posList.addAll(vPosList);\r
460     }\r
461 \r
462     /**\r
463      * Sets the value of '_posList' by setting it to the given\r
464      * Vector. No type checking is performed.\r
465      * @deprecated\r
466      * \r
467      * @param posVector the Vector to set.\r
468      */\r
469     public void setPosAsReference(\r
470             final java.util.Vector posVector) {\r
471         this._posList = posVector;\r
472     }\r
473 \r
474     /**\r
475      * \r
476      * \r
477      * @param index\r
478      * @param vSeg\r
479      * @throws java.lang.IndexOutOfBoundsException if the index\r
480      * given is outside the bounds of the collection\r
481      */\r
482     public void setSeg(\r
483             final int index,\r
484             final uk.ac.vamsas.objects.core.Seg vSeg)\r
485     throws java.lang.IndexOutOfBoundsException {\r
486         // check bounds for index\r
487         if (index < 0 || index >= this._segList.size()) {\r
488             throw new IndexOutOfBoundsException("setSeg: Index value '" + index + "' not in range [0.." + (this._segList.size() - 1) + "]");\r
489         }\r
490         \r
491         this._segList.set(index, vSeg);\r
492     }\r
493 \r
494     /**\r
495      * \r
496      * \r
497      * @param vSegArray\r
498      */\r
499     public void setSeg(\r
500             final uk.ac.vamsas.objects.core.Seg[] vSegArray) {\r
501         //-- copy array\r
502         _segList.clear();\r
503         \r
504         for (int i = 0; i < vSegArray.length; i++) {\r
505                 this._segList.add(vSegArray[i]);\r
506         }\r
507     }\r
508 \r
509     /**\r
510      * Sets the value of '_segList' by copying the given Vector.\r
511      * All elements will be checked for type safety.\r
512      * \r
513      * @param vSegList the Vector to copy.\r
514      */\r
515     public void setSeg(\r
516             final java.util.Vector vSegList) {\r
517         // copy vector\r
518         this._segList.clear();\r
519         \r
520         this._segList.addAll(vSegList);\r
521     }\r
522 \r
523     /**\r
524      * Sets the value of '_segList' by setting it to the given\r
525      * Vector. No type checking is performed.\r
526      * @deprecated\r
527      * \r
528      * @param segVector the Vector to set.\r
529      */\r
530     public void setSegAsReference(\r
531             final java.util.Vector segVector) {\r
532         this._segList = segVector;\r
533     }\r
534 \r
535     /**\r
536      * \r
537      * \r
538      * @throws org.exolab.castor.xml.ValidationException if this\r
539      * object is an invalid instance according to the schema\r
540      */\r
541     public void validate(\r
542     )\r
543     throws org.exolab.castor.xml.ValidationException {\r
544         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
545         validator.validate(this);\r
546     }\r
547 \r
548 }\r