2 * This class was automatically generated with
\r
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
\r
8 package uk.ac.vamsas.objects.core;
\r
11 * Specify an ordered set of positions and/or regions on the
\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
19 * @version $Revision$ $Date$
\r
21 public abstract class RangeType extends uk.ac.vamsas.client.Vobject
\r
22 implements java.io.Serializable
\r
26 //--------------------------/
\r
27 //- Class/Member Variables -/
\r
28 //--------------------------/
\r
31 * Internal choice value storage
\r
33 private java.lang.Object _choiceValue;
\r
36 * a position within the associated object's coordinate system
\r
39 private java.util.Vector _posList;
\r
42 * a region from start to end, with flag for inclusivity of
\r
45 private java.util.Vector _segList;
\r
52 public RangeType() {
\r
54 this._posList = new java.util.Vector();
\r
55 this._segList = new java.util.Vector();
\r
67 * @throws java.lang.IndexOutOfBoundsException if the index
\r
68 * given is outside the bounds of the collection
\r
71 final uk.ac.vamsas.objects.core.Pos vPos)
\r
72 throws java.lang.IndexOutOfBoundsException {
\r
73 this._posList.addElement(vPos);
\r
81 * @throws java.lang.IndexOutOfBoundsException if the index
\r
82 * given is outside the bounds of the collection
\r
86 final uk.ac.vamsas.objects.core.Pos vPos)
\r
87 throws java.lang.IndexOutOfBoundsException {
\r
88 this._posList.add(index, vPos);
\r
95 * @throws java.lang.IndexOutOfBoundsException if the index
\r
96 * given is outside the bounds of the collection
\r
99 final uk.ac.vamsas.objects.core.Seg vSeg)
\r
100 throws java.lang.IndexOutOfBoundsException {
\r
101 this._segList.addElement(vSeg);
\r
109 * @throws java.lang.IndexOutOfBoundsException if the index
\r
110 * given is outside the bounds of the collection
\r
112 public void addSeg(
\r
114 final uk.ac.vamsas.objects.core.Seg vSeg)
\r
115 throws java.lang.IndexOutOfBoundsException {
\r
116 this._segList.add(index, vSeg);
\r
120 * Method enumeratePos.
\r
122 * @return an Enumeration over all
\r
123 * uk.ac.vamsas.objects.core.Pos elements
\r
125 public java.util.Enumeration enumeratePos(
\r
127 return this._posList.elements();
\r
131 * Method enumerateSeg.
\r
133 * @return an Enumeration over all
\r
134 * uk.ac.vamsas.objects.core.Seg elements
\r
136 public java.util.Enumeration enumerateSeg(
\r
138 return this._segList.elements();
\r
142 * Overrides the java.lang.Object.equals method.
\r
145 * @return true if the objects are equal.
\r
147 public boolean equals(
\r
148 final java.lang.Object obj) {
\r
152 if (super.equals(obj)==false)
\r
155 if (obj instanceof RangeType) {
\r
157 RangeType temp = (RangeType)obj;
\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
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
176 org.castor.util.CycleBreaker.releaseCycleHandle(this._choiceValue);
\r
177 org.castor.util.CycleBreaker.releaseCycleHandle(temp._choiceValue);
\r
180 } else if (temp._choiceValue != null)
\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
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
198 org.castor.util.CycleBreaker.releaseCycleHandle(this._posList);
\r
199 org.castor.util.CycleBreaker.releaseCycleHandle(temp._posList);
\r
202 } else if (temp._posList != null)
\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
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
220 org.castor.util.CycleBreaker.releaseCycleHandle(this._segList);
\r
221 org.castor.util.CycleBreaker.releaseCycleHandle(temp._segList);
\r
224 } else if (temp._segList != null)
\r
232 * Returns the value of field 'choiceValue'. The field
\r
233 * 'choiceValue' has the following description: Internal choice
\r
236 * @return the value of field 'ChoiceValue'.
\r
238 public java.lang.Object getChoiceValue(
\r
240 return this._choiceValue;
\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
252 public uk.ac.vamsas.objects.core.Pos getPos(
\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
260 return (uk.ac.vamsas.objects.core.Pos) _posList.get(index);
\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
270 * @return this collection as an Array
\r
272 public uk.ac.vamsas.objects.core.Pos[] getPos(
\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
279 * Method getPosAsReference.Returns a reference to '_posList'.
\r
280 * No type checking is performed on any modifications to the
\r
283 * @return a reference to the Vector backing this class
\r
285 public java.util.Vector getPosAsReference(
\r
287 return this._posList;
\r
291 * Method getPosCount.
\r
293 * @return the size of this collection
\r
295 public int getPosCount(
\r
297 return this._posList.size();
\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
309 public uk.ac.vamsas.objects.core.Seg getSeg(
\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
317 return (uk.ac.vamsas.objects.core.Seg) _segList.get(index);
\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
327 * @return this collection as an Array
\r
329 public uk.ac.vamsas.objects.core.Seg[] getSeg(
\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
336 * Method getSegAsReference.Returns a reference to '_segList'.
\r
337 * No type checking is performed on any modifications to the
\r
340 * @return a reference to the Vector backing this class
\r
342 public java.util.Vector getSegAsReference(
\r
344 return this._segList;
\r
348 * Method getSegCount.
\r
350 * @return the size of this collection
\r
352 public int getSegCount(
\r
354 return this._segList.size();
\r
358 * Overrides the java.lang.Object.hashCode method.
\r
360 * The following steps came from <b>Effective Java Programming
\r
361 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
363 * @return a hash code value for the object.
\r
365 public int hashCode(
\r
367 int result = super.hashCode();
\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
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
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
392 * @return true if this object is valid according to the schema
\r
394 public boolean isValid(
\r
398 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
406 public void removeAllPos(
\r
408 this._posList.clear();
\r
413 public void removeAllSeg(
\r
415 this._segList.clear();
\r
419 * Method removePos.
\r
422 * @return true if the object was removed from the collection.
\r
424 public boolean removePos(
\r
425 final uk.ac.vamsas.objects.core.Pos vPos) {
\r
426 boolean removed = _posList.remove(vPos);
\r
431 * Method removePosAt.
\r
434 * @return the element removed from the collection
\r
436 public uk.ac.vamsas.objects.core.Pos removePosAt(
\r
438 java.lang.Object obj = this._posList.remove(index);
\r
439 return (uk.ac.vamsas.objects.core.Pos) obj;
\r
443 * Method removeSeg.
\r
446 * @return true if the object was removed from the collection.
\r
448 public boolean removeSeg(
\r
449 final uk.ac.vamsas.objects.core.Seg vSeg) {
\r
450 boolean removed = _segList.remove(vSeg);
\r
455 * Method removeSegAt.
\r
458 * @return the element removed from the collection
\r
460 public uk.ac.vamsas.objects.core.Seg removeSegAt(
\r
462 java.lang.Object obj = this._segList.remove(index);
\r
463 return (uk.ac.vamsas.objects.core.Seg) obj;
\r
471 * @throws java.lang.IndexOutOfBoundsException if the index
\r
472 * given is outside the bounds of the collection
\r
474 public void setPos(
\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
483 this._posList.set(index, vPos);
\r
491 public void setPos(
\r
492 final uk.ac.vamsas.objects.core.Pos[] vPosArray) {
\r
496 for (int i = 0; i < vPosArray.length; i++) {
\r
497 this._posList.add(vPosArray[i]);
\r
502 * Sets the value of '_posList' by copying the given Vector.
\r
503 * All elements will be checked for type safety.
\r
505 * @param vPosList the Vector to copy.
\r
507 public void setPos(
\r
508 final java.util.Vector vPosList) {
\r
510 this._posList.clear();
\r
512 this._posList.addAll(vPosList);
\r
516 * Sets the value of '_posList' by setting it to the given
\r
517 * Vector. No type checking is performed.
\r
520 * @param posVector the Vector to set.
\r
522 public void setPosAsReference(
\r
523 final java.util.Vector posVector) {
\r
524 this._posList = posVector;
\r
532 * @throws java.lang.IndexOutOfBoundsException if the index
\r
533 * given is outside the bounds of the collection
\r
535 public void setSeg(
\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
544 this._segList.set(index, vSeg);
\r
552 public void setSeg(
\r
553 final uk.ac.vamsas.objects.core.Seg[] vSegArray) {
\r
557 for (int i = 0; i < vSegArray.length; i++) {
\r
558 this._segList.add(vSegArray[i]);
\r
563 * Sets the value of '_segList' by copying the given Vector.
\r
564 * All elements will be checked for type safety.
\r
566 * @param vSegList the Vector to copy.
\r
568 public void setSeg(
\r
569 final java.util.Vector vSegList) {
\r
571 this._segList.clear();
\r
573 this._segList.addAll(vSegList);
\r
577 * Sets the value of '_segList' by setting it to the given
\r
578 * Vector. No type checking is performed.
\r
581 * @param segVector the Vector to set.
\r
583 public void setSegAsReference(
\r
584 final java.util.Vector segVector) {
\r
585 this._segList = segVector;
\r
591 * @throws org.exolab.castor.xml.ValidationException if this
\r
592 * object is an invalid instance according to the schema
\r
594 public void validate(
\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