2 * This class was automatically generated with
3 * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
5 * $Id:AnnotationElement.java 264 2006-12-14 17:42:54Z JimP $
8 package uk.ac.vamsas.objects.core;
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
27 * Class AnnotationElement.
29 * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $
31 public class AnnotationElement extends uk.ac.vamsas.client.Vobject
32 implements java.io.Serializable
36 //--------------------------/
37 //- Class/Member Variables -/
38 //--------------------------/
41 * position with respect to the coordinate frame defined by a
42 * rangeType specification
44 private int _position;
47 * keeps track of state for field: _position
49 private boolean _has_position;
52 * true means the annotation element appears between the
53 * specified position and the next
55 private boolean _after = false;
58 * keeps track of state for field: _after
60 private boolean _has_after;
63 * Primary Key for vamsas object referencing
65 private java.lang.String _id;
68 * Free text at this position
70 private java.lang.String _description;
73 * Discrete symbol - possibly graphically represented
76 private java.util.Vector _glyphList;
79 * Ordered set of float values - an application may treat
80 * the values together as a vector with common support for a
82 * annotation elements - but this is, again, not validated so
84 * should deal gracefully with varying numbers of dimensions
87 private java.util.Vector _valueList;
94 public AnnotationElement()
97 _glyphList = new Vector();
98 _valueList = new Vector();
99 } //-- uk.ac.vamsas.objects.core.AnnotationElement()
113 public void addGlyph(uk.ac.vamsas.objects.core.Glyph vGlyph)
114 throws java.lang.IndexOutOfBoundsException
116 _glyphList.addElement(vGlyph);
117 } //-- void addGlyph(uk.ac.vamsas.objects.core.Glyph)
127 public void addGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph)
128 throws java.lang.IndexOutOfBoundsException
130 _glyphList.insertElementAt(vGlyph, index);
131 } //-- void addGlyph(int, uk.ac.vamsas.objects.core.Glyph)
140 public void addValue(float vValue)
141 throws java.lang.IndexOutOfBoundsException
143 _valueList.addElement(new java.lang.Float(vValue));
144 } //-- void addValue(float)
154 public void addValue(int index, float vValue)
155 throws java.lang.IndexOutOfBoundsException
157 _valueList.insertElementAt(new java.lang.Float(vValue), index);
158 } //-- void addValue(int, float)
164 public void deleteAfter()
166 this._has_after= false;
167 } //-- void deleteAfter()
170 * Method deletePosition
173 public void deletePosition()
175 this._has_position= false;
176 } //-- void deletePosition()
179 * Method enumerateGlyph
183 * @return Enumeration
185 public java.util.Enumeration enumerateGlyph()
187 return _glyphList.elements();
188 } //-- java.util.Enumeration enumerateGlyph()
191 * Method enumerateValue
195 * @return Enumeration
197 public java.util.Enumeration enumerateValue()
199 return _valueList.elements();
200 } //-- java.util.Enumeration enumerateValue()
203 * Note: hashCode() has not been overriden
208 public boolean equals(java.lang.Object obj)
213 if (super.equals(obj)==false)
216 if (obj instanceof AnnotationElement) {
218 AnnotationElement temp = (AnnotationElement)obj;
219 if (this._position != temp._position)
221 if (this._has_position != temp._has_position)
223 if (this._after != temp._after)
225 if (this._has_after != temp._has_after)
227 if (this._id != null) {
228 if (temp._id == null) return false;
229 else if (!(this._id.equals(temp._id)))
232 else if (temp._id != null)
234 if (this._description != null) {
235 if (temp._description == null) return false;
236 else if (!(this._description.equals(temp._description)))
239 else if (temp._description != null)
241 if (this._glyphList != null) {
242 if (temp._glyphList == null) return false;
243 else if (!(this._glyphList.equals(temp._glyphList)))
246 else if (temp._glyphList != null)
248 if (this._valueList != null) {
249 if (temp._valueList == null) return false;
250 else if (!(this._valueList.equals(temp._valueList)))
253 else if (temp._valueList != null)
258 } //-- boolean equals(java.lang.Object)
261 * Returns the value of field 'after'. The field 'after' has
262 * the following description: true means the annotation element
263 * appears between the
264 * specified position and the next
267 * @return the value of field 'after'.
269 public boolean getAfter()
272 } //-- boolean getAfter()
275 * Returns the value of field 'description'. The field
276 * 'description' has the following description: Free text at
280 * @return the value of field 'description'.
282 public java.lang.String getDescription()
284 return this._description;
285 } //-- java.lang.String getDescription()
295 public uk.ac.vamsas.objects.core.Glyph getGlyph(int index)
296 throws java.lang.IndexOutOfBoundsException
298 //-- check bounds for index
299 if ((index < 0) || (index > _glyphList.size())) {
300 throw new IndexOutOfBoundsException("getGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]");
303 return (uk.ac.vamsas.objects.core.Glyph) _glyphList.elementAt(index);
304 } //-- uk.ac.vamsas.objects.core.Glyph getGlyph(int)
313 public uk.ac.vamsas.objects.core.Glyph[] getGlyph()
315 int size = _glyphList.size();
316 uk.ac.vamsas.objects.core.Glyph[] mArray = new uk.ac.vamsas.objects.core.Glyph[size];
317 for (int index = 0; index < size; index++) {
318 mArray[index] = (uk.ac.vamsas.objects.core.Glyph) _glyphList.elementAt(index);
321 } //-- uk.ac.vamsas.objects.core.Glyph[] getGlyph()
324 * Method getGlyphCount
330 public int getGlyphCount()
332 return _glyphList.size();
333 } //-- int getGlyphCount()
336 * Returns the value of field 'id'. The field 'id' has the
337 * following description: Primary Key for vamsas object
341 * @return the value of field 'id'.
343 public java.lang.String getId()
346 } //-- java.lang.String getId()
349 * Returns the value of field 'position'. The field 'position'
350 * has the following description: position with respect to the
351 * coordinate frame defined by a
352 * rangeType specification
355 * @return the value of field 'position'.
357 public int getPosition()
359 return this._position;
360 } //-- int getPosition()
370 public float getValue(int index)
371 throws java.lang.IndexOutOfBoundsException
373 //-- check bounds for index
374 if ((index < 0) || (index > _valueList.size())) {
375 throw new IndexOutOfBoundsException("getValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]");
378 return ((java.lang.Float)_valueList.elementAt(index)).floatValue();
379 } //-- float getValue(int)
388 public float[] getValue()
390 int size = _valueList.size();
391 float[] mArray = new float[size];
392 for (int index = 0; index < size; index++) {
393 mArray[index] = ((java.lang.Float)_valueList.elementAt(index)).floatValue();
396 } //-- float[] getValue()
399 * Method getValueCount
405 public int getValueCount()
407 return _valueList.size();
408 } //-- int getValueCount()
417 public boolean hasAfter()
419 return this._has_after;
420 } //-- boolean hasAfter()
429 public boolean hasPosition()
431 return this._has_position;
432 } //-- boolean hasPosition()
441 public boolean isValid()
446 catch (org.exolab.castor.xml.ValidationException vex) {
450 } //-- boolean isValid()
459 public void marshal(java.io.Writer out)
460 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
463 Marshaller.marshal(this, out);
464 } //-- void marshal(java.io.Writer)
473 public void marshal(org.xml.sax.ContentHandler handler)
474 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
477 Marshaller.marshal(this, handler);
478 } //-- void marshal(org.xml.sax.ContentHandler)
481 * Method removeAllGlyph
484 public void removeAllGlyph()
486 _glyphList.removeAllElements();
487 } //-- void removeAllGlyph()
490 * Method removeAllValue
493 public void removeAllValue()
495 _valueList.removeAllElements();
496 } //-- void removeAllValue()
506 public uk.ac.vamsas.objects.core.Glyph removeGlyph(int index)
508 java.lang.Object obj = _glyphList.elementAt(index);
509 _glyphList.removeElementAt(index);
510 return (uk.ac.vamsas.objects.core.Glyph) obj;
511 } //-- uk.ac.vamsas.objects.core.Glyph removeGlyph(int)
521 public float removeValue(int index)
523 java.lang.Object obj = _valueList.elementAt(index);
524 _valueList.removeElementAt(index);
525 return ((java.lang.Float)obj).floatValue();
526 } //-- float removeValue(int)
529 * Sets the value of field 'after'. The field 'after' has the
530 * following description: true means the annotation element
531 * appears between the
532 * specified position and the next
534 * @param after the value of field 'after'.
536 public void setAfter(boolean after)
539 this._has_after = true;
540 } //-- void setAfter(boolean)
543 * Sets the value of field 'description'. The field
544 * 'description' has the following description: Free text at
547 * @param description the value of field 'description'.
549 public void setDescription(java.lang.String description)
551 this._description = description;
552 } //-- void setDescription(java.lang.String)
562 public void setGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph)
563 throws java.lang.IndexOutOfBoundsException
565 //-- check bounds for index
566 if ((index < 0) || (index > _glyphList.size())) {
567 throw new IndexOutOfBoundsException("setGlyph: Index value '"+index+"' not in range [0.."+_glyphList.size()+ "]");
569 _glyphList.setElementAt(vGlyph, index);
570 } //-- void setGlyph(int, uk.ac.vamsas.objects.core.Glyph)
579 public void setGlyph(uk.ac.vamsas.objects.core.Glyph[] glyphArray)
582 _glyphList.removeAllElements();
583 for (int i = 0; i < glyphArray.length; i++) {
584 _glyphList.addElement(glyphArray[i]);
586 } //-- void setGlyph(uk.ac.vamsas.objects.core.Glyph)
589 * Sets the value of field 'id'. The field 'id' has the
590 * following description: Primary Key for vamsas object
593 * @param id the value of field 'id'.
595 public void setId(java.lang.String id)
598 } //-- void setId(java.lang.String)
601 * Sets the value of field 'position'. The field 'position' has
602 * the following description: position with respect to the
603 * coordinate frame defined by a
604 * rangeType specification
606 * @param position the value of field 'position'.
608 public void setPosition(int position)
610 this._position = position;
611 this._has_position = true;
612 } //-- void setPosition(int)
622 public void setValue(int index, float vValue)
623 throws java.lang.IndexOutOfBoundsException
625 //-- check bounds for index
626 if ((index < 0) || (index > _valueList.size())) {
627 throw new IndexOutOfBoundsException("setValue: Index value '"+index+"' not in range [0.."+_valueList.size()+ "]");
629 _valueList.setElementAt(new java.lang.Float(vValue), index);
630 } //-- void setValue(int, float)
639 public void setValue(float[] valueArray)
642 _valueList.removeAllElements();
643 for (int i = 0; i < valueArray.length; i++) {
644 _valueList.addElement(new java.lang.Float(valueArray[i]));
646 } //-- void setValue(float)
654 * @return AnnotationElement
656 public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader reader)
657 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
659 return (uk.ac.vamsas.objects.core.AnnotationElement) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AnnotationElement.class, reader);
660 } //-- uk.ac.vamsas.objects.core.AnnotationElement unmarshal(java.io.Reader)
666 public void validate()
667 throws org.exolab.castor.xml.ValidationException
669 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
670 validator.validate(this);
671 } //-- void validate()