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
158 if (this._choiceValue != null) {
\r
159 if (temp._choiceValue == null) return false;
\r
160 else if (!(this._choiceValue.equals(temp._choiceValue)))
\r
163 else if (temp._choiceValue != null)
\r
165 if (this._posList != null) {
\r
166 if (temp._posList == null) return false;
\r
167 else if (!(this._posList.equals(temp._posList)))
\r
170 else if (temp._posList != null)
\r
172 if (this._segList != null) {
\r
173 if (temp._segList == null) return false;
\r
174 else if (!(this._segList.equals(temp._segList)))
\r
177 else if (temp._segList != null)
\r
185 * Returns the value of field 'choiceValue'. The field
\r
186 * 'choiceValue' has the following description: Internal choice
\r
189 * @return the value of field 'ChoiceValue'.
\r
191 public java.lang.Object getChoiceValue(
\r
193 return this._choiceValue;
\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
205 public uk.ac.vamsas.objects.core.Pos getPos(
\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
213 return (uk.ac.vamsas.objects.core.Pos) _posList.get(index);
\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
223 * @return this collection as an Array
\r
225 public uk.ac.vamsas.objects.core.Pos[] getPos(
\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
232 * Method getPosAsReference.Returns a reference to '_posList'.
\r
233 * No type checking is performed on any modifications to the
\r
236 * @return a reference to the Vector backing this class
\r
238 public java.util.Vector getPosAsReference(
\r
240 return this._posList;
\r
244 * Method getPosCount.
\r
246 * @return the size of this collection
\r
248 public int getPosCount(
\r
250 return this._posList.size();
\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
262 public uk.ac.vamsas.objects.core.Seg getSeg(
\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
270 return (uk.ac.vamsas.objects.core.Seg) _segList.get(index);
\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
280 * @return this collection as an Array
\r
282 public uk.ac.vamsas.objects.core.Seg[] getSeg(
\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
289 * Method getSegAsReference.Returns a reference to '_segList'.
\r
290 * No type checking is performed on any modifications to the
\r
293 * @return a reference to the Vector backing this class
\r
295 public java.util.Vector getSegAsReference(
\r
297 return this._segList;
\r
301 * Method getSegCount.
\r
303 * @return the size of this collection
\r
305 public int getSegCount(
\r
307 return this._segList.size();
\r
311 * Overrides the java.lang.Object.hashCode method.
\r
313 * The following steps came from <b>Effective Java Programming
\r
314 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
316 * @return a hash code value for the object.
\r
318 public int hashCode(
\r
320 int result = super.hashCode();
\r
323 if (_choiceValue != null) {
\r
324 result = 37 * result + _choiceValue.hashCode();
\r
326 if (_posList != null) {
\r
327 result = 37 * result + _posList.hashCode();
\r
329 if (_segList != null) {
\r
330 result = 37 * result + _segList.hashCode();
\r
339 * @return true if this object is valid according to the schema
\r
341 public boolean isValid(
\r
345 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
353 public void removeAllPos(
\r
355 this._posList.clear();
\r
360 public void removeAllSeg(
\r
362 this._segList.clear();
\r
366 * Method removePos.
\r
369 * @return true if the object was removed from the collection.
\r
371 public boolean removePos(
\r
372 final uk.ac.vamsas.objects.core.Pos vPos) {
\r
373 boolean removed = _posList.remove(vPos);
\r
378 * Method removePosAt.
\r
381 * @return the element removed from the collection
\r
383 public uk.ac.vamsas.objects.core.Pos removePosAt(
\r
385 java.lang.Object obj = this._posList.remove(index);
\r
386 return (uk.ac.vamsas.objects.core.Pos) obj;
\r
390 * Method removeSeg.
\r
393 * @return true if the object was removed from the collection.
\r
395 public boolean removeSeg(
\r
396 final uk.ac.vamsas.objects.core.Seg vSeg) {
\r
397 boolean removed = _segList.remove(vSeg);
\r
402 * Method removeSegAt.
\r
405 * @return the element removed from the collection
\r
407 public uk.ac.vamsas.objects.core.Seg removeSegAt(
\r
409 java.lang.Object obj = this._segList.remove(index);
\r
410 return (uk.ac.vamsas.objects.core.Seg) obj;
\r
418 * @throws java.lang.IndexOutOfBoundsException if the index
\r
419 * given is outside the bounds of the collection
\r
421 public void setPos(
\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
430 this._posList.set(index, vPos);
\r
438 public void setPos(
\r
439 final uk.ac.vamsas.objects.core.Pos[] vPosArray) {
\r
443 for (int i = 0; i < vPosArray.length; i++) {
\r
444 this._posList.add(vPosArray[i]);
\r
449 * Sets the value of '_posList' by copying the given Vector.
\r
450 * All elements will be checked for type safety.
\r
452 * @param vPosList the Vector to copy.
\r
454 public void setPos(
\r
455 final java.util.Vector vPosList) {
\r
457 this._posList.clear();
\r
459 this._posList.addAll(vPosList);
\r
463 * Sets the value of '_posList' by setting it to the given
\r
464 * Vector. No type checking is performed.
\r
467 * @param posVector the Vector to set.
\r
469 public void setPosAsReference(
\r
470 final java.util.Vector posVector) {
\r
471 this._posList = posVector;
\r
479 * @throws java.lang.IndexOutOfBoundsException if the index
\r
480 * given is outside the bounds of the collection
\r
482 public void setSeg(
\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
491 this._segList.set(index, vSeg);
\r
499 public void setSeg(
\r
500 final uk.ac.vamsas.objects.core.Seg[] vSegArray) {
\r
504 for (int i = 0; i < vSegArray.length; i++) {
\r
505 this._segList.add(vSegArray[i]);
\r
510 * Sets the value of '_segList' by copying the given Vector.
\r
511 * All elements will be checked for type safety.
\r
513 * @param vSegList the Vector to copy.
\r
515 public void setSeg(
\r
516 final java.util.Vector vSegList) {
\r
518 this._segList.clear();
\r
520 this._segList.addAll(vSegList);
\r
524 * Sets the value of '_segList' by setting it to the given
\r
525 * Vector. No type checking is performed.
\r
528 * @param segVector the Vector to set.
\r
530 public void setSegAsReference(
\r
531 final java.util.Vector segVector) {
\r
532 this._segList = segVector;
\r
538 * @throws org.exolab.castor.xml.ValidationException if this
\r
539 * object is an invalid instance according to the schema
\r
541 public void validate(
\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