applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / AnnotationElement.java
1 /*
2  * This file is part of the Vamsas Client version 0.1. 
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, 
4  *  Andrew Waterhouse and Dominik Lindner.
5  * 
6  * Earlier versions have also been incorporated into Jalview version 2.4 
7  * since 2008, and TOPALi version 2 since 2007.
8  * 
9  * The Vamsas Client is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *  
14  * The Vamsas Client is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Lesser General Public License for more details.
18  * 
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.
21  */
22 package uk.ac.vamsas.objects.core;
23
24 //---------------------------------/
25 //- Imported classes and packages -/
26 //---------------------------------/
27
28 import org.exolab.castor.xml.Marshaller;
29 import org.exolab.castor.xml.Unmarshaller;
30
31 /**
32  * Class AnnotationElement.
33  * 
34  * @version $Revision$ $Date: 2007-06-28 14:51:44 +0100 (Thu, 28 Jun 2007)
35  *          $
36  */
37 public class AnnotationElement extends uk.ac.vamsas.client.Vobject implements
38     java.io.Serializable {
39
40   // --------------------------/
41   // - Class/Member Variables -/
42   // --------------------------/
43
44   /**
45    * position with respect to the coordinate frame defined by a rangeType
46    * specification
47    */
48   private long _position;
49
50   /**
51    * keeps track of state for field: _position
52    */
53   private boolean _has_position;
54
55   /**
56    * true means the annotation element appears between the specified position
57    * and the next
58    */
59   private boolean _after = false;
60
61   /**
62    * keeps track of state for field: _after
63    */
64   private boolean _has_after;
65
66   /**
67    * Primary Key for vamsas object referencing
68    */
69   private java.lang.String _id;
70
71   /**
72    * Free text at this position
73    */
74   private java.lang.String _description;
75
76   /**
77    * Discrete symbol - possibly graphically represented
78    * 
79    */
80   private java.util.Vector _glyphList;
81
82   /**
83    * Ordered set of float values - an application may treat the values together
84    * as a vector with common support for a set of annotation elements - but this
85    * is, again, not validated so applications should deal gracefully with
86    * varying numbers of dimensions
87    * 
88    */
89   private java.util.Vector _valueList;
90
91   // ----------------/
92   // - Constructors -/
93   // ----------------/
94
95   public AnnotationElement() {
96     super();
97     this._glyphList = new java.util.Vector();
98     this._valueList = new java.util.Vector();
99   }
100
101   // -----------/
102   // - Methods -/
103   // -----------/
104
105   /**
106    * 
107    * 
108    * @param vGlyph
109    * @throws java.lang.IndexOutOfBoundsException
110    *           if the index given is outside the bounds of the collection
111    */
112   public void addGlyph(final uk.ac.vamsas.objects.core.Glyph vGlyph)
113       throws java.lang.IndexOutOfBoundsException {
114     this._glyphList.addElement(vGlyph);
115   }
116
117   /**
118    * 
119    * 
120    * @param index
121    * @param vGlyph
122    * @throws java.lang.IndexOutOfBoundsException
123    *           if the index given is outside the bounds of the collection
124    */
125   public void addGlyph(final int index,
126       final uk.ac.vamsas.objects.core.Glyph vGlyph)
127       throws java.lang.IndexOutOfBoundsException {
128     this._glyphList.add(index, vGlyph);
129   }
130
131   /**
132    * 
133    * 
134    * @param vValue
135    * @throws java.lang.IndexOutOfBoundsException
136    *           if the index given is outside the bounds of the collection
137    */
138   public void addValue(final float vValue)
139       throws java.lang.IndexOutOfBoundsException {
140     this._valueList.addElement(new java.lang.Float(vValue));
141   }
142
143   /**
144    * 
145    * 
146    * @param index
147    * @param vValue
148    * @throws java.lang.IndexOutOfBoundsException
149    *           if the index given is outside the bounds of the collection
150    */
151   public void addValue(final int index, final float vValue)
152       throws java.lang.IndexOutOfBoundsException {
153     this._valueList.add(index, new java.lang.Float(vValue));
154   }
155
156   /**
157      */
158   public void deleteAfter() {
159     this._has_after = false;
160   }
161
162   /**
163      */
164   public void deletePosition() {
165     this._has_position = false;
166   }
167
168   /**
169    * Method enumerateGlyph.
170    * 
171    * @return an Enumeration over all uk.ac.vamsas.objects.core.Glyph elements
172    */
173   public java.util.Enumeration enumerateGlyph() {
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     return this._valueList.elements();
184   }
185
186   /**
187    * Overrides the java.lang.Object.equals method.
188    * 
189    * @param obj
190    * @return true if the objects are equal.
191    */
192   public boolean equals(final java.lang.Object obj) {
193     if (this == obj)
194       return true;
195
196     if (super.equals(obj) == false)
197       return false;
198
199     if (obj instanceof AnnotationElement) {
200
201       AnnotationElement temp = (AnnotationElement) obj;
202       boolean thcycle;
203       boolean tmcycle;
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)
214           return false;
215         if (this._id != temp._id) {
216           thcycle = org.castor.util.CycleBreaker.startingToCycle(this._id);
217           tmcycle = org.castor.util.CycleBreaker.startingToCycle(temp._id);
218           if (thcycle != tmcycle) {
219             if (!thcycle) {
220               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
221             }
222             ;
223             if (!tmcycle) {
224               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
225             }
226             ;
227             return false;
228           }
229           if (!thcycle) {
230             if (!this._id.equals(temp._id)) {
231               org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
232               org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
233               return false;
234             }
235             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
236             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
237           }
238         }
239       } else if (temp._id != null)
240         return false;
241       if (this._description != null) {
242         if (temp._description == null)
243           return false;
244         if (this._description != temp._description) {
245           thcycle = org.castor.util.CycleBreaker
246               .startingToCycle(this._description);
247           tmcycle = org.castor.util.CycleBreaker
248               .startingToCycle(temp._description);
249           if (thcycle != tmcycle) {
250             if (!thcycle) {
251               org.castor.util.CycleBreaker
252                   .releaseCycleHandle(this._description);
253             }
254             ;
255             if (!tmcycle) {
256               org.castor.util.CycleBreaker
257                   .releaseCycleHandle(temp._description);
258             }
259             ;
260             return false;
261           }
262           if (!thcycle) {
263             if (!this._description.equals(temp._description)) {
264               org.castor.util.CycleBreaker
265                   .releaseCycleHandle(this._description);
266               org.castor.util.CycleBreaker
267                   .releaseCycleHandle(temp._description);
268               return false;
269             }
270             org.castor.util.CycleBreaker.releaseCycleHandle(this._description);
271             org.castor.util.CycleBreaker.releaseCycleHandle(temp._description);
272           }
273         }
274       } else if (temp._description != null)
275         return false;
276       if (this._glyphList != null) {
277         if (temp._glyphList == null)
278           return false;
279         if (this._glyphList != temp._glyphList) {
280           thcycle = org.castor.util.CycleBreaker
281               .startingToCycle(this._glyphList);
282           tmcycle = org.castor.util.CycleBreaker
283               .startingToCycle(temp._glyphList);
284           if (thcycle != tmcycle) {
285             if (!thcycle) {
286               org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
287             }
288             ;
289             if (!tmcycle) {
290               org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
291             }
292             ;
293             return false;
294           }
295           if (!thcycle) {
296             if (!this._glyphList.equals(temp._glyphList)) {
297               org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
298               org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
299               return false;
300             }
301             org.castor.util.CycleBreaker.releaseCycleHandle(this._glyphList);
302             org.castor.util.CycleBreaker.releaseCycleHandle(temp._glyphList);
303           }
304         }
305       } else if (temp._glyphList != null)
306         return false;
307       if (this._valueList != null) {
308         if (temp._valueList == null)
309           return false;
310         if (this._valueList != temp._valueList) {
311           thcycle = org.castor.util.CycleBreaker
312               .startingToCycle(this._valueList);
313           tmcycle = org.castor.util.CycleBreaker
314               .startingToCycle(temp._valueList);
315           if (thcycle != tmcycle) {
316             if (!thcycle) {
317               org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
318             }
319             ;
320             if (!tmcycle) {
321               org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
322             }
323             ;
324             return false;
325           }
326           if (!thcycle) {
327             if (!this._valueList.equals(temp._valueList)) {
328               org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
329               org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
330               return false;
331             }
332             org.castor.util.CycleBreaker.releaseCycleHandle(this._valueList);
333             org.castor.util.CycleBreaker.releaseCycleHandle(temp._valueList);
334           }
335         }
336       } else if (temp._valueList != null)
337         return false;
338       return true;
339     }
340     return false;
341   }
342
343   /**
344    * Returns the value of field 'after'. The field 'after' has the following
345    * description: true means the annotation element appears between the
346    * specified position and the next
347    * 
348    * @return the value of field 'After'.
349    */
350   public boolean getAfter() {
351     return this._after;
352   }
353
354   /**
355    * Returns the value of field 'description'. The field 'description' has the
356    * following description: Free text at this position
357    * 
358    * @return the value of field 'Description'.
359    */
360   public java.lang.String getDescription() {
361     return this._description;
362   }
363
364   /**
365    * Method getGlyph.
366    * 
367    * @param index
368    * @throws java.lang.IndexOutOfBoundsException
369    *           if the index given is outside the bounds of the collection
370    * @return the value of the uk.ac.vamsas.objects.core.Glyph at the given index
371    */
372   public uk.ac.vamsas.objects.core.Glyph getGlyph(final int index)
373       throws java.lang.IndexOutOfBoundsException {
374     // check bounds for index
375     if (index < 0 || index >= this._glyphList.size()) {
376       throw new IndexOutOfBoundsException("getGlyph: Index value '" + index
377           + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
378     }
379
380     return (uk.ac.vamsas.objects.core.Glyph) _glyphList.get(index);
381   }
382
383   /**
384    * Method getGlyph.Returns the contents of the collection in an Array.
385    * <p>
386    * Note: Just in case the collection contents are changing in another thread,
387    * we pass a 0-length Array of the correct type into the API call. This way we
388    * <i>know</i> that the Array returned is of exactly the correct length.
389    * 
390    * @return this collection as an Array
391    */
392   public uk.ac.vamsas.objects.core.Glyph[] getGlyph() {
393     uk.ac.vamsas.objects.core.Glyph[] array = new uk.ac.vamsas.objects.core.Glyph[0];
394     return (uk.ac.vamsas.objects.core.Glyph[]) this._glyphList.toArray(array);
395   }
396
397   /**
398    * Method getGlyphAsReference.Returns a reference to '_glyphList'. No type
399    * checking is performed on any modifications to the Vector.
400    * 
401    * @return a reference to the Vector backing this class
402    */
403   public java.util.Vector getGlyphAsReference() {
404     return this._glyphList;
405   }
406
407   /**
408    * Method getGlyphCount.
409    * 
410    * @return the size of this collection
411    */
412   public int getGlyphCount() {
413     return this._glyphList.size();
414   }
415
416   /**
417    * Returns the value of field 'id'. The field 'id' has the following
418    * description: Primary Key for vamsas object referencing
419    * 
420    * @return the value of field 'Id'.
421    */
422   public java.lang.String getId() {
423     return this._id;
424   }
425
426   /**
427    * Returns the value of field 'position'. The field 'position' has the
428    * following description: position with respect to the coordinate frame
429    * defined by a rangeType specification
430    * 
431    * @return the value of field 'Position'.
432    */
433   public long getPosition() {
434     return this._position;
435   }
436
437   /**
438    * Method getValue.
439    * 
440    * @param index
441    * @throws java.lang.IndexOutOfBoundsException
442    *           if the index given is outside the bounds of the collection
443    * @return the value of the float at the given index
444    */
445   public float getValue(final int index)
446       throws java.lang.IndexOutOfBoundsException {
447     // check bounds for index
448     if (index < 0 || index >= this._valueList.size()) {
449       throw new IndexOutOfBoundsException("getValue: Index value '" + index
450           + "' not in range [0.." + (this._valueList.size() - 1) + "]");
451     }
452
453     return ((java.lang.Float) _valueList.get(index)).floatValue();
454   }
455
456   /**
457    * Method getValue.Returns the contents of the collection in an Array.
458    * 
459    * @return this collection as an Array
460    */
461   public float[] getValue() {
462     int size = this._valueList.size();
463     float[] array = new float[size];
464     java.util.Iterator iter = _valueList.iterator();
465     for (int index = 0; index < size; index++) {
466       array[index] = ((java.lang.Float) iter.next()).floatValue();
467     }
468     return array;
469   }
470
471   /**
472    * Method getValueAsReference.Returns a reference to '_valueList'. No type
473    * checking is performed on any modifications to the Vector.
474    * 
475    * @return a reference to the Vector backing this class
476    */
477   public java.util.Vector getValueAsReference() {
478     return this._valueList;
479   }
480
481   /**
482    * Method getValueCount.
483    * 
484    * @return the size of this collection
485    */
486   public int getValueCount() {
487     return this._valueList.size();
488   }
489
490   /**
491    * Method hasAfter.
492    * 
493    * @return true if at least one After has been added
494    */
495   public boolean hasAfter() {
496     return this._has_after;
497   }
498
499   /**
500    * Method hasPosition.
501    * 
502    * @return true if at least one Position has been added
503    */
504   public boolean hasPosition() {
505     return this._has_position;
506   }
507
508   /**
509    * Overrides the java.lang.Object.hashCode method.
510    * <p>
511    * The following steps came from <b>Effective Java Programming Language
512    * Guide</b> by Joshua Bloch, Chapter 3
513    * 
514    * @return a hash code value for the object.
515    */
516   public int hashCode() {
517     int result = super.hashCode();
518
519     long tmp;
520     result = 37 * result + (int) (_position ^ (_position >>> 32));
521     result = 37 * result + (_after ? 0 : 1);
522     if (_id != null && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
523       result = 37 * result + _id.hashCode();
524       org.castor.util.CycleBreaker.releaseCycleHandle(_id);
525     }
526     if (_description != null
527         && !org.castor.util.CycleBreaker.startingToCycle(_description)) {
528       result = 37 * result + _description.hashCode();
529       org.castor.util.CycleBreaker.releaseCycleHandle(_description);
530     }
531     if (_glyphList != null
532         && !org.castor.util.CycleBreaker.startingToCycle(_glyphList)) {
533       result = 37 * result + _glyphList.hashCode();
534       org.castor.util.CycleBreaker.releaseCycleHandle(_glyphList);
535     }
536     if (_valueList != null
537         && !org.castor.util.CycleBreaker.startingToCycle(_valueList)) {
538       result = 37 * result + _valueList.hashCode();
539       org.castor.util.CycleBreaker.releaseCycleHandle(_valueList);
540     }
541
542     return result;
543   }
544
545   /**
546    * Returns the value of field 'after'. The field 'after' has the following
547    * description: true means the annotation element appears between the
548    * specified position and the next
549    * 
550    * @return the value of field 'After'.
551    */
552   public boolean isAfter() {
553     return this._after;
554   }
555
556   /**
557    * Method isValid.
558    * 
559    * @return true if this object is valid according to the schema
560    */
561   public boolean isValid() {
562     try {
563       validate();
564     } catch (org.exolab.castor.xml.ValidationException vex) {
565       return false;
566     }
567     return true;
568   }
569
570   /**
571    * 
572    * 
573    * @param out
574    * @throws org.exolab.castor.xml.MarshalException
575    *           if object is null or if any SAXException is thrown during
576    *           marshaling
577    * @throws org.exolab.castor.xml.ValidationException
578    *           if this object is an invalid instance according to the schema
579    */
580   public void marshal(final java.io.Writer out)
581       throws org.exolab.castor.xml.MarshalException,
582       org.exolab.castor.xml.ValidationException {
583     Marshaller.marshal(this, out);
584   }
585
586   /**
587    * 
588    * 
589    * @param handler
590    * @throws java.io.IOException
591    *           if an IOException occurs during marshaling
592    * @throws org.exolab.castor.xml.ValidationException
593    *           if this object is an invalid instance according to the schema
594    * @throws org.exolab.castor.xml.MarshalException
595    *           if object is null or if any SAXException is thrown during
596    *           marshaling
597    */
598   public void marshal(final org.xml.sax.ContentHandler handler)
599       throws java.io.IOException, org.exolab.castor.xml.MarshalException,
600       org.exolab.castor.xml.ValidationException {
601     Marshaller.marshal(this, handler);
602   }
603
604   /**
605      */
606   public void removeAllGlyph() {
607     this._glyphList.clear();
608   }
609
610   /**
611      */
612   public void removeAllValue() {
613     this._valueList.clear();
614   }
615
616   /**
617    * Method removeGlyph.
618    * 
619    * @param vGlyph
620    * @return true if the object was removed from the collection.
621    */
622   public boolean removeGlyph(final uk.ac.vamsas.objects.core.Glyph vGlyph) {
623     boolean removed = _glyphList.remove(vGlyph);
624     return removed;
625   }
626
627   /**
628    * Method removeGlyphAt.
629    * 
630    * @param index
631    * @return the element removed from the collection
632    */
633   public uk.ac.vamsas.objects.core.Glyph removeGlyphAt(final int index) {
634     java.lang.Object obj = this._glyphList.remove(index);
635     return (uk.ac.vamsas.objects.core.Glyph) obj;
636   }
637
638   /**
639    * Method removeValue.
640    * 
641    * @param vValue
642    * @return true if the object was removed from the collection.
643    */
644   public boolean removeValue(final float vValue) {
645     boolean removed = _valueList.remove(new java.lang.Float(vValue));
646     return removed;
647   }
648
649   /**
650    * Method removeValueAt.
651    * 
652    * @param index
653    * @return the element removed from the collection
654    */
655   public float removeValueAt(final int index) {
656     java.lang.Object obj = this._valueList.remove(index);
657     return ((java.lang.Float) obj).floatValue();
658   }
659
660   /**
661    * Sets the value of field 'after'. The field 'after' has the following
662    * description: true means the annotation element appears between the
663    * specified position and the next
664    * 
665    * @param after
666    *          the value of field 'after'.
667    */
668   public void setAfter(final boolean after) {
669     this._after = after;
670     this._has_after = true;
671   }
672
673   /**
674    * Sets the value of field 'description'. The field 'description' has the
675    * following description: Free text at this position
676    * 
677    * @param description
678    *          the value of field 'description'.
679    */
680   public void setDescription(final java.lang.String description) {
681     this._description = description;
682   }
683
684   /**
685    * 
686    * 
687    * @param index
688    * @param vGlyph
689    * @throws java.lang.IndexOutOfBoundsException
690    *           if the index given is outside the bounds of the collection
691    */
692   public void setGlyph(final int index,
693       final uk.ac.vamsas.objects.core.Glyph vGlyph)
694       throws java.lang.IndexOutOfBoundsException {
695     // check bounds for index
696     if (index < 0 || index >= this._glyphList.size()) {
697       throw new IndexOutOfBoundsException("setGlyph: Index value '" + index
698           + "' not in range [0.." + (this._glyphList.size() - 1) + "]");
699     }
700
701     this._glyphList.set(index, vGlyph);
702   }
703
704   /**
705    * 
706    * 
707    * @param vGlyphArray
708    */
709   public void setGlyph(final uk.ac.vamsas.objects.core.Glyph[] vGlyphArray) {
710     // -- copy array
711     _glyphList.clear();
712
713     for (int i = 0; i < vGlyphArray.length; i++) {
714       this._glyphList.add(vGlyphArray[i]);
715     }
716   }
717
718   /**
719    * Sets the value of '_glyphList' by copying the given Vector. All elements
720    * will be checked for type safety.
721    * 
722    * @param vGlyphList
723    *          the Vector to copy.
724    */
725   public void setGlyph(final java.util.Vector vGlyphList) {
726     // copy vector
727     this._glyphList.clear();
728
729     this._glyphList.addAll(vGlyphList);
730   }
731
732   /**
733    * Sets the value of '_glyphList' by setting it to the given Vector. No type
734    * checking is performed.
735    * 
736    * @deprecated
737    * 
738    * @param glyphVector
739    *          the Vector to set.
740    */
741   public void setGlyphAsReference(final java.util.Vector glyphVector) {
742     this._glyphList = glyphVector;
743   }
744
745   /**
746    * Sets the value of field 'id'. The field 'id' has the following description:
747    * Primary Key for vamsas object referencing
748    * 
749    * @param id
750    *          the value of field 'id'.
751    */
752   public void setId(final java.lang.String id) {
753     this._id = id;
754   }
755
756   /**
757    * Sets the value of field 'position'. The field 'position' has the following
758    * description: position with respect to the coordinate frame defined by a
759    * rangeType specification
760    * 
761    * @param position
762    *          the value of field 'position'.
763    */
764   public void setPosition(final long position) {
765     this._position = position;
766     this._has_position = true;
767   }
768
769   /**
770    * 
771    * 
772    * @param index
773    * @param vValue
774    * @throws java.lang.IndexOutOfBoundsException
775    *           if the index given is outside the bounds of the collection
776    */
777   public void setValue(final int index, final float vValue)
778       throws java.lang.IndexOutOfBoundsException {
779     // check bounds for index
780     if (index < 0 || index >= this._valueList.size()) {
781       throw new IndexOutOfBoundsException("setValue: Index value '" + index
782           + "' not in range [0.." + (this._valueList.size() - 1) + "]");
783     }
784
785     this._valueList.set(index, new java.lang.Float(vValue));
786   }
787
788   /**
789    * 
790    * 
791    * @param vValueArray
792    */
793   public void setValue(final float[] vValueArray) {
794     // -- copy array
795     _valueList.clear();
796
797     for (int i = 0; i < vValueArray.length; i++) {
798       this._valueList.add(new java.lang.Float(vValueArray[i]));
799     }
800   }
801
802   /**
803    * Sets the value of '_valueList' by copying the given Vector. All elements
804    * will be checked for type safety.
805    * 
806    * @param vValueList
807    *          the Vector to copy.
808    */
809   public void setValue(final java.util.Vector vValueList) {
810     // copy vector
811     this._valueList.clear();
812
813     this._valueList.addAll(vValueList);
814   }
815
816   /**
817    * Sets the value of '_valueList' by setting it to the given Vector. No type
818    * checking is performed.
819    * 
820    * @deprecated
821    * 
822    * @param valueVector
823    *          the Vector to set.
824    */
825   public void setValueAsReference(final java.util.Vector valueVector) {
826     this._valueList = valueVector;
827   }
828
829   /**
830    * Method unmarshal.
831    * 
832    * @param reader
833    * @throws org.exolab.castor.xml.MarshalException
834    *           if object is null or if any SAXException is thrown during
835    *           marshaling
836    * @throws org.exolab.castor.xml.ValidationException
837    *           if this object is an invalid instance according to the schema
838    * @return the unmarshaled uk.ac.vamsas.objects.core.AnnotationElement
839    */
840   public static uk.ac.vamsas.objects.core.AnnotationElement unmarshal(
841       final java.io.Reader reader)
842       throws org.exolab.castor.xml.MarshalException,
843       org.exolab.castor.xml.ValidationException {
844     return (uk.ac.vamsas.objects.core.AnnotationElement) Unmarshaller
845         .unmarshal(uk.ac.vamsas.objects.core.AnnotationElement.class, reader);
846   }
847
848   /**
849    * 
850    * 
851    * @throws org.exolab.castor.xml.ValidationException
852    *           if this object is an invalid instance according to the schema
853    */
854   public void validate() throws org.exolab.castor.xml.ValidationException {
855     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
856     validator.validate(this);
857   }
858
859 }