2 * This class was automatically generated with
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
8 package uk.ac.vamsas.objects.core;
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
18 * Class AnnotationElement.
20 * @version $Revision$ $Date$
22 public class AnnotationElement extends uk.ac.vamsas.client.Vobject
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * position with respect to the coordinate frame defined by a
33 * rangeType specification
35 private long _position;
38 * keeps track of state for field: _position
40 private boolean _has_position;
43 * true means the annotation element appears between the
44 * specified position and the next
46 private boolean _after = false;
49 * keeps track of state for field: _after
51 private boolean _has_after;
54 * Primary Key for vamsas object referencing
56 private java.lang.String _id;
59 * Free text at this position
61 private java.lang.String _description;
64 * Discrete symbol - possibly graphically represented
67 private java.util.Vector _glyphList;
70 * Ordered set of float values - an application may treat
71 * the values together as a vector with common support for a
73 * annotation elements - but this is, again, not validated so
75 * should deal gracefully with varying numbers of dimensions
78 private java.util.Vector _valueList;
85 public AnnotationElement() {
87 this._glyphList = new java.util.Vector();
88 this._valueList = new java.util.Vector();
100 * @throws java.lang.IndexOutOfBoundsException if the index
101 * given is outside the bounds of the collection
103 public void addGlyph(
104 final uk.ac.vamsas.objects.core.Glyph vGlyph)
105 throws java.lang.IndexOutOfBoundsException {
106 this._glyphList.addElement(vGlyph);
114 * @throws java.lang.IndexOutOfBoundsException if the index
115 * given is outside the bounds of the collection
117 public void addGlyph(
119 final uk.ac.vamsas.objects.core.Glyph vGlyph)
120 throws java.lang.IndexOutOfBoundsException {
121 this._glyphList.add(index, vGlyph);
128 * @throws java.lang.IndexOutOfBoundsException if the index
129 * given is outside the bounds of the collection
131 public void addValue(
133 throws java.lang.IndexOutOfBoundsException {
134 this._valueList.addElement(new java.lang.Float(vValue));
142 * @throws java.lang.IndexOutOfBoundsException if the index
143 * given is outside the bounds of the collection
145 public void addValue(
148 throws java.lang.IndexOutOfBoundsException {
149 this._valueList.add(index, new java.lang.Float(vValue));
154 public void deleteAfter(
156 this._has_after= false;
161 public void deletePosition(
163 this._has_position= false;
167 * Method enumerateGlyph.
169 * @return an Enumeration over all
170 * uk.ac.vamsas.objects.core.Glyph elements
172 public java.util.Enumeration enumerateGlyph(
174 return this._glyphList.elements();
178 * Method enumerateValue.
180 * @return an Enumeration over all float elements
182 public java.util.Enumeration enumerateValue(
184 return this._valueList.elements();
188 * Overrides the java.lang.Object.equals method.
191 * @return true if the objects are equal.
193 public boolean equals(
194 final java.lang.Object obj) {
198 if (super.equals(obj)==false)
201 if (obj instanceof AnnotationElement) {
203 AnnotationElement temp = (AnnotationElement)obj;
206 if (this._position != temp._position)
208 if (this._has_position != temp._has_position)
210 if (this._after != temp._after)
212 if (this._has_after != temp._has_after)
214 if (this._id != null) {
215 if (temp._id == null) return false;
216 if (this._id != temp._id) {
217 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);
218 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);
219 if (thcycle!=tmcycle) {
220 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };
221 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };
225 if (!this._id.equals(temp._id)) {
226 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
227 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
230 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
231 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
234 } else if (temp._id != null)
236 if (this._description != null) {
237 if (temp._description == null) return false;
238 if (this._description != temp._description) {
239 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._description);
240 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._description);
241 if (thcycle!=tmcycle) {
242 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._description); };
243 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._description); };
247 if (!this._description.equals(temp._description)) {
248 org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
249 org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
252 org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
253 org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
256 } else if (temp._description != null)
258 if (this._glyphList != null) {
259 if (temp._glyphList == null) return false;
260 if (this._glyphList != temp._glyphList) {
261 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._glyphList);
262 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._glyphList);
263 if (thcycle!=tmcycle) {
264 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList); };
265 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList); };
269 if (!this._glyphList.equals(temp._glyphList)) {
270 org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
271 org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
274 org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
275 org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
278 } else if (temp._glyphList != null)
280 if (this._valueList != null) {
281 if (temp._valueList == null) return false;
282 if (this._valueList != temp._valueList) {
283 thcycle=org.castor.util.CycleBreaker.startingToCycle(this._valueList);
284 tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._valueList);
285 if (thcycle!=tmcycle) {
286 if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList); };
287 if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList); };
291 if (!this._valueList.equals(temp._valueList)) {
292 org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
293 org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
296 org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
297 org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
300 } else if (temp._valueList != null)
308 * Returns the value of field 'after'. The field 'after' has
309 * the following description: true means the annotation element
310 * appears between the
311 * specified position and the next
313 * @return the value of field 'After'.
315 public boolean getAfter(
321 * Returns the value of field 'description'. The field
322 * 'description' has the following description: Free text at
325 * @return the value of field 'Description'.
327 public java.lang.String getDescription(
329 return this._description;
336 * @throws java.lang.IndexOutOfBoundsException if the index
337 * given is outside the bounds of the collection
338 * @return the value of the uk.ac.vamsas.objects.core.Glyph at
341 public uk.ac.vamsas.objects.core.Glyph getGlyph(
343 throws java.lang.IndexOutOfBoundsException {
344 // check bounds for index
345 if (index < 0 || index >= this._glyphList.size()) {
346 throw new IndexOutOfBoundsException("getGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
349 return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index);
353 * Method getGlyph.Returns the contents of the collection in an
354 * Array. <p>Note: Just in case the collection contents are
355 * changing in another thread, we pass a 0-length Array of the
356 * correct type into the API call. This way we <i>know</i>
357 * that the Array returned is of exactly the correct length.
359 * @return this collection as an Array
361 public uk.ac.vamsas.objects.core.Glyph[] getGlyph(
363 uk.ac.vamsas.objects.core.Glyph[] array = new uk.ac.vamsas.objects.core.Glyph[0];
364 return (uk.ac.vamsas.objects.core.Glyph[]) this._glyphList.toArray(array);
368 * Method getGlyphAsReference.Returns a reference to
369 * '_glyphList'. No type checking is performed on any
370 * modifications to the Vector.
372 * @return a reference to the Vector backing this class
374 public java.util.Vector getGlyphAsReference(
376 return this._glyphList;
380 * Method getGlyphCount.
382 * @return the size of this collection
384 public int getGlyphCount(
386 return this._glyphList.size();
390 * Returns the value of field 'id'. The field 'id' has the
391 * following description: Primary Key for vamsas object
394 * @return the value of field 'Id'.
396 public java.lang.String getId(
402 * Returns the value of field 'position'. The field 'position'
403 * has the following description: position with respect to the
404 * coordinate frame defined by a
405 * rangeType specification
407 * @return the value of field 'Position'.
409 public long getPosition(
411 return this._position;
418 * @throws java.lang.IndexOutOfBoundsException if the index
419 * given is outside the bounds of the collection
420 * @return the value of the float at the given index
422 public float getValue(
424 throws java.lang.IndexOutOfBoundsException {
425 // check bounds for index
426 if (index < 0 || index >= this._valueList.size()) {
427 throw new IndexOutOfBoundsException("getValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]");
430 return ((java.lang.Float) _valueList.get(index)).floatValue();
434 * Method getValue.Returns the contents of the collection in an
437 * @return this collection as an Array
439 public float[] getValue(
441 int size = this._valueList.size();
442 float[] array = new float[size];
443 java.util.Iterator iter = _valueList.iterator();
444 for (int index = 0; index < size; index++) {
445 array[index] = ((java.lang.Float) iter.next()).floatValue();
451 * Method getValueAsReference.Returns a reference to
452 * '_valueList'. No type checking is performed on any
453 * modifications to the Vector.
455 * @return a reference to the Vector backing this class
457 public java.util.Vector getValueAsReference(
459 return this._valueList;
463 * Method getValueCount.
465 * @return the size of this collection
467 public int getValueCount(
469 return this._valueList.size();
475 * @return true if at least one After has been added
477 public boolean hasAfter(
479 return this._has_after;
483 * Method hasPosition.
485 * @return true if at least one Position has been added
487 public boolean hasPosition(
489 return this._has_position;
493 * Overrides the java.lang.Object.hashCode method.
495 * The following steps came from <b>Effective Java Programming
496 * Language Guide</b> by Joshua Bloch, Chapter 3
498 * @return a hash code value for the object.
502 int result = super.hashCode();
505 result = 37 * result + (int)(_position^(_position>>>32));
506 result = 37 * result + (_after?0:1);
508 && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
509 result = 37 * result + _id.hashCode();
510 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
512 if (_description != null
513 && !org.castor.util.CycleBreaker.startingToCycle(_description)) {
514 result = 37 * result + _description.hashCode();
515 org.castor.util.CycleBreaker.releaseCycleHandle(_description);
517 if (_glyphList != null
518 && !org.castor.util.CycleBreaker.startingToCycle(_glyphList)) {
519 result = 37 * result + _glyphList.hashCode();
520 org.castor.util.CycleBreaker.releaseCycleHandle(_glyphList);
522 if (_valueList != null
523 && !org.castor.util.CycleBreaker.startingToCycle(_valueList)) {
524 result = 37 * result + _valueList.hashCode();
525 org.castor.util.CycleBreaker.releaseCycleHandle(_valueList);
532 * Returns the value of field 'after'. The field 'after' has
533 * the following description: true means the annotation element
534 * appears between the
535 * specified position and the next
537 * @return the value of field 'After'.
539 public boolean isAfter(
547 * @return true if this object is valid according to the schema
549 public boolean isValid(
553 } catch (org.exolab.castor.xml.ValidationException vex) {
563 * @throws org.exolab.castor.xml.MarshalException if object is
564 * null or if any SAXException is thrown during marshaling
565 * @throws org.exolab.castor.xml.ValidationException if this
566 * object is an invalid instance according to the schema
569 final java.io.Writer out)
570 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
571 Marshaller.marshal(this, out);
578 * @throws java.io.IOException if an IOException occurs during
580 * @throws org.exolab.castor.xml.ValidationException if this
581 * object is an invalid instance according to the schema
582 * @throws org.exolab.castor.xml.MarshalException if object is
583 * null or if any SAXException is thrown during marshaling
586 final org.xml.sax.ContentHandler handler)
587 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
588 Marshaller.marshal(this, handler);
593 public void removeAllGlyph(
595 this._glyphList.clear();
600 public void removeAllValue(
602 this._valueList.clear();
606 * Method removeGlyph.
609 * @return true if the object was removed from the collection.
611 public boolean removeGlyph(
612 final uk.ac.vamsas.objects.core.Glyph vGlyph) {
613 boolean removed = _glyphList.remove(vGlyph);
618 * Method removeGlyphAt.
621 * @return the element removed from the collection
623 public uk.ac.vamsas.objects.core.Glyph removeGlyphAt(
625 java.lang.Object obj = this._glyphList.remove(index);
626 return (uk.ac.vamsas.objects.core.Glyph) obj;
630 * Method removeValue.
633 * @return true if the object was removed from the collection.
635 public boolean removeValue(
636 final float vValue) {
637 boolean removed = _valueList.remove(new java.lang.Float(vValue));
642 * Method removeValueAt.
645 * @return the element removed from the collection
647 public float removeValueAt(
649 java.lang.Object obj = this._valueList.remove(index);
650 return ((java.lang.Float) obj).floatValue();
654 * Sets the value of field 'after'. The field 'after' has the
655 * following description: true means the annotation element
656 * appears between the
657 * specified position and the next
659 * @param after the value of field 'after'.
661 public void setAfter(
662 final boolean after) {
664 this._has_after = true;
668 * Sets the value of field 'description'. The field
669 * 'description' has the following description: Free text at
672 * @param description the value of field 'description'.
674 public void setDescription(
675 final java.lang.String description) {
676 this._description = description;
684 * @throws java.lang.IndexOutOfBoundsException if the index
685 * given is outside the bounds of the collection
687 public void setGlyph(
689 final uk.ac.vamsas.objects.core.Glyph vGlyph)
690 throws java.lang.IndexOutOfBoundsException {
691 // check bounds for index
692 if (index < 0 || index >= this._glyphList.size()) {
693 throw new IndexOutOfBoundsException("setGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
696 this._glyphList.set(index, vGlyph);
704 public void setGlyph(
705 final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) {
709 for (int i = 0; i < vGlyphArray.length; i++) {
710 this._glyphList.add(vGlyphArray[i]);
715 * Sets the value of '_glyphList' by copying the given Vector.
716 * All elements will be checked for type safety.
718 * @param vGlyphList the Vector to copy.
720 public void setGlyph(
721 final java.util.Vector vGlyphList) {
723 this._glyphList.clear();
725 this._glyphList.addAll(vGlyphList);
729 * Sets the value of '_glyphList' by setting it to the given
730 * Vector. No type checking is performed.
733 * @param glyphVector the Vector to set.
735 public void setGlyphAsReference(
736 final java.util.Vector glyphVector) {
737 this._glyphList = glyphVector;
741 * Sets the value of field 'id'. The field 'id' has the
742 * following description: Primary Key for vamsas object
745 * @param id the value of field 'id'.
748 final java.lang.String id) {
753 * Sets the value of field 'position'. The field 'position' has
754 * the following description: position with respect to the
755 * coordinate frame defined by a
756 * rangeType specification
758 * @param position the value of field 'position'.
760 public void setPosition(
761 final long position) {
762 this._position = position;
763 this._has_position = true;
771 * @throws java.lang.IndexOutOfBoundsException if the index
772 * given is outside the bounds of the collection
774 public void setValue(
777 throws java.lang.IndexOutOfBoundsException {
778 // check bounds for index
779 if (index < 0 || index >= this._valueList.size()) {
780 throw new IndexOutOfBoundsException("setValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]");
783 this._valueList.set(index, new java.lang.Float(vValue));
791 public void setValue(
792 final float[] vValueArray) {
796 for (int i = 0; i < vValueArray.length; i++) {
797 this._valueList.add(new java.lang.Float(vValueArray[i]));
802 * Sets the value of '_valueList' by copying the given Vector.
803 * All elements will be checked for type safety.
805 * @param vValueList the Vector to copy.
807 public void setValue(
808 final java.util.Vector vValueList) {
810 this._valueList.clear();
812 this._valueList.addAll(vValueList);
816 * Sets the value of '_valueList' by setting it to the given
817 * Vector. No type checking is performed.
820 * @param valueVector the Vector to set.
822 public void setValueAsReference(
823 final java.util.Vector valueVector) {
824 this._valueList = valueVector;
831 * @throws org.exolab.castor.xml.MarshalException if object is
832 * null or if any SAXException is thrown during marshaling
833 * @throws org.exolab.castor.xml.ValidationException if this
834 * object is an invalid instance according to the schema
835 * @return the unmarshaled
836 * uk.ac.vamsas.objects.core.AnnotationElement
838 public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal(
839 final java.io.Reader reader)
840 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
841 return (uk.ac.vamsas.objects.core.AnnotationElement) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AnnotationElement.class, reader);
847 * @throws org.exolab.castor.xml.ValidationException if this
848 * object is an invalid instance according to the schema
850 public void validate(
852 throws org.exolab.castor.xml.ValidationException {
853 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
854 validator.validate(this);