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