rebult for castor-1.1(vamsas version)
[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 1.1</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
16
17 /**
18  * Class AnnotationElement.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class AnnotationElement extends uk.ac.vamsas.client.Vobject 
23 implements java.io.Serializable
24 {
25
26
27       //--------------------------/
28      //- Class/Member Variables -/
29     //--------------------------/
30
31     /**
32      * position with respect to the coordinate frame defined by a
33      *  rangeType specification 
34      */
35     private long _position;
36
37     /**
38      * keeps track of state for field: _position
39      */
40     private boolean _has_position;
41
42     /**
43      * true means the annotation element appears between the
44      *  specified position and the next 
45      */
46     private boolean _after = false;
47
48     /**
49      * keeps track of state for field: _after
50      */
51     private boolean _has_after;
52
53     /**
54      * Primary Key for vamsas object referencing 
55      */
56     private java.lang.String _id;
57
58     /**
59      * Free text at this position 
60      */
61     private java.lang.String _description;
62
63     /**
64      * Discrete symbol - possibly graphically represented
65      *  
66      */
67     private java.util.Vector _glyphList;
68
69     /**
70      * Ordered set of float values - an application may treat
71      *  the values together as a vector with common support for a
72      * set of
73      *  annotation elements - but this is, again, not validated so
74      * applications
75      *  should deal gracefully with varying numbers of dimensions
76      *  
77      */
78     private java.util.Vector _valueList;
79
80
81       //----------------/
82      //- Constructors -/
83     //----------------/
84
85     public AnnotationElement() {
86         super();
87         this._glyphList = new java.util.Vector();
88         this._valueList = new java.util.Vector();
89     }
90
91
92       //-----------/
93      //- Methods -/
94     //-----------/
95
96     /**
97      * 
98      * 
99      * @param vGlyph
100      * @throws java.lang.IndexOutOfBoundsException if the index
101      * given is outside the bounds of the collection
102      */
103     public void addGlyph(
104             final uk.ac.vamsas.objects.core.Glyph vGlyph)
105     throws java.lang.IndexOutOfBoundsException {
106         this._glyphList.addElement(vGlyph);
107     }
108
109     /**
110      * 
111      * 
112      * @param index
113      * @param vGlyph
114      * @throws java.lang.IndexOutOfBoundsException if the index
115      * given is outside the bounds of the collection
116      */
117     public void addGlyph(
118             final int index,
119             final uk.ac.vamsas.objects.core.Glyph vGlyph)
120     throws java.lang.IndexOutOfBoundsException {
121         this._glyphList.add(index, vGlyph);
122     }
123
124     /**
125      * 
126      * 
127      * @param vValue
128      * @throws java.lang.IndexOutOfBoundsException if the index
129      * given is outside the bounds of the collection
130      */
131     public void addValue(
132             final float vValue)
133     throws java.lang.IndexOutOfBoundsException {
134         this._valueList.addElement(new java.lang.Float(vValue));
135     }
136
137     /**
138      * 
139      * 
140      * @param index
141      * @param vValue
142      * @throws java.lang.IndexOutOfBoundsException if the index
143      * given is outside the bounds of the collection
144      */
145     public void addValue(
146             final int index,
147             final float vValue)
148     throws java.lang.IndexOutOfBoundsException {
149         this._valueList.add(index, new java.lang.Float(vValue));
150     }
151
152     /**
153      */
154     public void deleteAfter(
155     ) {
156         this._has_after= false;
157     }
158
159     /**
160      */
161     public void deletePosition(
162     ) {
163         this._has_position= false;
164     }
165
166     /**
167      * Method enumerateGlyph.
168      * 
169      * @return an Enumeration over all
170      * uk.ac.vamsas.objects.core.Glyph elements
171      */
172     public java.util.Enumeration enumerateGlyph(
173     ) {
174         return this._glyphList.elements();
175     }
176
177     /**
178      * Method enumerateValue.
179      * 
180      * @return an Enumeration over all float elements
181      */
182     public java.util.Enumeration enumerateValue(
183     ) {
184         return this._valueList.elements();
185     }
186
187     /**
188      * Overrides the java.lang.Object.equals method.
189      * 
190      * @param obj
191      * @return true if the objects are equal.
192      */
193     public boolean equals(
194             final java.lang.Object obj) {
195         if ( this == obj )
196             return true;
197         
198         if (super.equals(obj)==false)
199             return false;
200         
201         if (obj instanceof AnnotationElement) {
202         
203             AnnotationElement temp = (AnnotationElement)obj;
204             if (this._position != temp._position)
205                 return false;
206             if (this._has_position != temp._has_position)
207                 return false;
208             if (this._after != temp._after)
209                 return false;
210             if (this._has_after != temp._has_after)
211                 return false;
212             if (this._id != null) {
213                 if (temp._id == null) return false;
214                 else if (!(this._id.equals(temp._id))) 
215                     return false;
216             }
217             else if (temp._id != null)
218                 return false;
219             if (this._description != null) {
220                 if (temp._description == null) return false;
221                 else if (!(this._description.equals(temp._description))) 
222                     return false;
223             }
224             else if (temp._description != null)
225                 return false;
226             if (this._glyphList != null) {
227                 if (temp._glyphList == null) return false;
228                 else if (!(this._glyphList.equals(temp._glyphList))) 
229                     return false;
230             }
231             else if (temp._glyphList != null)
232                 return false;
233             if (this._valueList != null) {
234                 if (temp._valueList == null) return false;
235                 else if (!(this._valueList.equals(temp._valueList))) 
236                     return false;
237             }
238             else if (temp._valueList != null)
239                 return false;
240             return true;
241         }
242         return false;
243     }
244
245     /**
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 
250      * 
251      * @return the value of field 'After'.
252      */
253     public boolean getAfter(
254     ) {
255         return this._after;
256     }
257
258     /**
259      * Returns the value of field 'description'. The field
260      * 'description' has the following description: Free text at
261      * this position 
262      * 
263      * @return the value of field 'Description'.
264      */
265     public java.lang.String getDescription(
266     ) {
267         return this._description;
268     }
269
270     /**
271      * Method getGlyph.
272      * 
273      * @param index
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
277      * the given index
278      */
279     public uk.ac.vamsas.objects.core.Glyph getGlyph(
280             final int index)
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) + "]");
285         }
286         
287         return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index);
288     }
289
290     /**
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.
296      * 
297      * @return this collection as an Array
298      */
299     public uk.ac.vamsas.objects.core.Glyph[] getGlyph(
300     ) {
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);
303     }
304
305     /**
306      * Method getGlyphAsReference.Returns a reference to
307      * '_glyphList'. No type checking is performed on any
308      * modifications to the Vector.
309      * 
310      * @return a reference to the Vector backing this class
311      */
312     public java.util.Vector getGlyphAsReference(
313     ) {
314         return this._glyphList;
315     }
316
317     /**
318      * Method getGlyphCount.
319      * 
320      * @return the size of this collection
321      */
322     public int getGlyphCount(
323     ) {
324         return this._glyphList.size();
325     }
326
327     /**
328      * Returns the value of field 'id'. The field 'id' has the
329      * following description: Primary Key for vamsas object
330      * referencing 
331      * 
332      * @return the value of field 'Id'.
333      */
334     public java.lang.String getId(
335     ) {
336         return this._id;
337     }
338
339     /**
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 
344      * 
345      * @return the value of field 'Position'.
346      */
347     public long getPosition(
348     ) {
349         return this._position;
350     }
351
352     /**
353      * Method getValue.
354      * 
355      * @param index
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
359      */
360     public float getValue(
361             final int index)
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) + "]");
366         }
367         
368         return ((java.lang.Float) _valueList.get(index)).floatValue();
369     }
370
371     /**
372      * Method getValue.Returns the contents of the collection in an
373      * Array.  
374      * 
375      * @return this collection as an Array
376      */
377     public float[] getValue(
378     ) {
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();
384         }
385         return array;
386     }
387
388     /**
389      * Method getValueAsReference.Returns a reference to
390      * '_valueList'. No type checking is performed on any
391      * modifications to the Vector.
392      * 
393      * @return a reference to the Vector backing this class
394      */
395     public java.util.Vector getValueAsReference(
396     ) {
397         return this._valueList;
398     }
399
400     /**
401      * Method getValueCount.
402      * 
403      * @return the size of this collection
404      */
405     public int getValueCount(
406     ) {
407         return this._valueList.size();
408     }
409
410     /**
411      * Method hasAfter.
412      * 
413      * @return true if at least one After has been added
414      */
415     public boolean hasAfter(
416     ) {
417         return this._has_after;
418     }
419
420     /**
421      * Method hasPosition.
422      * 
423      * @return true if at least one Position has been added
424      */
425     public boolean hasPosition(
426     ) {
427         return this._has_position;
428     }
429
430     /**
431      * Overrides the java.lang.Object.hashCode method.
432      * <p>
433      * The following steps came from <b>Effective Java Programming
434      * Language Guide</b> by Joshua Bloch, Chapter 3
435      * 
436      * @return a hash code value for the object.
437      */
438     public int hashCode(
439     ) {
440         int result = super.hashCode();
441         
442         long tmp;
443         result = 37 * result + (int)(_position^(_position>>>32));
444         result = 37 * result + (_after?0:1);
445         if (_id != null) {
446            result = 37 * result + _id.hashCode();
447         }
448         if (_description != null) {
449            result = 37 * result + _description.hashCode();
450         }
451         if (_glyphList != null) {
452            result = 37 * result + _glyphList.hashCode();
453         }
454         if (_valueList != null) {
455            result = 37 * result + _valueList.hashCode();
456         }
457         
458         return result;
459     }
460
461     /**
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 
466      * 
467      * @return the value of field 'After'.
468      */
469     public boolean isAfter(
470     ) {
471         return this._after;
472     }
473
474     /**
475      * Method isValid.
476      * 
477      * @return true if this object is valid according to the schema
478      */
479     public boolean isValid(
480     ) {
481         try {
482             validate();
483         } catch (org.exolab.castor.xml.ValidationException vex) {
484             return false;
485         }
486         return true;
487     }
488
489     /**
490      * 
491      * 
492      * @param out
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
497      */
498     public void marshal(
499             final java.io.Writer out)
500     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
501         Marshaller.marshal(this, out);
502     }
503
504     /**
505      * 
506      * 
507      * @param handler
508      * @throws java.io.IOException if an IOException occurs during
509      * marshaling
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
514      */
515     public void marshal(
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);
519     }
520
521     /**
522      */
523     public void removeAllGlyph(
524     ) {
525         this._glyphList.clear();
526     }
527
528     /**
529      */
530     public void removeAllValue(
531     ) {
532         this._valueList.clear();
533     }
534
535     /**
536      * Method removeGlyph.
537      * 
538      * @param vGlyph
539      * @return true if the object was removed from the collection.
540      */
541     public boolean removeGlyph(
542             final uk.ac.vamsas.objects.core.Glyph vGlyph) {
543         boolean removed = _glyphList.remove(vGlyph);
544         return removed;
545     }
546
547     /**
548      * Method removeGlyphAt.
549      * 
550      * @param index
551      * @return the element removed from the collection
552      */
553     public uk.ac.vamsas.objects.core.Glyph removeGlyphAt(
554             final int index) {
555         java.lang.Object obj = this._glyphList.remove(index);
556         return (uk.ac.vamsas.objects.core.Glyph) obj;
557     }
558
559     /**
560      * Method removeValue.
561      * 
562      * @param vValue
563      * @return true if the object was removed from the collection.
564      */
565     public boolean removeValue(
566             final float vValue) {
567         boolean removed = _valueList.remove(new java.lang.Float(vValue));
568         return removed;
569     }
570
571     /**
572      * Method removeValueAt.
573      * 
574      * @param index
575      * @return the element removed from the collection
576      */
577     public float removeValueAt(
578             final int index) {
579         java.lang.Object obj = this._valueList.remove(index);
580         return ((java.lang.Float) obj).floatValue();
581     }
582
583     /**
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 
588      * 
589      * @param after the value of field 'after'.
590      */
591     public void setAfter(
592             final boolean after) {
593         this._after = after;
594         this._has_after = true;
595     }
596
597     /**
598      * Sets the value of field 'description'. The field
599      * 'description' has the following description: Free text at
600      * this position 
601      * 
602      * @param description the value of field 'description'.
603      */
604     public void setDescription(
605             final java.lang.String description) {
606         this._description = description;
607     }
608
609     /**
610      * 
611      * 
612      * @param index
613      * @param vGlyph
614      * @throws java.lang.IndexOutOfBoundsException if the index
615      * given is outside the bounds of the collection
616      */
617     public void setGlyph(
618             final int index,
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) + "]");
624         }
625         
626         this._glyphList.set(index, vGlyph);
627     }
628
629     /**
630      * 
631      * 
632      * @param vGlyphArray
633      */
634     public void setGlyph(
635             final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) {
636         //-- copy array
637         _glyphList.clear();
638         
639         for (int i = 0; i < vGlyphArray.length; i++) {
640                 this._glyphList.add(vGlyphArray[i]);
641         }
642     }
643
644     /**
645      * Sets the value of '_glyphList' by copying the given Vector.
646      * All elements will be checked for type safety.
647      * 
648      * @param vGlyphList the Vector to copy.
649      */
650     public void setGlyph(
651             final java.util.Vector vGlyphList) {
652         // copy vector
653         this._glyphList.clear();
654         
655         this._glyphList.addAll(vGlyphList);
656     }
657
658     /**
659      * Sets the value of '_glyphList' by setting it to the given
660      * Vector. No type checking is performed.
661      * @deprecated
662      * 
663      * @param glyphVector the Vector to set.
664      */
665     public void setGlyphAsReference(
666             final java.util.Vector glyphVector) {
667         this._glyphList = glyphVector;
668     }
669
670     /**
671      * Sets the value of field 'id'. The field 'id' has the
672      * following description: Primary Key for vamsas object
673      * referencing 
674      * 
675      * @param id the value of field 'id'.
676      */
677     public void setId(
678             final java.lang.String id) {
679         this._id = id;
680     }
681
682     /**
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 
687      * 
688      * @param position the value of field 'position'.
689      */
690     public void setPosition(
691             final long position) {
692         this._position = position;
693         this._has_position = true;
694     }
695
696     /**
697      * 
698      * 
699      * @param index
700      * @param vValue
701      * @throws java.lang.IndexOutOfBoundsException if the index
702      * given is outside the bounds of the collection
703      */
704     public void setValue(
705             final int index,
706             final float vValue)
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) + "]");
711         }
712         
713         this._valueList.set(index, new java.lang.Float(vValue));
714     }
715
716     /**
717      * 
718      * 
719      * @param vValueArray
720      */
721     public void setValue(
722             final float[] vValueArray) {
723         //-- copy array
724         _valueList.clear();
725         
726         for (int i = 0; i < vValueArray.length; i++) {
727                 this._valueList.add(new java.lang.Float(vValueArray[i]));
728         }
729     }
730
731     /**
732      * Sets the value of '_valueList' by copying the given Vector.
733      * All elements will be checked for type safety.
734      * 
735      * @param vValueList the Vector to copy.
736      */
737     public void setValue(
738             final java.util.Vector vValueList) {
739         // copy vector
740         this._valueList.clear();
741         
742         this._valueList.addAll(vValueList);
743     }
744
745     /**
746      * Sets the value of '_valueList' by setting it to the given
747      * Vector. No type checking is performed.
748      * @deprecated
749      * 
750      * @param valueVector the Vector to set.
751      */
752     public void setValueAsReference(
753             final java.util.Vector valueVector) {
754         this._valueList = valueVector;
755     }
756
757     /**
758      * Method unmarshal.
759      * 
760      * @param reader
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
767      */
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);
772     }
773
774     /**
775      * 
776      * 
777      * @throws org.exolab.castor.xml.ValidationException if this
778      * object is an invalid instance according to the schema
779      */
780     public void validate(
781     )
782     throws org.exolab.castor.xml.ValidationException {
783         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
784         validator.validate(this);
785     }
786
787 }