applied 2009 GPL license
[jalview.git] / src / jalview / schemabinding / version2 / Feature.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4.0.b2)\r
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2;\r
20 \r
21 // ---------------------------------/\r
22 // - Imported classes and packages -/\r
23 // ---------------------------------/\r
24 \r
25 import org.exolab.castor.xml.Marshaller;\r
26 import org.exolab.castor.xml.Unmarshaller;\r
27 \r
28 /**\r
29  * Class Feature.\r
30  * \r
31  * @version $Revision$ $Date$\r
32  */\r
33 public class Feature implements java.io.Serializable\r
34 {\r
35 \r
36   // --------------------------/\r
37   // - Class/Member Variables -/\r
38   // --------------------------/\r
39 \r
40   /**\r
41    * Field _begin.\r
42    */\r
43   private int _begin;\r
44 \r
45   /**\r
46    * keeps track of state for field: _begin\r
47    */\r
48   private boolean _has_begin;\r
49 \r
50   /**\r
51    * Field _end.\r
52    */\r
53   private int _end;\r
54 \r
55   /**\r
56    * keeps track of state for field: _end\r
57    */\r
58   private boolean _has_end;\r
59 \r
60   /**\r
61    * Field _type.\r
62    */\r
63   private java.lang.String _type;\r
64 \r
65   /**\r
66    * Field _description.\r
67    */\r
68   private java.lang.String _description;\r
69 \r
70   /**\r
71    * Field _status.\r
72    */\r
73   private java.lang.String _status;\r
74 \r
75   /**\r
76    * Field _featureGroup.\r
77    */\r
78   private java.lang.String _featureGroup;\r
79 \r
80   /**\r
81    * Field _score.\r
82    */\r
83   private float _score;\r
84 \r
85   /**\r
86    * keeps track of state for field: _score\r
87    */\r
88   private boolean _has_score;\r
89 \r
90   /**\r
91    * Field _otherDataList.\r
92    */\r
93   private java.util.Vector _otherDataList;\r
94 \r
95   // ----------------/\r
96   // - Constructors -/\r
97   // ----------------/\r
98 \r
99   public Feature()\r
100   {\r
101     super();\r
102     this._otherDataList = new java.util.Vector();\r
103   }\r
104 \r
105   // -----------/\r
106   // - Methods -/\r
107   // -----------/\r
108 \r
109   /**\r
110    * \r
111    * \r
112    * @param vOtherData\r
113    * @throws java.lang.IndexOutOfBoundsException\r
114    *                 if the index given is outside the bounds of the collection\r
115    */\r
116   public void addOtherData(\r
117           final jalview.schemabinding.version2.OtherData vOtherData)\r
118           throws java.lang.IndexOutOfBoundsException\r
119   {\r
120     this._otherDataList.addElement(vOtherData);\r
121   }\r
122 \r
123   /**\r
124    * \r
125    * \r
126    * @param index\r
127    * @param vOtherData\r
128    * @throws java.lang.IndexOutOfBoundsException\r
129    *                 if the index given is outside the bounds of the collection\r
130    */\r
131   public void addOtherData(final int index,\r
132           final jalview.schemabinding.version2.OtherData vOtherData)\r
133           throws java.lang.IndexOutOfBoundsException\r
134   {\r
135     this._otherDataList.add(index, vOtherData);\r
136   }\r
137 \r
138   /**\r
139    */\r
140   public void deleteBegin()\r
141   {\r
142     this._has_begin = false;\r
143   }\r
144 \r
145   /**\r
146    */\r
147   public void deleteEnd()\r
148   {\r
149     this._has_end = false;\r
150   }\r
151 \r
152   /**\r
153    */\r
154   public void deleteScore()\r
155   {\r
156     this._has_score = false;\r
157   }\r
158 \r
159   /**\r
160    * Method enumerateOtherData.\r
161    * \r
162    * @return an Enumeration over all jalview.schemabinding.version2.OtherData\r
163    *         elements\r
164    */\r
165   public java.util.Enumeration enumerateOtherData()\r
166   {\r
167     return this._otherDataList.elements();\r
168   }\r
169 \r
170   /**\r
171    * Returns the value of field 'begin'.\r
172    * \r
173    * @return the value of field 'Begin'.\r
174    */\r
175   public int getBegin()\r
176   {\r
177     return this._begin;\r
178   }\r
179 \r
180   /**\r
181    * Returns the value of field 'description'.\r
182    * \r
183    * @return the value of field 'Description'.\r
184    */\r
185   public java.lang.String getDescription()\r
186   {\r
187     return this._description;\r
188   }\r
189 \r
190   /**\r
191    * Returns the value of field 'end'.\r
192    * \r
193    * @return the value of field 'End'.\r
194    */\r
195   public int getEnd()\r
196   {\r
197     return this._end;\r
198   }\r
199 \r
200   /**\r
201    * Returns the value of field 'featureGroup'.\r
202    * \r
203    * @return the value of field 'FeatureGroup'.\r
204    */\r
205   public java.lang.String getFeatureGroup()\r
206   {\r
207     return this._featureGroup;\r
208   }\r
209 \r
210   /**\r
211    * Method getOtherData.\r
212    * \r
213    * @param index\r
214    * @throws java.lang.IndexOutOfBoundsException\r
215    *                 if the index given is outside the bounds of the collection\r
216    * @return the value of the jalview.schemabinding.version2.OtherData at the\r
217    *         given index\r
218    */\r
219   public jalview.schemabinding.version2.OtherData getOtherData(\r
220           final int index) throws java.lang.IndexOutOfBoundsException\r
221   {\r
222     // check bounds for index\r
223     if (index < 0 || index >= this._otherDataList.size())\r
224     {\r
225       throw new IndexOutOfBoundsException("getOtherData: Index value '"\r
226               + index + "' not in range [0.."\r
227               + (this._otherDataList.size() - 1) + "]");\r
228     }\r
229 \r
230     return (jalview.schemabinding.version2.OtherData) _otherDataList\r
231             .get(index);\r
232   }\r
233 \r
234   /**\r
235    * Method getOtherData.Returns the contents of the collection in an Array.\r
236    * <p>\r
237    * Note: Just in case the collection contents are changing in another thread,\r
238    * we pass a 0-length Array of the correct type into the API call. This way we\r
239    * <i>know</i> that the Array returned is of exactly the correct length.\r
240    * \r
241    * @return this collection as an Array\r
242    */\r
243   public jalview.schemabinding.version2.OtherData[] getOtherData()\r
244   {\r
245     jalview.schemabinding.version2.OtherData[] array = new jalview.schemabinding.version2.OtherData[0];\r
246     return (jalview.schemabinding.version2.OtherData[]) this._otherDataList\r
247             .toArray(array);\r
248   }\r
249 \r
250   /**\r
251    * Method getOtherDataCount.\r
252    * \r
253    * @return the size of this collection\r
254    */\r
255   public int getOtherDataCount()\r
256   {\r
257     return this._otherDataList.size();\r
258   }\r
259 \r
260   /**\r
261    * Returns the value of field 'score'.\r
262    * \r
263    * @return the value of field 'Score'.\r
264    */\r
265   public float getScore()\r
266   {\r
267     return this._score;\r
268   }\r
269 \r
270   /**\r
271    * Returns the value of field 'status'.\r
272    * \r
273    * @return the value of field 'Status'.\r
274    */\r
275   public java.lang.String getStatus()\r
276   {\r
277     return this._status;\r
278   }\r
279 \r
280   /**\r
281    * Returns the value of field 'type'.\r
282    * \r
283    * @return the value of field 'Type'.\r
284    */\r
285   public java.lang.String getType()\r
286   {\r
287     return this._type;\r
288   }\r
289 \r
290   /**\r
291    * Method hasBegin.\r
292    * \r
293    * @return true if at least one Begin has been added\r
294    */\r
295   public boolean hasBegin()\r
296   {\r
297     return this._has_begin;\r
298   }\r
299 \r
300   /**\r
301    * Method hasEnd.\r
302    * \r
303    * @return true if at least one End has been added\r
304    */\r
305   public boolean hasEnd()\r
306   {\r
307     return this._has_end;\r
308   }\r
309 \r
310   /**\r
311    * Method hasScore.\r
312    * \r
313    * @return true if at least one Score has been added\r
314    */\r
315   public boolean hasScore()\r
316   {\r
317     return this._has_score;\r
318   }\r
319 \r
320   /**\r
321    * Method isValid.\r
322    * \r
323    * @return true if this object is valid according to the schema\r
324    */\r
325   public boolean isValid()\r
326   {\r
327     try\r
328     {\r
329       validate();\r
330     } catch (org.exolab.castor.xml.ValidationException vex)\r
331     {\r
332       return false;\r
333     }\r
334     return true;\r
335   }\r
336 \r
337   /**\r
338    * \r
339    * \r
340    * @param out\r
341    * @throws org.exolab.castor.xml.MarshalException\r
342    *                 if object is null or if any SAXException is thrown during\r
343    *                 marshaling\r
344    * @throws org.exolab.castor.xml.ValidationException\r
345    *                 if this object is an invalid instance according to the\r
346    *                 schema\r
347    */\r
348   public void marshal(final java.io.Writer out)\r
349           throws org.exolab.castor.xml.MarshalException,\r
350           org.exolab.castor.xml.ValidationException\r
351   {\r
352     Marshaller.marshal(this, out);\r
353   }\r
354 \r
355   /**\r
356    * \r
357    * \r
358    * @param handler\r
359    * @throws java.io.IOException\r
360    *                 if an IOException occurs during marshaling\r
361    * @throws org.exolab.castor.xml.ValidationException\r
362    *                 if this object is an invalid instance according to the\r
363    *                 schema\r
364    * @throws org.exolab.castor.xml.MarshalException\r
365    *                 if object is null or if any SAXException is thrown during\r
366    *                 marshaling\r
367    */\r
368   public void marshal(final org.xml.sax.ContentHandler handler)\r
369           throws java.io.IOException,\r
370           org.exolab.castor.xml.MarshalException,\r
371           org.exolab.castor.xml.ValidationException\r
372   {\r
373     Marshaller.marshal(this, handler);\r
374   }\r
375 \r
376   /**\r
377    */\r
378   public void removeAllOtherData()\r
379   {\r
380     this._otherDataList.clear();\r
381   }\r
382 \r
383   /**\r
384    * Method removeOtherData.\r
385    * \r
386    * @param vOtherData\r
387    * @return true if the object was removed from the collection.\r
388    */\r
389   public boolean removeOtherData(\r
390           final jalview.schemabinding.version2.OtherData vOtherData)\r
391   {\r
392     boolean removed = _otherDataList.remove(vOtherData);\r
393     return removed;\r
394   }\r
395 \r
396   /**\r
397    * Method removeOtherDataAt.\r
398    * \r
399    * @param index\r
400    * @return the element removed from the collection\r
401    */\r
402   public jalview.schemabinding.version2.OtherData removeOtherDataAt(\r
403           final int index)\r
404   {\r
405     java.lang.Object obj = this._otherDataList.remove(index);\r
406     return (jalview.schemabinding.version2.OtherData) obj;\r
407   }\r
408 \r
409   /**\r
410    * Sets the value of field 'begin'.\r
411    * \r
412    * @param begin\r
413    *                the value of field 'begin'.\r
414    */\r
415   public void setBegin(final int begin)\r
416   {\r
417     this._begin = begin;\r
418     this._has_begin = true;\r
419   }\r
420 \r
421   /**\r
422    * Sets the value of field 'description'.\r
423    * \r
424    * @param description\r
425    *                the value of field 'description'.\r
426    */\r
427   public void setDescription(final java.lang.String description)\r
428   {\r
429     this._description = description;\r
430   }\r
431 \r
432   /**\r
433    * Sets the value of field 'end'.\r
434    * \r
435    * @param end\r
436    *                the value of field 'end'.\r
437    */\r
438   public void setEnd(final int end)\r
439   {\r
440     this._end = end;\r
441     this._has_end = true;\r
442   }\r
443 \r
444   /**\r
445    * Sets the value of field 'featureGroup'.\r
446    * \r
447    * @param featureGroup\r
448    *                the value of field 'featureGroup'.\r
449    */\r
450   public void setFeatureGroup(final java.lang.String featureGroup)\r
451   {\r
452     this._featureGroup = featureGroup;\r
453   }\r
454 \r
455   /**\r
456    * \r
457    * \r
458    * @param index\r
459    * @param vOtherData\r
460    * @throws java.lang.IndexOutOfBoundsException\r
461    *                 if the index given is outside the bounds of the collection\r
462    */\r
463   public void setOtherData(final int index,\r
464           final jalview.schemabinding.version2.OtherData vOtherData)\r
465           throws java.lang.IndexOutOfBoundsException\r
466   {\r
467     // check bounds for index\r
468     if (index < 0 || index >= this._otherDataList.size())\r
469     {\r
470       throw new IndexOutOfBoundsException("setOtherData: Index value '"\r
471               + index + "' not in range [0.."\r
472               + (this._otherDataList.size() - 1) + "]");\r
473     }\r
474 \r
475     this._otherDataList.set(index, vOtherData);\r
476   }\r
477 \r
478   /**\r
479    * \r
480    * \r
481    * @param vOtherDataArray\r
482    */\r
483   public void setOtherData(\r
484           final jalview.schemabinding.version2.OtherData[] vOtherDataArray)\r
485   {\r
486     // -- copy array\r
487     _otherDataList.clear();\r
488 \r
489     for (int i = 0; i < vOtherDataArray.length; i++)\r
490     {\r
491       this._otherDataList.add(vOtherDataArray[i]);\r
492     }\r
493   }\r
494 \r
495   /**\r
496    * Sets the value of field 'score'.\r
497    * \r
498    * @param score\r
499    *                the value of field 'score'.\r
500    */\r
501   public void setScore(final float score)\r
502   {\r
503     this._score = score;\r
504     this._has_score = true;\r
505   }\r
506 \r
507   /**\r
508    * Sets the value of field 'status'.\r
509    * \r
510    * @param status\r
511    *                the value of field 'status'.\r
512    */\r
513   public void setStatus(final java.lang.String status)\r
514   {\r
515     this._status = status;\r
516   }\r
517 \r
518   /**\r
519    * Sets the value of field 'type'.\r
520    * \r
521    * @param type\r
522    *                the value of field 'type'.\r
523    */\r
524   public void setType(final java.lang.String type)\r
525   {\r
526     this._type = type;\r
527   }\r
528 \r
529   /**\r
530    * Method unmarshal.\r
531    * \r
532    * @param reader\r
533    * @throws org.exolab.castor.xml.MarshalException\r
534    *                 if object is null or if any SAXException is thrown during\r
535    *                 marshaling\r
536    * @throws org.exolab.castor.xml.ValidationException\r
537    *                 if this object is an invalid instance according to the\r
538    *                 schema\r
539    * @return the unmarshaled jalview.schemabinding.version2.Featur\r
540    */\r
541   public static jalview.schemabinding.version2.Feature unmarshal(\r
542           final java.io.Reader reader)\r
543           throws org.exolab.castor.xml.MarshalException,\r
544           org.exolab.castor.xml.ValidationException\r
545   {\r
546     return (jalview.schemabinding.version2.Feature) Unmarshaller.unmarshal(\r
547             jalview.schemabinding.version2.Feature.class, reader);\r
548   }\r
549 \r
550   /**\r
551    * \r
552    * \r
553    * @throws org.exolab.castor.xml.ValidationException\r
554    *                 if this object is an invalid instance according to the\r
555    *                 schema\r
556    */\r
557   public void validate() throws org.exolab.castor.xml.ValidationException\r
558   {\r
559     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
560     validator.validate(this);\r
561   }\r
562 \r
563 }\r