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