refactored org to uk
[vamsas.git] / src / uk / ac / vamsas / objects / core / AnnotationElement.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
4  * Schema.
5  * $Id:AnnotationElement.java 264 2006-12-14 17:42:54Z JimP $
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
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;
25
26 /**
27  * Class AnnotationElement.
28  * 
29  * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $
30  */
31 public class AnnotationElement extends uk.ac.vamsas.client.Vobject 
32 implements java.io.Serializable
33 {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * position with respect to the coordinate frame defined by a
42      *  rangeType specification 
43      */
44     private int _position;
45
46     /**
47      * keeps track of state for field: _position
48      */
49     private boolean _has_position;
50
51     /**
52      * true means the annotation element appears between the
53      *  specified position and the next 
54      */
55     private boolean _after = false;
56
57     /**
58      * keeps track of state for field: _after
59      */
60     private boolean _has_after;
61
62     /**
63      * Primary Key for vamsas object referencing 
64      */
65     private java.lang.String _id;
66
67     /**
68      * Free text at this position 
69      */
70     private java.lang.String _description;
71
72     /**
73      * Discrete symbol - possibly graphically represented
74      *  
75      */
76     private java.util.Vector _glyphList;
77
78     /**
79      * Ordered set of float values - an application may treat
80      *  the values together as a vector with common support for a
81      * set of
82      *  annotation elements - but this is, again, not validated so
83      * applications
84      *  should deal gracefully with varying numbers of dimensions
85      *  
86      */
87     private java.util.Vector _valueList;
88
89
90       //----------------/
91      //- Constructors -/
92     //----------------/
93
94     public AnnotationElement() 
95      {
96         super();
97         _glyphList = new Vector();
98         _valueList = new Vector();
99     } //-- uk.ac.vamsas.objects.core.AnnotationElement()
100
101
102       //-----------/
103      //- Methods -/
104     //-----------/
105
106     /**
107      * Method addGlyph
108      * 
109      * 
110      * 
111      * @param vGlyph
112      */
113     public void addGlyph(uk.ac.vamsas.objects.core.Glyph vGlyph)
114         throws java.lang.IndexOutOfBoundsException
115     {
116         _glyphList.addElement(vGlyph);
117     } //-- void addGlyph(uk.ac.vamsas.objects.core.Glyph) 
118
119     /**
120      * Method addGlyph
121      * 
122      * 
123      * 
124      * @param index
125      * @param vGlyph
126      */
127     public void addGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph)
128         throws java.lang.IndexOutOfBoundsException
129     {
130         _glyphList.insertElementAt(vGlyph, index);
131     } //-- void addGlyph(int, uk.ac.vamsas.objects.core.Glyph) 
132
133     /**
134      * Method addValue
135      * 
136      * 
137      * 
138      * @param vValue
139      */
140     public void addValue(float vValue)
141         throws java.lang.IndexOutOfBoundsException
142     {
143         _valueList.addElement(new java.lang.Float(vValue));
144     } //-- void addValue(float) 
145
146     /**
147      * Method addValue
148      * 
149      * 
150      * 
151      * @param index
152      * @param vValue
153      */
154     public void addValue(int index, float vValue)
155         throws java.lang.IndexOutOfBoundsException
156     {
157         _valueList.insertElementAt(new java.lang.Float(vValue), index);
158     } //-- void addValue(int, float) 
159
160     /**
161      * Method deleteAfter
162      * 
163      */
164     public void deleteAfter()
165     {
166         this._has_after= false;
167     } //-- void deleteAfter() 
168
169     /**
170      * Method deletePosition
171      * 
172      */
173     public void deletePosition()
174     {
175         this._has_position= false;
176     } //-- void deletePosition() 
177
178     /**
179      * Method enumerateGlyph
180      * 
181      * 
182      * 
183      * @return Enumeration
184      */
185     public java.util.Enumeration enumerateGlyph()
186     {
187         return _glyphList.elements();
188     } //-- java.util.Enumeration enumerateGlyph() 
189
190     /**
191      * Method enumerateValue
192      * 
193      * 
194      * 
195      * @return Enumeration
196      */
197     public java.util.Enumeration enumerateValue()
198     {
199         return _valueList.elements();
200     } //-- java.util.Enumeration enumerateValue() 
201
202     /**
203      * Note: hashCode() has not been overriden
204      * 
205      * @param obj
206      * @return boolean
207      */
208     public boolean equals(java.lang.Object obj)
209     {
210         if ( this == obj )
211             return true;
212         
213         if (super.equals(obj)==false)
214             return false;
215         
216         if (obj instanceof AnnotationElement) {
217         
218             AnnotationElement temp = (AnnotationElement)obj;
219             if (this._position != temp._position)
220                 return false;
221             if (this._has_position != temp._has_position)
222                 return false;
223             if (this._after != temp._after)
224                 return false;
225             if (this._has_after != temp._has_after)
226                 return false;
227             if (this._id != null) {
228                 if (temp._id == null) return false;
229                 else if (!(this._id.equals(temp._id))) 
230                     return false;
231             }
232             else if (temp._id != null)
233                 return false;
234             if (this._description != null) {
235                 if (temp._description == null) return false;
236                 else if (!(this._description.equals(temp._description))) 
237                     return false;
238             }
239             else if (temp._description != null)
240                 return false;
241             if (this._glyphList != null) {
242                 if (temp._glyphList == null) return false;
243                 else if (!(this._glyphList.equals(temp._glyphList))) 
244                     return false;
245             }
246             else if (temp._glyphList != null)
247                 return false;
248             if (this._valueList != null) {
249                 if (temp._valueList == null) return false;
250                 else if (!(this._valueList.equals(temp._valueList))) 
251                     return false;
252             }
253             else if (temp._valueList != null)
254                 return false;
255             return true;
256         }
257         return false;
258     } //-- boolean equals(java.lang.Object) 
259
260     /**
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 
265      * 
266      * @return boolean
267      * @return the value of field 'after'.
268      */
269     public boolean getAfter()
270     {
271         return this._after;
272     } //-- boolean getAfter() 
273
274     /**
275      * Returns the value of field 'description'. The field
276      * 'description' has the following description: Free text at
277      * this position 
278      * 
279      * @return String
280      * @return the value of field 'description'.
281      */
282     public java.lang.String getDescription()
283     {
284         return this._description;
285     } //-- java.lang.String getDescription() 
286
287     /**
288      * Method getGlyph
289      * 
290      * 
291      * 
292      * @param index
293      * @return Glyph
294      */
295     public uk.ac.vamsas.objects.core.Glyph getGlyph(int index)
296         throws java.lang.IndexOutOfBoundsException
297     {
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()+ "]");
301         }
302         
303         return (uk.ac.vamsas.objects.core.Glyph) _glyphList.elementAt(index);
304     } //-- uk.ac.vamsas.objects.core.Glyph getGlyph(int) 
305
306     /**
307      * Method getGlyph
308      * 
309      * 
310      * 
311      * @return Glyph
312      */
313     public uk.ac.vamsas.objects.core.Glyph[] getGlyph()
314     {
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);
319         }
320         return mArray;
321     } //-- uk.ac.vamsas.objects.core.Glyph[] getGlyph() 
322
323     /**
324      * Method getGlyphCount
325      * 
326      * 
327      * 
328      * @return int
329      */
330     public int getGlyphCount()
331     {
332         return _glyphList.size();
333     } //-- int getGlyphCount() 
334
335     /**
336      * Returns the value of field 'id'. The field 'id' has the
337      * following description: Primary Key for vamsas object
338      * referencing 
339      * 
340      * @return String
341      * @return the value of field 'id'.
342      */
343     public java.lang.String getId()
344     {
345         return this._id;
346     } //-- java.lang.String getId() 
347
348     /**
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 
353      * 
354      * @return int
355      * @return the value of field 'position'.
356      */
357     public int getPosition()
358     {
359         return this._position;
360     } //-- int getPosition() 
361
362     /**
363      * Method getValue
364      * 
365      * 
366      * 
367      * @param index
368      * @return float
369      */
370     public float getValue(int index)
371         throws java.lang.IndexOutOfBoundsException
372     {
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()+ "]");
376         }
377         
378         return ((java.lang.Float)_valueList.elementAt(index)).floatValue();
379     } //-- float getValue(int) 
380
381     /**
382      * Method getValue
383      * 
384      * 
385      * 
386      * @return float
387      */
388     public float[] getValue()
389     {
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();
394         }
395         return mArray;
396     } //-- float[] getValue() 
397
398     /**
399      * Method getValueCount
400      * 
401      * 
402      * 
403      * @return int
404      */
405     public int getValueCount()
406     {
407         return _valueList.size();
408     } //-- int getValueCount() 
409
410     /**
411      * Method hasAfter
412      * 
413      * 
414      * 
415      * @return boolean
416      */
417     public boolean hasAfter()
418     {
419         return this._has_after;
420     } //-- boolean hasAfter() 
421
422     /**
423      * Method hasPosition
424      * 
425      * 
426      * 
427      * @return boolean
428      */
429     public boolean hasPosition()
430     {
431         return this._has_position;
432     } //-- boolean hasPosition() 
433
434     /**
435      * Method isValid
436      * 
437      * 
438      * 
439      * @return boolean
440      */
441     public boolean isValid()
442     {
443         try {
444             validate();
445         }
446         catch (org.exolab.castor.xml.ValidationException vex) {
447             return false;
448         }
449         return true;
450     } //-- boolean isValid() 
451
452     /**
453      * Method marshal
454      * 
455      * 
456      * 
457      * @param out
458      */
459     public void marshal(java.io.Writer out)
460         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
461     {
462         
463         Marshaller.marshal(this, out);
464     } //-- void marshal(java.io.Writer) 
465
466     /**
467      * Method marshal
468      * 
469      * 
470      * 
471      * @param handler
472      */
473     public void marshal(org.xml.sax.ContentHandler handler)
474         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
475     {
476         
477         Marshaller.marshal(this, handler);
478     } //-- void marshal(org.xml.sax.ContentHandler) 
479
480     /**
481      * Method removeAllGlyph
482      * 
483      */
484     public void removeAllGlyph()
485     {
486         _glyphList.removeAllElements();
487     } //-- void removeAllGlyph() 
488
489     /**
490      * Method removeAllValue
491      * 
492      */
493     public void removeAllValue()
494     {
495         _valueList.removeAllElements();
496     } //-- void removeAllValue() 
497
498     /**
499      * Method removeGlyph
500      * 
501      * 
502      * 
503      * @param index
504      * @return Glyph
505      */
506     public uk.ac.vamsas.objects.core.Glyph removeGlyph(int index)
507     {
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) 
512
513     /**
514      * Method removeValue
515      * 
516      * 
517      * 
518      * @param index
519      * @return float
520      */
521     public float removeValue(int index)
522     {
523         java.lang.Object obj = _valueList.elementAt(index);
524         _valueList.removeElementAt(index);
525         return ((java.lang.Float)obj).floatValue();
526     } //-- float removeValue(int) 
527
528     /**
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 
533      * 
534      * @param after the value of field 'after'.
535      */
536     public void setAfter(boolean after)
537     {
538         this._after = after;
539         this._has_after = true;
540     } //-- void setAfter(boolean) 
541
542     /**
543      * Sets the value of field 'description'. The field
544      * 'description' has the following description: Free text at
545      * this position 
546      * 
547      * @param description the value of field 'description'.
548      */
549     public void setDescription(java.lang.String description)
550     {
551         this._description = description;
552     } //-- void setDescription(java.lang.String) 
553
554     /**
555      * Method setGlyph
556      * 
557      * 
558      * 
559      * @param index
560      * @param vGlyph
561      */
562     public void setGlyph(int index, uk.ac.vamsas.objects.core.Glyph vGlyph)
563         throws java.lang.IndexOutOfBoundsException
564     {
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()+ "]");
568         }
569         _glyphList.setElementAt(vGlyph, index);
570     } //-- void setGlyph(int, uk.ac.vamsas.objects.core.Glyph) 
571
572     /**
573      * Method setGlyph
574      * 
575      * 
576      * 
577      * @param glyphArray
578      */
579     public void setGlyph(uk.ac.vamsas.objects.core.Glyph[] glyphArray)
580     {
581         //-- copy array
582         _glyphList.removeAllElements();
583         for (int i = 0; i < glyphArray.length; i++) {
584             _glyphList.addElement(glyphArray[i]);
585         }
586     } //-- void setGlyph(uk.ac.vamsas.objects.core.Glyph) 
587
588     /**
589      * Sets the value of field 'id'. The field 'id' has the
590      * following description: Primary Key for vamsas object
591      * referencing 
592      * 
593      * @param id the value of field 'id'.
594      */
595     public void setId(java.lang.String id)
596     {
597         this._id = id;
598     } //-- void setId(java.lang.String) 
599
600     /**
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 
605      * 
606      * @param position the value of field 'position'.
607      */
608     public void setPosition(int position)
609     {
610         this._position = position;
611         this._has_position = true;
612     } //-- void setPosition(int) 
613
614     /**
615      * Method setValue
616      * 
617      * 
618      * 
619      * @param index
620      * @param vValue
621      */
622     public void setValue(int index, float vValue)
623         throws java.lang.IndexOutOfBoundsException
624     {
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()+ "]");
628         }
629         _valueList.setElementAt(new java.lang.Float(vValue), index);
630     } //-- void setValue(int, float) 
631
632     /**
633      * Method setValue
634      * 
635      * 
636      * 
637      * @param valueArray
638      */
639     public void setValue(float[] valueArray)
640     {
641         //-- copy array
642         _valueList.removeAllElements();
643         for (int i = 0; i < valueArray.length; i++) {
644             _valueList.addElement(new java.lang.Float(valueArray[i]));
645         }
646     } //-- void setValue(float) 
647
648     /**
649      * Method unmarshal
650      * 
651      * 
652      * 
653      * @param reader
654      * @return AnnotationElement
655      */
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
658     {
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) 
661
662     /**
663      * Method validate
664      * 
665      */
666     public void validate()
667         throws org.exolab.castor.xml.ValidationException
668     {
669         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
670         validator.validate(this);
671     } //-- void validate() 
672
673 }