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;
204 if (this._position != temp._position)
206 if (this._has_position != temp._has_position)
208 if (this._after != temp._after)
210 if (this._has_after != temp._has_after)
212 if (this._id != null) {
213 if (temp._id == null) return false;
214 else if (!(this._id.equals(temp._id)))
217 else if (temp._id != null)
219 if (this._description != null) {
220 if (temp._description == null) return false;
221 else if (!(this._description.equals(temp._description)))
224 else if (temp._description != null)
226 if (this._glyphList != null) {
227 if (temp._glyphList == null) return false;
228 else if (!(this._glyphList.equals(temp._glyphList)))
231 else if (temp._glyphList != null)
233 if (this._valueList != null) {
234 if (temp._valueList == null) return false;
235 else if (!(this._valueList.equals(temp._valueList)))
238 else if (temp._valueList != null)
246 * Returns the value of field 'after'. The field 'after' has
247 * the following description: true means the annotation element
248 * appears between the
249 * specified position and the next
251 * @return the value of field 'After'.
253 public boolean getAfter(
259 * Returns the value of field 'description'. The field
260 * 'description' has the following description: Free text at
263 * @return the value of field 'Description'.
265 public java.lang.String getDescription(
267 return this._description;
274 * @throws java.lang.IndexOutOfBoundsException if the index
275 * given is outside the bounds of the collection
276 * @return the value of the uk.ac.vamsas.objects.core.Glyph at
279 public uk.ac.vamsas.objects.core.Glyph getGlyph(
281 throws java.lang.IndexOutOfBoundsException {
282 // check bounds for index
283 if (index < 0 || index >= this._glyphList.size()) {
284 throw new IndexOutOfBoundsException("getGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
287 return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index);
291 * Method getGlyph.Returns the contents of the collection in an
292 * Array. <p>Note: Just in case the collection contents are
293 * changing in another thread, we pass a 0-length Array of the
294 * correct type into the API call. This way we <i>know</i>
295 * that the Array returned is of exactly the correct length.
297 * @return this collection as an Array
299 public uk.ac.vamsas.objects.core.Glyph[] getGlyph(
301 uk.ac.vamsas.objects.core.Glyph[] array = new uk.ac.vamsas.objects.core.Glyph[0];
302 return (uk.ac.vamsas.objects.core.Glyph[]) this._glyphList.toArray(array);
306 * Method getGlyphAsReference.Returns a reference to
307 * '_glyphList'. No type checking is performed on any
308 * modifications to the Vector.
310 * @return a reference to the Vector backing this class
312 public java.util.Vector getGlyphAsReference(
314 return this._glyphList;
318 * Method getGlyphCount.
320 * @return the size of this collection
322 public int getGlyphCount(
324 return this._glyphList.size();
328 * Returns the value of field 'id'. The field 'id' has the
329 * following description: Primary Key for vamsas object
332 * @return the value of field 'Id'.
334 public java.lang.String getId(
340 * Returns the value of field 'position'. The field 'position'
341 * has the following description: position with respect to the
342 * coordinate frame defined by a
343 * rangeType specification
345 * @return the value of field 'Position'.
347 public long getPosition(
349 return this._position;
356 * @throws java.lang.IndexOutOfBoundsException if the index
357 * given is outside the bounds of the collection
358 * @return the value of the float at the given index
360 public float getValue(
362 throws java.lang.IndexOutOfBoundsException {
363 // check bounds for index
364 if (index < 0 || index >= this._valueList.size()) {
365 throw new IndexOutOfBoundsException("getValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]");
368 return ((java.lang.Float) _valueList.get(index)).floatValue();
372 * Method getValue.Returns the contents of the collection in an
375 * @return this collection as an Array
377 public float[] getValue(
379 int size = this._valueList.size();
380 float[] array = new float[size];
381 java.util.Iterator iter = _valueList.iterator();
382 for (int index = 0; index < size; index++) {
383 array[index] = ((java.lang.Float) iter.next()).floatValue();
389 * Method getValueAsReference.Returns a reference to
390 * '_valueList'. No type checking is performed on any
391 * modifications to the Vector.
393 * @return a reference to the Vector backing this class
395 public java.util.Vector getValueAsReference(
397 return this._valueList;
401 * Method getValueCount.
403 * @return the size of this collection
405 public int getValueCount(
407 return this._valueList.size();
413 * @return true if at least one After has been added
415 public boolean hasAfter(
417 return this._has_after;
421 * Method hasPosition.
423 * @return true if at least one Position has been added
425 public boolean hasPosition(
427 return this._has_position;
431 * Overrides the java.lang.Object.hashCode method.
433 * The following steps came from <b>Effective Java Programming
434 * Language Guide</b> by Joshua Bloch, Chapter 3
436 * @return a hash code value for the object.
440 int result = super.hashCode();
443 result = 37 * result + (int)(_position^(_position>>>32));
444 result = 37 * result + (_after?0:1);
446 result = 37 * result + _id.hashCode();
448 if (_description != null) {
449 result = 37 * result + _description.hashCode();
451 if (_glyphList != null) {
452 result = 37 * result + _glyphList.hashCode();
454 if (_valueList != null) {
455 result = 37 * result + _valueList.hashCode();
462 * Returns the value of field 'after'. The field 'after' has
463 * the following description: true means the annotation element
464 * appears between the
465 * specified position and the next
467 * @return the value of field 'After'.
469 public boolean isAfter(
477 * @return true if this object is valid according to the schema
479 public boolean isValid(
483 } catch (org.exolab.castor.xml.ValidationException vex) {
493 * @throws org.exolab.castor.xml.MarshalException if object is
494 * null or if any SAXException is thrown during marshaling
495 * @throws org.exolab.castor.xml.ValidationException if this
496 * object is an invalid instance according to the schema
499 final java.io.Writer out)
500 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
501 Marshaller.marshal(this, out);
508 * @throws java.io.IOException if an IOException occurs during
510 * @throws org.exolab.castor.xml.ValidationException if this
511 * object is an invalid instance according to the schema
512 * @throws org.exolab.castor.xml.MarshalException if object is
513 * null or if any SAXException is thrown during marshaling
516 final org.xml.sax.ContentHandler handler)
517 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
518 Marshaller.marshal(this, handler);
523 public void removeAllGlyph(
525 this._glyphList.clear();
530 public void removeAllValue(
532 this._valueList.clear();
536 * Method removeGlyph.
539 * @return true if the object was removed from the collection.
541 public boolean removeGlyph(
542 final uk.ac.vamsas.objects.core.Glyph vGlyph) {
543 boolean removed = _glyphList.remove(vGlyph);
548 * Method removeGlyphAt.
551 * @return the element removed from the collection
553 public uk.ac.vamsas.objects.core.Glyph removeGlyphAt(
555 java.lang.Object obj = this._glyphList.remove(index);
556 return (uk.ac.vamsas.objects.core.Glyph) obj;
560 * Method removeValue.
563 * @return true if the object was removed from the collection.
565 public boolean removeValue(
566 final float vValue) {
567 boolean removed = _valueList.remove(new java.lang.Float(vValue));
572 * Method removeValueAt.
575 * @return the element removed from the collection
577 public float removeValueAt(
579 java.lang.Object obj = this._valueList.remove(index);
580 return ((java.lang.Float) obj).floatValue();
584 * Sets the value of field 'after'. The field 'after' has the
585 * following description: true means the annotation element
586 * appears between the
587 * specified position and the next
589 * @param after the value of field 'after'.
591 public void setAfter(
592 final boolean after) {
594 this._has_after = true;
598 * Sets the value of field 'description'. The field
599 * 'description' has the following description: Free text at
602 * @param description the value of field 'description'.
604 public void setDescription(
605 final java.lang.String description) {
606 this._description = description;
614 * @throws java.lang.IndexOutOfBoundsException if the index
615 * given is outside the bounds of the collection
617 public void setGlyph(
619 final uk.ac.vamsas.objects.core.Glyph vGlyph)
620 throws java.lang.IndexOutOfBoundsException {
621 // check bounds for index
622 if (index < 0 || index >= this._glyphList.size()) {
623 throw new IndexOutOfBoundsException("setGlyph: Index value '" + index + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
626 this._glyphList.set(index, vGlyph);
634 public void setGlyph(
635 final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) {
639 for (int i = 0; i < vGlyphArray.length; i++) {
640 this._glyphList.add(vGlyphArray[i]);
645 * Sets the value of '_glyphList' by copying the given Vector.
646 * All elements will be checked for type safety.
648 * @param vGlyphList the Vector to copy.
650 public void setGlyph(
651 final java.util.Vector vGlyphList) {
653 this._glyphList.clear();
655 this._glyphList.addAll(vGlyphList);
659 * Sets the value of '_glyphList' by setting it to the given
660 * Vector. No type checking is performed.
663 * @param glyphVector the Vector to set.
665 public void setGlyphAsReference(
666 final java.util.Vector glyphVector) {
667 this._glyphList = glyphVector;
671 * Sets the value of field 'id'. The field 'id' has the
672 * following description: Primary Key for vamsas object
675 * @param id the value of field 'id'.
678 final java.lang.String id) {
683 * Sets the value of field 'position'. The field 'position' has
684 * the following description: position with respect to the
685 * coordinate frame defined by a
686 * rangeType specification
688 * @param position the value of field 'position'.
690 public void setPosition(
691 final long position) {
692 this._position = position;
693 this._has_position = true;
701 * @throws java.lang.IndexOutOfBoundsException if the index
702 * given is outside the bounds of the collection
704 public void setValue(
707 throws java.lang.IndexOutOfBoundsException {
708 // check bounds for index
709 if (index < 0 || index >= this._valueList.size()) {
710 throw new IndexOutOfBoundsException("setValue: Index value '" + index + "' not in range [0.." + (this._valueList.size() - 1) + "]");
713 this._valueList.set(index, new java.lang.Float(vValue));
721 public void setValue(
722 final float[] vValueArray) {
726 for (int i = 0; i < vValueArray.length; i++) {
727 this._valueList.add(new java.lang.Float(vValueArray[i]));
732 * Sets the value of '_valueList' by copying the given Vector.
733 * All elements will be checked for type safety.
735 * @param vValueList the Vector to copy.
737 public void setValue(
738 final java.util.Vector vValueList) {
740 this._valueList.clear();
742 this._valueList.addAll(vValueList);
746 * Sets the value of '_valueList' by setting it to the given
747 * Vector. No type checking is performed.
750 * @param valueVector the Vector to set.
752 public void setValueAsReference(
753 final java.util.Vector valueVector) {
754 this._valueList = valueVector;
761 * @throws org.exolab.castor.xml.MarshalException if object is
762 * null or if any SAXException is thrown during marshaling
763 * @throws org.exolab.castor.xml.ValidationException if this
764 * object is an invalid instance according to the schema
765 * @return the unmarshaled
766 * uk.ac.vamsas.objects.core.AnnotationElement
768 public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal(
769 final java.io.Reader reader)
770 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
771 return (uk.ac.vamsas.objects.core.AnnotationElement) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AnnotationElement.class, reader);
777 * @throws org.exolab.castor.xml.ValidationException if this
778 * object is an invalid instance according to the schema
780 public void validate(
782 throws org.exolab.castor.xml.ValidationException {
783 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
784 validator.validate(this);