JAL-1620 version bump and release notes
[jalview.git] / src / jalview / binding / JSeq.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1)
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.binding;
22
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
26
27 import jalview.util.MessageManager;
28
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
31
32 /**
33  * Class JSeq.
34  * 
35  * @version $Revision$ $Date$
36  */
37 public class JSeq implements java.io.Serializable
38 {
39
40   // --------------------------/
41   // - Class/Member Variables -/
42   // --------------------------/
43
44   /**
45    * Field _colour.
46    */
47   private int _colour;
48
49   /**
50    * keeps track of state for field: _colour
51    */
52   private boolean _has_colour;
53
54   /**
55    * Field _start.
56    */
57   private int _start;
58
59   /**
60    * keeps track of state for field: _start
61    */
62   private boolean _has_start;
63
64   /**
65    * Field _end.
66    */
67   private int _end;
68
69   /**
70    * keeps track of state for field: _end
71    */
72   private boolean _has_end;
73
74   /**
75    * Field _id.
76    */
77   private int _id;
78
79   /**
80    * keeps track of state for field: _id
81    */
82   private boolean _has_id;
83
84   /**
85    * Field _featuresList.
86    */
87   private java.util.Vector _featuresList;
88
89   /**
90    * Field _pdbidsList.
91    */
92   private java.util.Vector _pdbidsList;
93
94   // ----------------/
95   // - Constructors -/
96   // ----------------/
97
98   public JSeq()
99   {
100     super();
101     this._featuresList = new java.util.Vector();
102     this._pdbidsList = new java.util.Vector();
103   }
104
105   // -----------/
106   // - Methods -/
107   // -----------/
108
109   /**
110    * 
111    * 
112    * @param vFeatures
113    * @throws java.lang.IndexOutOfBoundsException
114    *           if the index given is outside the bounds of the collection
115    */
116   public void addFeatures(final jalview.binding.Features vFeatures)
117           throws java.lang.IndexOutOfBoundsException
118   {
119     this._featuresList.addElement(vFeatures);
120   }
121
122   /**
123    * 
124    * 
125    * @param index
126    * @param vFeatures
127    * @throws java.lang.IndexOutOfBoundsException
128    *           if the index given is outside the bounds of the collection
129    */
130   public void addFeatures(final int index,
131           final jalview.binding.Features vFeatures)
132           throws java.lang.IndexOutOfBoundsException
133   {
134     this._featuresList.add(index, vFeatures);
135   }
136
137   /**
138    * 
139    * 
140    * @param vPdbids
141    * @throws java.lang.IndexOutOfBoundsException
142    *           if the index given is outside the bounds of the collection
143    */
144   public void addPdbids(final jalview.binding.Pdbids vPdbids)
145           throws java.lang.IndexOutOfBoundsException
146   {
147     this._pdbidsList.addElement(vPdbids);
148   }
149
150   /**
151    * 
152    * 
153    * @param index
154    * @param vPdbids
155    * @throws java.lang.IndexOutOfBoundsException
156    *           if the index given is outside the bounds of the collection
157    */
158   public void addPdbids(final int index,
159           final jalview.binding.Pdbids vPdbids)
160           throws java.lang.IndexOutOfBoundsException
161   {
162     this._pdbidsList.add(index, vPdbids);
163   }
164
165   /**
166      */
167   public void deleteColour()
168   {
169     this._has_colour = false;
170   }
171
172   /**
173      */
174   public void deleteEnd()
175   {
176     this._has_end = false;
177   }
178
179   /**
180      */
181   public void deleteId()
182   {
183     this._has_id = false;
184   }
185
186   /**
187      */
188   public void deleteStart()
189   {
190     this._has_start = false;
191   }
192
193   /**
194    * Method enumerateFeatures.
195    * 
196    * @return an Enumeration over all jalview.binding.Features elements
197    */
198   public java.util.Enumeration enumerateFeatures()
199   {
200     return this._featuresList.elements();
201   }
202
203   /**
204    * Method enumeratePdbids.
205    * 
206    * @return an Enumeration over all jalview.binding.Pdbids elements
207    */
208   public java.util.Enumeration enumeratePdbids()
209   {
210     return this._pdbidsList.elements();
211   }
212
213   /**
214    * Returns the value of field 'colour'.
215    * 
216    * @return the value of field 'Colour'.
217    */
218   public int getColour()
219   {
220     return this._colour;
221   }
222
223   /**
224    * Returns the value of field 'end'.
225    * 
226    * @return the value of field 'End'.
227    */
228   public int getEnd()
229   {
230     return this._end;
231   }
232
233   /**
234    * Method getFeatures.
235    * 
236    * @param index
237    * @throws java.lang.IndexOutOfBoundsException
238    *           if the index given is outside the bounds of the collection
239    * @return the value of the jalview.binding.Features at the given index
240    */
241   public jalview.binding.Features getFeatures(final int index)
242           throws java.lang.IndexOutOfBoundsException
243   {
244     // check bounds for index
245     if (index < 0 || index >= this._featuresList.size())
246     {
247         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
248                   "getFeatures",
249                   Integer.valueOf(index).toString(),
250                   Integer.valueOf((this._featuresList.size() - 1)).toString()
251         })); 
252     }
253
254     return (jalview.binding.Features) _featuresList.get(index);
255   }
256
257   /**
258    * Method getFeatures.Returns the contents of the collection in an Array.
259    * <p>
260    * Note: Just in case the collection contents are changing in another thread,
261    * we pass a 0-length Array of the correct type into the API call. This way we
262    * <i>know</i> that the Array returned is of exactly the correct length.
263    * 
264    * @return this collection as an Array
265    */
266   public jalview.binding.Features[] getFeatures()
267   {
268     jalview.binding.Features[] array = new jalview.binding.Features[0];
269     return (jalview.binding.Features[]) this._featuresList.toArray(array);
270   }
271
272   /**
273    * Method getFeaturesCount.
274    * 
275    * @return the size of this collection
276    */
277   public int getFeaturesCount()
278   {
279     return this._featuresList.size();
280   }
281
282   /**
283    * Returns the value of field 'id'.
284    * 
285    * @return the value of field 'Id'.
286    */
287   public int getId()
288   {
289     return this._id;
290   }
291
292   /**
293    * Method getPdbids.
294    * 
295    * @param index
296    * @throws java.lang.IndexOutOfBoundsException
297    *           if the index given is outside the bounds of the collection
298    * @return the value of the jalview.binding.Pdbids at the given index
299    */
300   public jalview.binding.Pdbids getPdbids(final int index)
301           throws java.lang.IndexOutOfBoundsException
302   {
303     // check bounds for index
304     if (index < 0 || index >= this._pdbidsList.size())
305     {
306         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
307                           "getPdbids",
308                           Integer.valueOf(index).toString(),
309                           Integer.valueOf((this._pdbidsList.size() - 1)).toString()
310           })); 
311     }
312
313     return (jalview.binding.Pdbids) _pdbidsList.get(index);
314   }
315
316   /**
317    * Method getPdbids.Returns the contents of the collection in an Array.
318    * <p>
319    * Note: Just in case the collection contents are changing in another thread,
320    * we pass a 0-length Array of the correct type into the API call. This way we
321    * <i>know</i> that the Array returned is of exactly the correct length.
322    * 
323    * @return this collection as an Array
324    */
325   public jalview.binding.Pdbids[] getPdbids()
326   {
327     jalview.binding.Pdbids[] array = new jalview.binding.Pdbids[0];
328     return (jalview.binding.Pdbids[]) this._pdbidsList.toArray(array);
329   }
330
331   /**
332    * Method getPdbidsCount.
333    * 
334    * @return the size of this collection
335    */
336   public int getPdbidsCount()
337   {
338     return this._pdbidsList.size();
339   }
340
341   /**
342    * Returns the value of field 'start'.
343    * 
344    * @return the value of field 'Start'.
345    */
346   public int getStart()
347   {
348     return this._start;
349   }
350
351   /**
352    * Method hasColour.
353    * 
354    * @return true if at least one Colour has been added
355    */
356   public boolean hasColour()
357   {
358     return this._has_colour;
359   }
360
361   /**
362    * Method hasEnd.
363    * 
364    * @return true if at least one End has been added
365    */
366   public boolean hasEnd()
367   {
368     return this._has_end;
369   }
370
371   /**
372    * Method hasId.
373    * 
374    * @return true if at least one Id has been added
375    */
376   public boolean hasId()
377   {
378     return this._has_id;
379   }
380
381   /**
382    * Method hasStart.
383    * 
384    * @return true if at least one Start has been added
385    */
386   public boolean hasStart()
387   {
388     return this._has_start;
389   }
390
391   /**
392    * Method isValid.
393    * 
394    * @return true if this object is valid according to the schema
395    */
396   public boolean isValid()
397   {
398     try
399     {
400       validate();
401     } catch (org.exolab.castor.xml.ValidationException vex)
402     {
403       return false;
404     }
405     return true;
406   }
407
408   /**
409    * 
410    * 
411    * @param out
412    * @throws org.exolab.castor.xml.MarshalException
413    *           if object is null or if any SAXException is thrown during
414    *           marshaling
415    * @throws org.exolab.castor.xml.ValidationException
416    *           if this object is an invalid instance according to the schema
417    */
418   public void marshal(final java.io.Writer out)
419           throws org.exolab.castor.xml.MarshalException,
420           org.exolab.castor.xml.ValidationException
421   {
422     Marshaller.marshal(this, out);
423   }
424
425   /**
426    * 
427    * 
428    * @param handler
429    * @throws java.io.IOException
430    *           if an IOException occurs during marshaling
431    * @throws org.exolab.castor.xml.ValidationException
432    *           if this object is an invalid instance according to the schema
433    * @throws org.exolab.castor.xml.MarshalException
434    *           if object is null or if any SAXException is thrown during
435    *           marshaling
436    */
437   public void marshal(final org.xml.sax.ContentHandler handler)
438           throws java.io.IOException,
439           org.exolab.castor.xml.MarshalException,
440           org.exolab.castor.xml.ValidationException
441   {
442     Marshaller.marshal(this, handler);
443   }
444
445   /**
446      */
447   public void removeAllFeatures()
448   {
449     this._featuresList.clear();
450   }
451
452   /**
453      */
454   public void removeAllPdbids()
455   {
456     this._pdbidsList.clear();
457   }
458
459   /**
460    * Method removeFeatures.
461    * 
462    * @param vFeatures
463    * @return true if the object was removed from the collection.
464    */
465   public boolean removeFeatures(final jalview.binding.Features vFeatures)
466   {
467     boolean removed = _featuresList.remove(vFeatures);
468     return removed;
469   }
470
471   /**
472    * Method removeFeaturesAt.
473    * 
474    * @param index
475    * @return the element removed from the collection
476    */
477   public jalview.binding.Features removeFeaturesAt(final int index)
478   {
479     java.lang.Object obj = this._featuresList.remove(index);
480     return (jalview.binding.Features) obj;
481   }
482
483   /**
484    * Method removePdbids.
485    * 
486    * @param vPdbids
487    * @return true if the object was removed from the collection.
488    */
489   public boolean removePdbids(final jalview.binding.Pdbids vPdbids)
490   {
491     boolean removed = _pdbidsList.remove(vPdbids);
492     return removed;
493   }
494
495   /**
496    * Method removePdbidsAt.
497    * 
498    * @param index
499    * @return the element removed from the collection
500    */
501   public jalview.binding.Pdbids removePdbidsAt(final int index)
502   {
503     java.lang.Object obj = this._pdbidsList.remove(index);
504     return (jalview.binding.Pdbids) obj;
505   }
506
507   /**
508    * Sets the value of field 'colour'.
509    * 
510    * @param colour
511    *          the value of field 'colour'.
512    */
513   public void setColour(final int colour)
514   {
515     this._colour = colour;
516     this._has_colour = true;
517   }
518
519   /**
520    * Sets the value of field 'end'.
521    * 
522    * @param end
523    *          the value of field 'end'.
524    */
525   public void setEnd(final int end)
526   {
527     this._end = end;
528     this._has_end = true;
529   }
530
531   /**
532    * 
533    * 
534    * @param index
535    * @param vFeatures
536    * @throws java.lang.IndexOutOfBoundsException
537    *           if the index given is outside the bounds of the collection
538    */
539   public void setFeatures(final int index,
540           final jalview.binding.Features vFeatures)
541           throws java.lang.IndexOutOfBoundsException
542   {
543     // check bounds for index
544     if (index < 0 || index >= this._featuresList.size())
545     {
546         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
547                   "setFeatures",
548                   Integer.valueOf(index).toString(),
549                   Integer.valueOf((this._featuresList.size() - 1)).toString()
550         })); 
551     }
552
553     this._featuresList.set(index, vFeatures);
554   }
555
556   /**
557    * 
558    * 
559    * @param vFeaturesArray
560    */
561   public void setFeatures(final jalview.binding.Features[] vFeaturesArray)
562   {
563     // -- copy array
564     _featuresList.clear();
565
566     for (int i = 0; i < vFeaturesArray.length; i++)
567     {
568       this._featuresList.add(vFeaturesArray[i]);
569     }
570   }
571
572   /**
573    * Sets the value of field 'id'.
574    * 
575    * @param id
576    *          the value of field 'id'.
577    */
578   public void setId(final int id)
579   {
580     this._id = id;
581     this._has_id = true;
582   }
583
584   /**
585    * 
586    * 
587    * @param index
588    * @param vPdbids
589    * @throws java.lang.IndexOutOfBoundsException
590    *           if the index given is outside the bounds of the collection
591    */
592   public void setPdbids(final int index,
593           final jalview.binding.Pdbids vPdbids)
594           throws java.lang.IndexOutOfBoundsException
595   {
596     // check bounds for index
597     if (index < 0 || index >= this._pdbidsList.size())
598     {
599         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
600                           "setPdbids",
601                           Integer.valueOf(index).toString(),
602                           Integer.valueOf((this._pdbidsList.size() - 1)).toString()
603           })); 
604     }
605
606     this._pdbidsList.set(index, vPdbids);
607   }
608
609   /**
610    * 
611    * 
612    * @param vPdbidsArray
613    */
614   public void setPdbids(final jalview.binding.Pdbids[] vPdbidsArray)
615   {
616     // -- copy array
617     _pdbidsList.clear();
618
619     for (int i = 0; i < vPdbidsArray.length; i++)
620     {
621       this._pdbidsList.add(vPdbidsArray[i]);
622     }
623   }
624
625   /**
626    * Sets the value of field 'start'.
627    * 
628    * @param start
629    *          the value of field 'start'.
630    */
631   public void setStart(final int start)
632   {
633     this._start = start;
634     this._has_start = true;
635   }
636
637   /**
638    * Method unmarshal.
639    * 
640    * @param reader
641    * @throws org.exolab.castor.xml.MarshalException
642    *           if object is null or if any SAXException is thrown during
643    *           marshaling
644    * @throws org.exolab.castor.xml.ValidationException
645    *           if this object is an invalid instance according to the schema
646    * @return the unmarshaled jalview.binding.JSeq
647    */
648   public static jalview.binding.JSeq unmarshal(final java.io.Reader reader)
649           throws org.exolab.castor.xml.MarshalException,
650           org.exolab.castor.xml.ValidationException
651   {
652     return (jalview.binding.JSeq) Unmarshaller.unmarshal(
653             jalview.binding.JSeq.class, reader);
654   }
655
656   /**
657    * 
658    * 
659    * @throws org.exolab.castor.xml.ValidationException
660    *           if this object is an invalid instance according to the schema
661    */
662   public void validate() throws org.exolab.castor.xml.ValidationException
663   {
664     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
665     validator.validate(this);
666   }
667
668 }