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