9c27bd1b5f555398ab755bae4b305248ff74ad6e
[jalview.git] / src / jalview / schemabinding / version2 / Feature.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)\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       //----------------/\r
97      //- Constructors -/\r
98     //----------------/\r
99 \r
100     public Feature() {\r
101         super();\r
102         this._otherDataList = new java.util.Vector();\r
103     }\r
104 \r
105 \r
106       //-----------/\r
107      //- Methods -/\r
108     //-----------/\r
109 \r
110     /**\r
111      * \r
112      * \r
113      * @param vOtherData\r
114      * @throws java.lang.IndexOutOfBoundsException if the index\r
115      * given is outside the bounds of the collection\r
116      */\r
117     public void addOtherData(\r
118             final jalview.schemabinding.version2.OtherData vOtherData)\r
119     throws java.lang.IndexOutOfBoundsException {\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 if the index\r
129      * given is outside the bounds of the collection\r
130      */\r
131     public void addOtherData(\r
132             final int index,\r
133             final jalview.schemabinding.version2.OtherData vOtherData)\r
134     throws java.lang.IndexOutOfBoundsException {\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\r
163      * jalview.schemabinding.version2.OtherData 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 if the index\r
215      * given is outside the bounds of the collection\r
216      * @return the value of the\r
217      * jalview.schemabinding.version2.OtherData at the given index\r
218      */\r
219     public jalview.schemabinding.version2.OtherData getOtherData(\r
220             final int index)\r
221     throws java.lang.IndexOutOfBoundsException {\r
222         // check bounds for index\r
223         if (index < 0 || index >= this._otherDataList.size()) {\r
224             throw new IndexOutOfBoundsException("getOtherData: Index value '" + index + "' not in range [0.." + (this._otherDataList.size() - 1) + "]");\r
225         }\r
226         \r
227         return (jalview.schemabinding.version2.OtherData) _otherDataList.get(index);\r
228     }\r
229 \r
230     /**\r
231      * Method getOtherData.Returns the contents of the collection\r
232      * in an Array.  <p>Note:  Just in case the collection contents\r
233      * are changing in another thread, we pass a 0-length Array of\r
234      * the correct type into the API call.  This way we <i>know</i>\r
235      * that the Array returned is of exactly the correct length.\r
236      * \r
237      * @return this collection as an Array\r
238      */\r
239     public jalview.schemabinding.version2.OtherData[] getOtherData(\r
240     ) {\r
241         jalview.schemabinding.version2.OtherData[] array = new jalview.schemabinding.version2.OtherData[0];\r
242         return (jalview.schemabinding.version2.OtherData[]) this._otherDataList.toArray(array);\r
243     }\r
244 \r
245     /**\r
246      * Method getOtherDataCount.\r
247      * \r
248      * @return the size of this collection\r
249      */\r
250     public int getOtherDataCount(\r
251     ) {\r
252         return this._otherDataList.size();\r
253     }\r
254 \r
255     /**\r
256      * Returns the value of field 'score'.\r
257      * \r
258      * @return the value of field 'Score'.\r
259      */\r
260     public float getScore(\r
261     ) {\r
262         return this._score;\r
263     }\r
264 \r
265     /**\r
266      * Returns the value of field 'status'.\r
267      * \r
268      * @return the value of field 'Status'.\r
269      */\r
270     public java.lang.String getStatus(\r
271     ) {\r
272         return this._status;\r
273     }\r
274 \r
275     /**\r
276      * Returns the value of field 'type'.\r
277      * \r
278      * @return the value of field 'Type'.\r
279      */\r
280     public java.lang.String getType(\r
281     ) {\r
282         return this._type;\r
283     }\r
284 \r
285     /**\r
286      * Method hasBegin.\r
287      * \r
288      * @return true if at least one Begin has been added\r
289      */\r
290     public boolean hasBegin(\r
291     ) {\r
292         return this._has_begin;\r
293     }\r
294 \r
295     /**\r
296      * Method hasEnd.\r
297      * \r
298      * @return true if at least one End has been added\r
299      */\r
300     public boolean hasEnd(\r
301     ) {\r
302         return this._has_end;\r
303     }\r
304 \r
305     /**\r
306      * Method hasScore.\r
307      * \r
308      * @return true if at least one Score has been added\r
309      */\r
310     public boolean hasScore(\r
311     ) {\r
312         return this._has_score;\r
313     }\r
314 \r
315     /**\r
316      * Method isValid.\r
317      * \r
318      * @return true if this object is valid according to the schema\r
319      */\r
320     public boolean isValid(\r
321     ) {\r
322         try {\r
323             validate();\r
324         } catch (org.exolab.castor.xml.ValidationException vex) {\r
325             return false;\r
326         }\r
327         return true;\r
328     }\r
329 \r
330     /**\r
331      * \r
332      * \r
333      * @param out\r
334      * @throws org.exolab.castor.xml.MarshalException if object is\r
335      * null or if any SAXException is thrown during marshaling\r
336      * @throws org.exolab.castor.xml.ValidationException if this\r
337      * object is an invalid instance according to the schema\r
338      */\r
339     public void marshal(\r
340             final java.io.Writer out)\r
341     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
342         Marshaller.marshal(this, out);\r
343     }\r
344 \r
345     /**\r
346      * \r
347      * \r
348      * @param handler\r
349      * @throws java.io.IOException if an IOException occurs during\r
350      * marshaling\r
351      * @throws org.exolab.castor.xml.ValidationException if this\r
352      * object is an invalid instance according to the schema\r
353      * @throws org.exolab.castor.xml.MarshalException if object is\r
354      * null or if any SAXException is thrown during marshaling\r
355      */\r
356     public void marshal(\r
357             final org.xml.sax.ContentHandler handler)\r
358     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
359         Marshaller.marshal(this, handler);\r
360     }\r
361 \r
362     /**\r
363      */\r
364     public void removeAllOtherData(\r
365     ) {\r
366         this._otherDataList.clear();\r
367     }\r
368 \r
369     /**\r
370      * Method removeOtherData.\r
371      * \r
372      * @param vOtherData\r
373      * @return true if the object was removed from the collection.\r
374      */\r
375     public boolean removeOtherData(\r
376             final jalview.schemabinding.version2.OtherData vOtherData) {\r
377         boolean removed = _otherDataList.remove(vOtherData);\r
378         return removed;\r
379     }\r
380 \r
381     /**\r
382      * Method removeOtherDataAt.\r
383      * \r
384      * @param index\r
385      * @return the element removed from the collection\r
386      */\r
387     public jalview.schemabinding.version2.OtherData removeOtherDataAt(\r
388             final int index) {\r
389         java.lang.Object obj = this._otherDataList.remove(index);\r
390         return (jalview.schemabinding.version2.OtherData) obj;\r
391     }\r
392 \r
393     /**\r
394      * Sets the value of field 'begin'.\r
395      * \r
396      * @param begin the value of field 'begin'.\r
397      */\r
398     public void setBegin(\r
399             final int begin) {\r
400         this._begin = begin;\r
401         this._has_begin = true;\r
402     }\r
403 \r
404     /**\r
405      * Sets the value of field 'description'.\r
406      * \r
407      * @param description the value of field 'description'.\r
408      */\r
409     public void setDescription(\r
410             final java.lang.String description) {\r
411         this._description = description;\r
412     }\r
413 \r
414     /**\r
415      * Sets the value of field 'end'.\r
416      * \r
417      * @param end the value of field 'end'.\r
418      */\r
419     public void setEnd(\r
420             final int end) {\r
421         this._end = end;\r
422         this._has_end = true;\r
423     }\r
424 \r
425     /**\r
426      * Sets the value of field 'featureGroup'.\r
427      * \r
428      * @param featureGroup the value of field 'featureGroup'.\r
429      */\r
430     public void setFeatureGroup(\r
431             final java.lang.String featureGroup) {\r
432         this._featureGroup = featureGroup;\r
433     }\r
434 \r
435     /**\r
436      * \r
437      * \r
438      * @param index\r
439      * @param vOtherData\r
440      * @throws java.lang.IndexOutOfBoundsException if the index\r
441      * given is outside the bounds of the collection\r
442      */\r
443     public void setOtherData(\r
444             final int index,\r
445             final jalview.schemabinding.version2.OtherData vOtherData)\r
446     throws java.lang.IndexOutOfBoundsException {\r
447         // check bounds for index\r
448         if (index < 0 || index >= this._otherDataList.size()) {\r
449             throw new IndexOutOfBoundsException("setOtherData: Index value '" + index + "' not in range [0.." + (this._otherDataList.size() - 1) + "]");\r
450         }\r
451         \r
452         this._otherDataList.set(index, vOtherData);\r
453     }\r
454 \r
455     /**\r
456      * \r
457      * \r
458      * @param vOtherDataArray\r
459      */\r
460     public void setOtherData(\r
461             final jalview.schemabinding.version2.OtherData[] vOtherDataArray) {\r
462         //-- copy array\r
463         _otherDataList.clear();\r
464         \r
465         for (int i = 0; i < vOtherDataArray.length; i++) {\r
466                 this._otherDataList.add(vOtherDataArray[i]);\r
467         }\r
468     }\r
469 \r
470     /**\r
471      * Sets the value of field 'score'.\r
472      * \r
473      * @param score the value of field 'score'.\r
474      */\r
475     public void setScore(\r
476             final float score) {\r
477         this._score = score;\r
478         this._has_score = true;\r
479     }\r
480 \r
481     /**\r
482      * Sets the value of field 'status'.\r
483      * \r
484      * @param status the value of field 'status'.\r
485      */\r
486     public void setStatus(\r
487             final java.lang.String status) {\r
488         this._status = status;\r
489     }\r
490 \r
491     /**\r
492      * Sets the value of field 'type'.\r
493      * \r
494      * @param type the value of field 'type'.\r
495      */\r
496     public void setType(\r
497             final java.lang.String type) {\r
498         this._type = type;\r
499     }\r
500 \r
501     /**\r
502      * Method unmarshal.\r
503      * \r
504      * @param reader\r
505      * @throws org.exolab.castor.xml.MarshalException if object is\r
506      * null or if any SAXException is thrown during marshaling\r
507      * @throws org.exolab.castor.xml.ValidationException if this\r
508      * object is an invalid instance according to the schema\r
509      * @return the unmarshaled jalview.schemabinding.version2.Featur\r
510      */\r
511     public static jalview.schemabinding.version2.Feature unmarshal(\r
512             final java.io.Reader reader)\r
513     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
514         return (jalview.schemabinding.version2.Feature) Unmarshaller.unmarshal(jalview.schemabinding.version2.Feature.class, reader);\r
515     }\r
516 \r
517     /**\r
518      * \r
519      * \r
520      * @throws org.exolab.castor.xml.ValidationException if this\r
521      * object is an invalid instance according to the schema\r
522      */\r
523     public void validate(\r
524     )\r
525     throws org.exolab.castor.xml.ValidationException {\r
526         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
527         validator.validate(this);\r
528     }\r
529 \r
530 }\r