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