schema changes: provenance-entry-date is now an xmlSchema:dateTime bound directly...
[vamsas.git] / src / uk / ac / vamsas / objects / core / AlignmentAnnotation.java
1 /*\r
2  * This class was automatically generated with \r
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 \r
8 package uk.ac.vamsas.objects.core;\r
9 \r
10   //---------------------------------/\r
11  //- Imported classes and packages -/\r
12 //---------------------------------/\r
13 \r
14 import org.exolab.castor.xml.Marshaller;\r
15 import org.exolab.castor.xml.Unmarshaller;\r
16 \r
17 /**\r
18  * This is annotation over the coordinate frame\r
19  *  defined by all the columns in the alignment.\r
20  *  \r
21  * \r
22  * @version $Revision$ $Date$\r
23  */\r
24 public class AlignmentAnnotation extends uk.ac.vamsas.objects.core.RangeAnnotation \r
25 implements java.io.Serializable\r
26 {\r
27 \r
28 \r
29       //--------------------------/\r
30      //- Class/Member Variables -/\r
31     //--------------------------/\r
32 \r
33     /**\r
34      * TODO: decide if this flag is\r
35      *  redundant - when true it would suggest that\r
36      *  the annotationElement values together form a\r
37      *  graph \r
38      */\r
39     private boolean _graph;\r
40 \r
41     /**\r
42      * keeps track of state for field: _graph\r
43      */\r
44     private boolean _has_graph;\r
45 \r
46     /**\r
47      * annotation is associated with a\r
48      *  range on a particular group of alignment sequences\r
49      */\r
50     private java.util.Vector _seqrefs;\r
51 \r
52     /**\r
53      * Field _provenance.\r
54      */\r
55     private uk.ac.vamsas.objects.core.Provenance _provenance;\r
56 \r
57 \r
58       //----------------/\r
59      //- Constructors -/\r
60     //----------------/\r
61 \r
62     public AlignmentAnnotation() {\r
63         super();\r
64         this._seqrefs = new java.util.Vector();\r
65     }\r
66 \r
67 \r
68       //-----------/\r
69      //- Methods -/\r
70     //-----------/\r
71 \r
72     /**\r
73      * \r
74      * \r
75      * @param vSeqrefs\r
76      * @throws java.lang.IndexOutOfBoundsException if the index\r
77      * given is outside the bounds of the collection\r
78      */\r
79     public void addSeqrefs(\r
80             final java.lang.Object vSeqrefs)\r
81     throws java.lang.IndexOutOfBoundsException {\r
82         this._seqrefs.addElement(vSeqrefs);\r
83     }\r
84 \r
85     /**\r
86      * \r
87      * \r
88      * @param index\r
89      * @param vSeqrefs\r
90      * @throws java.lang.IndexOutOfBoundsException if the index\r
91      * given is outside the bounds of the collection\r
92      */\r
93     public void addSeqrefs(\r
94             final int index,\r
95             final java.lang.Object vSeqrefs)\r
96     throws java.lang.IndexOutOfBoundsException {\r
97         this._seqrefs.add(index, vSeqrefs);\r
98     }\r
99 \r
100     /**\r
101      */\r
102     public void deleteGraph(\r
103     ) {\r
104         this._has_graph= false;\r
105     }\r
106 \r
107     /**\r
108      * Method enumerateSeqrefs.\r
109      * \r
110      * @return an Enumeration over all java.lang.Object elements\r
111      */\r
112     public java.util.Enumeration enumerateSeqrefs(\r
113     ) {\r
114         return this._seqrefs.elements();\r
115     }\r
116 \r
117     /**\r
118      * Overrides the java.lang.Object.equals method.\r
119      * \r
120      * @param obj\r
121      * @return true if the objects are equal.\r
122      */\r
123     public boolean equals(\r
124             final java.lang.Object obj) {\r
125         if ( this == obj )\r
126             return true;\r
127         \r
128         if (super.equals(obj)==false)\r
129             return false;\r
130         \r
131         if (obj instanceof AlignmentAnnotation) {\r
132         \r
133             AlignmentAnnotation temp = (AlignmentAnnotation)obj;\r
134             if (this._graph != temp._graph)\r
135                 return false;\r
136             if (this._has_graph != temp._has_graph)\r
137                 return false;\r
138             if (this._seqrefs != null) {\r
139                 if (temp._seqrefs == null) return false;\r
140                 else if (!(this._seqrefs.equals(temp._seqrefs))) \r
141                     return false;\r
142             }\r
143             else if (temp._seqrefs != null)\r
144                 return false;\r
145             if (this._provenance != null) {\r
146                 if (temp._provenance == null) return false;\r
147                 else if (!(this._provenance.equals(temp._provenance))) \r
148                     return false;\r
149             }\r
150             else if (temp._provenance != null)\r
151                 return false;\r
152             return true;\r
153         }\r
154         return false;\r
155     }\r
156 \r
157     /**\r
158      * Returns the value of field 'graph'. The field 'graph' has\r
159      * the following description: TODO: decide if this flag is\r
160      *  redundant - when true it would suggest that\r
161      *  the annotationElement values together form a\r
162      *  graph \r
163      * \r
164      * @return the value of field 'Graph'.\r
165      */\r
166     public boolean getGraph(\r
167     ) {\r
168         return this._graph;\r
169     }\r
170 \r
171     /**\r
172      * Returns the value of field 'provenance'.\r
173      * \r
174      * @return the value of field 'Provenance'.\r
175      */\r
176     public uk.ac.vamsas.objects.core.Provenance getProvenance(\r
177     ) {\r
178         return this._provenance;\r
179     }\r
180 \r
181     /**\r
182      * Method getSeqrefs.\r
183      * \r
184      * @param index\r
185      * @throws java.lang.IndexOutOfBoundsException if the index\r
186      * given is outside the bounds of the collection\r
187      * @return the value of the java.lang.Object at the given index\r
188      */\r
189     public java.lang.Object getSeqrefs(\r
190             final int index)\r
191     throws java.lang.IndexOutOfBoundsException {\r
192         // check bounds for index\r
193         if (index < 0 || index >= this._seqrefs.size()) {\r
194             throw new IndexOutOfBoundsException("getSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");\r
195         }\r
196         \r
197         return _seqrefs.get(index);\r
198     }\r
199 \r
200     /**\r
201      * Method getSeqrefs.Returns the contents of the collection in\r
202      * an Array.  <p>Note:  Just in case the collection contents\r
203      * are changing in another thread, we pass a 0-length Array of\r
204      * the correct type into the API call.  This way we <i>know</i>\r
205      * that the Array returned is of exactly the correct length.\r
206      * \r
207      * @return this collection as an Array\r
208      */\r
209     public java.lang.Object[] getSeqrefs(\r
210     ) {\r
211         java.lang.Object[] array = new java.lang.Object[0];\r
212         return (java.lang.Object[]) this._seqrefs.toArray(array);\r
213     }\r
214 \r
215     /**\r
216      * Method getSeqrefsAsReference.Returns a reference to\r
217      * '_seqrefs'. No type checking is performed on any\r
218      * modifications to the Vector.\r
219      * \r
220      * @return a reference to the Vector backing this class\r
221      */\r
222     public java.util.Vector getSeqrefsAsReference(\r
223     ) {\r
224         return this._seqrefs;\r
225     }\r
226 \r
227     /**\r
228      * Method getSeqrefsCount.\r
229      * \r
230      * @return the size of this collection\r
231      */\r
232     public int getSeqrefsCount(\r
233     ) {\r
234         return this._seqrefs.size();\r
235     }\r
236 \r
237     /**\r
238      * Method hasGraph.\r
239      * \r
240      * @return true if at least one Graph has been added\r
241      */\r
242     public boolean hasGraph(\r
243     ) {\r
244         return this._has_graph;\r
245     }\r
246 \r
247     /**\r
248      * Overrides the java.lang.Object.hashCode method.\r
249      * <p>\r
250      * The following steps came from <b>Effective Java Programming\r
251      * Language Guide</b> by Joshua Bloch, Chapter 3\r
252      * \r
253      * @return a hash code value for the object.\r
254      */\r
255     public int hashCode(\r
256     ) {\r
257         int result = super.hashCode();\r
258         \r
259         long tmp;\r
260         result = 37 * result + (_graph?0:1);\r
261         if (_seqrefs != null) {\r
262            result = 37 * result + _seqrefs.hashCode();\r
263         }\r
264         if (_provenance != null) {\r
265            result = 37 * result + _provenance.hashCode();\r
266         }\r
267         \r
268         return result;\r
269     }\r
270 \r
271     /**\r
272      * Returns the value of field 'graph'. The field 'graph' has\r
273      * the following description: TODO: decide if this flag is\r
274      *  redundant - when true it would suggest that\r
275      *  the annotationElement values together form a\r
276      *  graph \r
277      * \r
278      * @return the value of field 'Graph'.\r
279      */\r
280     public boolean isGraph(\r
281     ) {\r
282         return this._graph;\r
283     }\r
284 \r
285     /**\r
286      * Method isValid.\r
287      * \r
288      * @return true if this object is valid according to the schema\r
289      */\r
290     public boolean isValid(\r
291     ) {\r
292         try {\r
293             validate();\r
294         } catch (org.exolab.castor.xml.ValidationException vex) {\r
295             return false;\r
296         }\r
297         return true;\r
298     }\r
299 \r
300     /**\r
301      * \r
302      * \r
303      * @param out\r
304      * @throws org.exolab.castor.xml.MarshalException if object is\r
305      * null or if any SAXException is thrown during marshaling\r
306      * @throws org.exolab.castor.xml.ValidationException if this\r
307      * object is an invalid instance according to the schema\r
308      */\r
309     public void marshal(\r
310             final java.io.Writer out)\r
311     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
312         Marshaller.marshal(this, out);\r
313     }\r
314 \r
315     /**\r
316      * \r
317      * \r
318      * @param handler\r
319      * @throws java.io.IOException if an IOException occurs during\r
320      * marshaling\r
321      * @throws org.exolab.castor.xml.ValidationException if this\r
322      * object is an invalid instance according to the schema\r
323      * @throws org.exolab.castor.xml.MarshalException if object is\r
324      * null or if any SAXException is thrown during marshaling\r
325      */\r
326     public void marshal(\r
327             final org.xml.sax.ContentHandler handler)\r
328     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
329         Marshaller.marshal(this, handler);\r
330     }\r
331 \r
332     /**\r
333      */\r
334     public void removeAllSeqrefs(\r
335     ) {\r
336         this._seqrefs.clear();\r
337     }\r
338 \r
339     /**\r
340      * Method removeSeqrefs.\r
341      * \r
342      * @param vSeqrefs\r
343      * @return true if the object was removed from the collection.\r
344      */\r
345     public boolean removeSeqrefs(\r
346             final java.lang.Object vSeqrefs) {\r
347         boolean removed = _seqrefs.remove(vSeqrefs);\r
348         return removed;\r
349     }\r
350 \r
351     /**\r
352      * Method removeSeqrefsAt.\r
353      * \r
354      * @param index\r
355      * @return the element removed from the collection\r
356      */\r
357     public java.lang.Object removeSeqrefsAt(\r
358             final int index) {\r
359         java.lang.Object obj = this._seqrefs.remove(index);\r
360         return obj;\r
361     }\r
362 \r
363     /**\r
364      * Sets the value of field 'graph'. The field 'graph' has the\r
365      * following description: TODO: decide if this flag is\r
366      *  redundant - when true it would suggest that\r
367      *  the annotationElement values together form a\r
368      *  graph \r
369      * \r
370      * @param graph the value of field 'graph'.\r
371      */\r
372     public void setGraph(\r
373             final boolean graph) {\r
374         this._graph = graph;\r
375         this._has_graph = true;\r
376     }\r
377 \r
378     /**\r
379      * Sets the value of field 'provenance'.\r
380      * \r
381      * @param provenance the value of field 'provenance'.\r
382      */\r
383     public void setProvenance(\r
384             final uk.ac.vamsas.objects.core.Provenance provenance) {\r
385         this._provenance = provenance;\r
386     }\r
387 \r
388     /**\r
389      * \r
390      * \r
391      * @param index\r
392      * @param vSeqrefs\r
393      * @throws java.lang.IndexOutOfBoundsException if the index\r
394      * given is outside the bounds of the collection\r
395      */\r
396     public void setSeqrefs(\r
397             final int index,\r
398             final java.lang.Object vSeqrefs)\r
399     throws java.lang.IndexOutOfBoundsException {\r
400         // check bounds for index\r
401         if (index < 0 || index >= this._seqrefs.size()) {\r
402             throw new IndexOutOfBoundsException("setSeqrefs: Index value '" + index + "' not in range [0.." + (this._seqrefs.size() - 1) + "]");\r
403         }\r
404         \r
405         this._seqrefs.set(index, vSeqrefs);\r
406     }\r
407 \r
408     /**\r
409      * \r
410      * \r
411      * @param vSeqrefsArray\r
412      */\r
413     public void setSeqrefs(\r
414             final java.lang.Object[] vSeqrefsArray) {\r
415         //-- copy array\r
416         _seqrefs.clear();\r
417         \r
418         for (int i = 0; i < vSeqrefsArray.length; i++) {\r
419                 this._seqrefs.add(vSeqrefsArray[i]);\r
420         }\r
421     }\r
422 \r
423     /**\r
424      * Sets the value of '_seqrefs' by copying the given Vector.\r
425      * All elements will be checked for type safety.\r
426      * \r
427      * @param vSeqrefsList the Vector to copy.\r
428      */\r
429     public void setSeqrefs(\r
430             final java.util.Vector vSeqrefsList) {\r
431         // copy vector\r
432         this._seqrefs.clear();\r
433         \r
434         this._seqrefs.addAll(vSeqrefsList);\r
435     }\r
436 \r
437     /**\r
438      * Sets the value of '_seqrefs' by setting it to the given\r
439      * Vector. No type checking is performed.\r
440      * @deprecated\r
441      * \r
442      * @param seqrefsVector the Vector to set.\r
443      */\r
444     public void setSeqrefsAsReference(\r
445             final java.util.Vector seqrefsVector) {\r
446         this._seqrefs = seqrefsVector;\r
447     }\r
448 \r
449     /**\r
450      * Method unmarshal.\r
451      * \r
452      * @param reader\r
453      * @throws org.exolab.castor.xml.MarshalException if object is\r
454      * null or if any SAXException is thrown during marshaling\r
455      * @throws org.exolab.castor.xml.ValidationException if this\r
456      * object is an invalid instance according to the schema\r
457      * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType\r
458      */\r
459     public static uk.ac.vamsas.objects.core.RangeType unmarshal(\r
460             final java.io.Reader reader)\r
461     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
462         return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentAnnotation.class, reader);\r
463     }\r
464 \r
465     /**\r
466      * \r
467      * \r
468      * @throws org.exolab.castor.xml.ValidationException if this\r
469      * object is an invalid instance according to the schema\r
470      */\r
471     public void validate(\r
472     )\r
473     throws org.exolab.castor.xml.ValidationException {\r
474         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
475         validator.validate(this);\r
476     }\r
477 \r
478 }\r