JAL-1620 version bump and release notes
[jalview.git] / src / jalview / schemabinding / version2 / 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.schemabinding.version2;
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 java.lang.String _id;
78
79   /**
80    * Field _hidden.
81    */
82   private boolean _hidden;
83
84   /**
85    * keeps track of state for field: _hidden
86    */
87   private boolean _has_hidden;
88
89   /**
90    * Field _featuresList.
91    */
92   private java.util.Vector _featuresList;
93
94   /**
95    * Field _pdbidsList.
96    */
97   private java.util.Vector _pdbidsList;
98
99   /**
100    * Field _hiddenSequencesList.
101    */
102   private java.util.Vector _hiddenSequencesList;
103
104   // ----------------/
105   // - Constructors -/
106   // ----------------/
107
108   public JSeq()
109   {
110     super();
111     this._featuresList = new java.util.Vector();
112     this._pdbidsList = new java.util.Vector();
113     this._hiddenSequencesList = new java.util.Vector();
114   }
115
116   // -----------/
117   // - Methods -/
118   // -----------/
119
120   /**
121    * 
122    * 
123    * @param vFeatures
124    * @throws java.lang.IndexOutOfBoundsException
125    *           if the index given is outside the bounds of the collection
126    */
127   public void addFeatures(
128           final jalview.schemabinding.version2.Features vFeatures)
129           throws java.lang.IndexOutOfBoundsException
130   {
131     this._featuresList.addElement(vFeatures);
132   }
133
134   /**
135    * 
136    * 
137    * @param index
138    * @param vFeatures
139    * @throws java.lang.IndexOutOfBoundsException
140    *           if the index given is outside the bounds of the collection
141    */
142   public void addFeatures(final int index,
143           final jalview.schemabinding.version2.Features vFeatures)
144           throws java.lang.IndexOutOfBoundsException
145   {
146     this._featuresList.add(index, vFeatures);
147   }
148
149   /**
150    * 
151    * 
152    * @param vHiddenSequences
153    * @throws java.lang.IndexOutOfBoundsException
154    *           if the index given is outside the bounds of the collection
155    */
156   public void addHiddenSequences(final int vHiddenSequences)
157           throws java.lang.IndexOutOfBoundsException
158   {
159     this._hiddenSequencesList.addElement(new java.lang.Integer(
160             vHiddenSequences));
161   }
162
163   /**
164    * 
165    * 
166    * @param index
167    * @param vHiddenSequences
168    * @throws java.lang.IndexOutOfBoundsException
169    *           if the index given is outside the bounds of the collection
170    */
171   public void addHiddenSequences(final int index, final int vHiddenSequences)
172           throws java.lang.IndexOutOfBoundsException
173   {
174     this._hiddenSequencesList.add(index, new java.lang.Integer(
175             vHiddenSequences));
176   }
177
178   /**
179    * 
180    * 
181    * @param vPdbids
182    * @throws java.lang.IndexOutOfBoundsException
183    *           if the index given is outside the bounds of the collection
184    */
185   public void addPdbids(final jalview.schemabinding.version2.Pdbids vPdbids)
186           throws java.lang.IndexOutOfBoundsException
187   {
188     this._pdbidsList.addElement(vPdbids);
189   }
190
191   /**
192    * 
193    * 
194    * @param index
195    * @param vPdbids
196    * @throws java.lang.IndexOutOfBoundsException
197    *           if the index given is outside the bounds of the collection
198    */
199   public void addPdbids(final int index,
200           final jalview.schemabinding.version2.Pdbids vPdbids)
201           throws java.lang.IndexOutOfBoundsException
202   {
203     this._pdbidsList.add(index, vPdbids);
204   }
205
206   /**
207      */
208   public void deleteColour()
209   {
210     this._has_colour = false;
211   }
212
213   /**
214      */
215   public void deleteEnd()
216   {
217     this._has_end = false;
218   }
219
220   /**
221      */
222   public void deleteHidden()
223   {
224     this._has_hidden = false;
225   }
226
227   /**
228      */
229   public void deleteStart()
230   {
231     this._has_start = false;
232   }
233
234   /**
235    * Method enumerateFeatures.
236    * 
237    * @return an Enumeration over all jalview.schemabinding.version2.Features
238    *         elements
239    */
240   public java.util.Enumeration enumerateFeatures()
241   {
242     return this._featuresList.elements();
243   }
244
245   /**
246    * Method enumerateHiddenSequences.
247    * 
248    * @return an Enumeration over all int elements
249    */
250   public java.util.Enumeration enumerateHiddenSequences()
251   {
252     return this._hiddenSequencesList.elements();
253   }
254
255   /**
256    * Method enumeratePdbids.
257    * 
258    * @return an Enumeration over all jalview.schemabinding.version2.Pdbids
259    *         elements
260    */
261   public java.util.Enumeration enumeratePdbids()
262   {
263     return this._pdbidsList.elements();
264   }
265
266   /**
267    * Returns the value of field 'colour'.
268    * 
269    * @return the value of field 'Colour'.
270    */
271   public int getColour()
272   {
273     return this._colour;
274   }
275
276   /**
277    * Returns the value of field 'end'.
278    * 
279    * @return the value of field 'End'.
280    */
281   public int getEnd()
282   {
283     return this._end;
284   }
285
286   /**
287    * Method getFeatures.
288    * 
289    * @param index
290    * @throws java.lang.IndexOutOfBoundsException
291    *           if the index given is outside the bounds of the collection
292    * @return the value of the jalview.schemabinding.version2.Features at the
293    *         given index
294    */
295   public jalview.schemabinding.version2.Features getFeatures(final int index)
296           throws java.lang.IndexOutOfBoundsException
297   {
298     // check bounds for index
299     if (index < 0 || index >= this._featuresList.size())
300     {
301         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
302                           "getFeatures",
303                           Integer.valueOf(index).toString(),
304                           Integer.valueOf((this._featuresList.size() - 1)).toString()
305           })); 
306     }
307
308     return (jalview.schemabinding.version2.Features) _featuresList
309             .get(index);
310   }
311
312   /**
313    * Method getFeatures.Returns the contents of the collection in an Array.
314    * <p>
315    * Note: Just in case the collection contents are changing in another thread,
316    * we pass a 0-length Array of the correct type into the API call. This way we
317    * <i>know</i> that the Array returned is of exactly the correct length.
318    * 
319    * @return this collection as an Array
320    */
321   public jalview.schemabinding.version2.Features[] getFeatures()
322   {
323     jalview.schemabinding.version2.Features[] array = new jalview.schemabinding.version2.Features[0];
324     return (jalview.schemabinding.version2.Features[]) this._featuresList
325             .toArray(array);
326   }
327
328   /**
329    * Method getFeaturesCount.
330    * 
331    * @return the size of this collection
332    */
333   public int getFeaturesCount()
334   {
335     return this._featuresList.size();
336   }
337
338   /**
339    * Returns the value of field 'hidden'.
340    * 
341    * @return the value of field 'Hidden'.
342    */
343   public boolean getHidden()
344   {
345     return this._hidden;
346   }
347
348   /**
349    * Method getHiddenSequences.
350    * 
351    * @param index
352    * @throws java.lang.IndexOutOfBoundsException
353    *           if the index given is outside the bounds of the collection
354    * @return the value of the int at the given index
355    */
356   public int getHiddenSequences(final int index)
357           throws java.lang.IndexOutOfBoundsException
358   {
359     // check bounds for index
360     if (index < 0 || index >= this._hiddenSequencesList.size())
361     {
362         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
363                   "getHiddenSequences",
364                   Integer.valueOf(index).toString(),
365                   Integer.valueOf((this._hiddenSequencesList.size() - 1)).toString()
366         })); 
367     }
368
369     return ((java.lang.Integer) _hiddenSequencesList.get(index)).intValue();
370   }
371
372   /**
373    * Method getHiddenSequences.Returns the contents of the collection in an
374    * Array.
375    * 
376    * @return this collection as an Array
377    */
378   public int[] getHiddenSequences()
379   {
380     int size = this._hiddenSequencesList.size();
381     int[] array = new int[size];
382     java.util.Iterator iter = _hiddenSequencesList.iterator();
383     for (int index = 0; index < size; index++)
384     {
385       array[index] = ((java.lang.Integer) iter.next()).intValue();
386     }
387     return array;
388   }
389
390   /**
391    * Method getHiddenSequencesCount.
392    * 
393    * @return the size of this collection
394    */
395   public int getHiddenSequencesCount()
396   {
397     return this._hiddenSequencesList.size();
398   }
399
400   /**
401    * Returns the value of field 'id'.
402    * 
403    * @return the value of field 'Id'.
404    */
405   public java.lang.String getId()
406   {
407     return this._id;
408   }
409
410   /**
411    * Method getPdbids.
412    * 
413    * @param index
414    * @throws java.lang.IndexOutOfBoundsException
415    *           if the index given is outside the bounds of the collection
416    * @return the value of the jalview.schemabinding.version2.Pdbids at the given
417    *         index
418    */
419   public jalview.schemabinding.version2.Pdbids getPdbids(final int index)
420           throws java.lang.IndexOutOfBoundsException
421   {
422     // check bounds for index
423     if (index < 0 || index >= this._pdbidsList.size())
424     {
425         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
426                           "getPdbids",
427                           Integer.valueOf(index).toString(),
428                           Integer.valueOf((this._pdbidsList.size() - 1)).toString()
429           })); 
430     }
431
432     return (jalview.schemabinding.version2.Pdbids) _pdbidsList.get(index);
433   }
434
435   /**
436    * Method getPdbids.Returns the contents of the collection in an Array.
437    * <p>
438    * Note: Just in case the collection contents are changing in another thread,
439    * we pass a 0-length Array of the correct type into the API call. This way we
440    * <i>know</i> that the Array returned is of exactly the correct length.
441    * 
442    * @return this collection as an Array
443    */
444   public jalview.schemabinding.version2.Pdbids[] getPdbids()
445   {
446     jalview.schemabinding.version2.Pdbids[] array = new jalview.schemabinding.version2.Pdbids[0];
447     return (jalview.schemabinding.version2.Pdbids[]) this._pdbidsList
448             .toArray(array);
449   }
450
451   /**
452    * Method getPdbidsCount.
453    * 
454    * @return the size of this collection
455    */
456   public int getPdbidsCount()
457   {
458     return this._pdbidsList.size();
459   }
460
461   /**
462    * Returns the value of field 'start'.
463    * 
464    * @return the value of field 'Start'.
465    */
466   public int getStart()
467   {
468     return this._start;
469   }
470
471   /**
472    * Method hasColour.
473    * 
474    * @return true if at least one Colour has been added
475    */
476   public boolean hasColour()
477   {
478     return this._has_colour;
479   }
480
481   /**
482    * Method hasEnd.
483    * 
484    * @return true if at least one End has been added
485    */
486   public boolean hasEnd()
487   {
488     return this._has_end;
489   }
490
491   /**
492    * Method hasHidden.
493    * 
494    * @return true if at least one Hidden has been added
495    */
496   public boolean hasHidden()
497   {
498     return this._has_hidden;
499   }
500
501   /**
502    * Method hasStart.
503    * 
504    * @return true if at least one Start has been added
505    */
506   public boolean hasStart()
507   {
508     return this._has_start;
509   }
510
511   /**
512    * Returns the value of field 'hidden'.
513    * 
514    * @return the value of field 'Hidden'.
515    */
516   public boolean isHidden()
517   {
518     return this._hidden;
519   }
520
521   /**
522    * Method isValid.
523    * 
524    * @return true if this object is valid according to the schema
525    */
526   public boolean isValid()
527   {
528     try
529     {
530       validate();
531     } catch (org.exolab.castor.xml.ValidationException vex)
532     {
533       return false;
534     }
535     return true;
536   }
537
538   /**
539    * 
540    * 
541    * @param out
542    * @throws org.exolab.castor.xml.MarshalException
543    *           if object is null or if any SAXException is thrown during
544    *           marshaling
545    * @throws org.exolab.castor.xml.ValidationException
546    *           if this object is an invalid instance according to the schema
547    */
548   public void marshal(final java.io.Writer out)
549           throws org.exolab.castor.xml.MarshalException,
550           org.exolab.castor.xml.ValidationException
551   {
552     Marshaller.marshal(this, out);
553   }
554
555   /**
556    * 
557    * 
558    * @param handler
559    * @throws java.io.IOException
560    *           if an IOException occurs during marshaling
561    * @throws org.exolab.castor.xml.ValidationException
562    *           if this object is an invalid instance according to the schema
563    * @throws org.exolab.castor.xml.MarshalException
564    *           if object is null or if any SAXException is thrown during
565    *           marshaling
566    */
567   public void marshal(final org.xml.sax.ContentHandler handler)
568           throws java.io.IOException,
569           org.exolab.castor.xml.MarshalException,
570           org.exolab.castor.xml.ValidationException
571   {
572     Marshaller.marshal(this, handler);
573   }
574
575   /**
576      */
577   public void removeAllFeatures()
578   {
579     this._featuresList.clear();
580   }
581
582   /**
583      */
584   public void removeAllHiddenSequences()
585   {
586     this._hiddenSequencesList.clear();
587   }
588
589   /**
590      */
591   public void removeAllPdbids()
592   {
593     this._pdbidsList.clear();
594   }
595
596   /**
597    * Method removeFeatures.
598    * 
599    * @param vFeatures
600    * @return true if the object was removed from the collection.
601    */
602   public boolean removeFeatures(
603           final jalview.schemabinding.version2.Features vFeatures)
604   {
605     boolean removed = _featuresList.remove(vFeatures);
606     return removed;
607   }
608
609   /**
610    * Method removeFeaturesAt.
611    * 
612    * @param index
613    * @return the element removed from the collection
614    */
615   public jalview.schemabinding.version2.Features removeFeaturesAt(
616           final int index)
617   {
618     java.lang.Object obj = this._featuresList.remove(index);
619     return (jalview.schemabinding.version2.Features) obj;
620   }
621
622   /**
623    * Method removeHiddenSequences.
624    * 
625    * @param vHiddenSequences
626    * @return true if the object was removed from the collection.
627    */
628   public boolean removeHiddenSequences(final int vHiddenSequences)
629   {
630     boolean removed = _hiddenSequencesList.remove(new java.lang.Integer(
631             vHiddenSequences));
632     return removed;
633   }
634
635   /**
636    * Method removeHiddenSequencesAt.
637    * 
638    * @param index
639    * @return the element removed from the collection
640    */
641   public int removeHiddenSequencesAt(final int index)
642   {
643     java.lang.Object obj = this._hiddenSequencesList.remove(index);
644     return ((java.lang.Integer) obj).intValue();
645   }
646
647   /**
648    * Method removePdbids.
649    * 
650    * @param vPdbids
651    * @return true if the object was removed from the collection.
652    */
653   public boolean removePdbids(
654           final jalview.schemabinding.version2.Pdbids vPdbids)
655   {
656     boolean removed = _pdbidsList.remove(vPdbids);
657     return removed;
658   }
659
660   /**
661    * Method removePdbidsAt.
662    * 
663    * @param index
664    * @return the element removed from the collection
665    */
666   public jalview.schemabinding.version2.Pdbids removePdbidsAt(
667           final int index)
668   {
669     java.lang.Object obj = this._pdbidsList.remove(index);
670     return (jalview.schemabinding.version2.Pdbids) obj;
671   }
672
673   /**
674    * Sets the value of field 'colour'.
675    * 
676    * @param colour
677    *          the value of field 'colour'.
678    */
679   public void setColour(final int colour)
680   {
681     this._colour = colour;
682     this._has_colour = true;
683   }
684
685   /**
686    * Sets the value of field 'end'.
687    * 
688    * @param end
689    *          the value of field 'end'.
690    */
691   public void setEnd(final int end)
692   {
693     this._end = end;
694     this._has_end = true;
695   }
696
697   /**
698    * 
699    * 
700    * @param index
701    * @param vFeatures
702    * @throws java.lang.IndexOutOfBoundsException
703    *           if the index given is outside the bounds of the collection
704    */
705   public void setFeatures(final int index,
706           final jalview.schemabinding.version2.Features vFeatures)
707           throws java.lang.IndexOutOfBoundsException
708   {
709     // check bounds for index
710     if (index < 0 || index >= this._featuresList.size())
711     {
712         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
713                   "setFeatures",
714                   Integer.valueOf(index).toString(),
715                   Integer.valueOf((this._featuresList.size() - 1)).toString()
716         })); 
717     }
718
719     this._featuresList.set(index, vFeatures);
720   }
721
722   /**
723    * 
724    * 
725    * @param vFeaturesArray
726    */
727   public void setFeatures(
728           final jalview.schemabinding.version2.Features[] vFeaturesArray)
729   {
730     // -- copy array
731     _featuresList.clear();
732
733     for (int i = 0; i < vFeaturesArray.length; i++)
734     {
735       this._featuresList.add(vFeaturesArray[i]);
736     }
737   }
738
739   /**
740    * Sets the value of field 'hidden'.
741    * 
742    * @param hidden
743    *          the value of field 'hidden'.
744    */
745   public void setHidden(final boolean hidden)
746   {
747     this._hidden = hidden;
748     this._has_hidden = true;
749   }
750
751   /**
752    * 
753    * 
754    * @param index
755    * @param vHiddenSequences
756    * @throws java.lang.IndexOutOfBoundsException
757    *           if the index given is outside the bounds of the collection
758    */
759   public void setHiddenSequences(final int index, final int vHiddenSequences)
760           throws java.lang.IndexOutOfBoundsException
761   {
762     // check bounds for index
763     if (index < 0 || index >= this._hiddenSequencesList.size())
764     {
765         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
766                           "setHiddenSequences",
767                           Integer.valueOf(index).toString(),
768                           Integer.valueOf((this._hiddenSequencesList.size() - 1)).toString()
769           })); 
770     }
771
772     this._hiddenSequencesList.set(index, new java.lang.Integer(
773             vHiddenSequences));
774   }
775
776   /**
777    * 
778    * 
779    * @param vHiddenSequencesArray
780    */
781   public void setHiddenSequences(final int[] vHiddenSequencesArray)
782   {
783     // -- copy array
784     _hiddenSequencesList.clear();
785
786     for (int i = 0; i < vHiddenSequencesArray.length; i++)
787     {
788       this._hiddenSequencesList.add(new java.lang.Integer(
789               vHiddenSequencesArray[i]));
790     }
791   }
792
793   /**
794    * Sets the value of field 'id'.
795    * 
796    * @param id
797    *          the value of field 'id'.
798    */
799   public void setId(final java.lang.String id)
800   {
801     this._id = id;
802   }
803
804   /**
805    * 
806    * 
807    * @param index
808    * @param vPdbids
809    * @throws java.lang.IndexOutOfBoundsException
810    *           if the index given is outside the bounds of the collection
811    */
812   public void setPdbids(final int index,
813           final jalview.schemabinding.version2.Pdbids vPdbids)
814           throws java.lang.IndexOutOfBoundsException
815   {
816     // check bounds for index
817     if (index < 0 || index >= this._pdbidsList.size())
818     {
819         throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
820                   "setPdbids",
821                   Integer.valueOf(index).toString(),
822                   Integer.valueOf((this._pdbidsList.size() - 1)).toString()
823         })); 
824     }
825
826     this._pdbidsList.set(index, vPdbids);
827   }
828
829   /**
830    * 
831    * 
832    * @param vPdbidsArray
833    */
834   public void setPdbids(
835           final jalview.schemabinding.version2.Pdbids[] vPdbidsArray)
836   {
837     // -- copy array
838     _pdbidsList.clear();
839
840     for (int i = 0; i < vPdbidsArray.length; i++)
841     {
842       this._pdbidsList.add(vPdbidsArray[i]);
843     }
844   }
845
846   /**
847    * Sets the value of field 'start'.
848    * 
849    * @param start
850    *          the value of field 'start'.
851    */
852   public void setStart(final int start)
853   {
854     this._start = start;
855     this._has_start = true;
856   }
857
858   /**
859    * Method unmarshal.
860    * 
861    * @param reader
862    * @throws org.exolab.castor.xml.MarshalException
863    *           if object is null or if any SAXException is thrown during
864    *           marshaling
865    * @throws org.exolab.castor.xml.ValidationException
866    *           if this object is an invalid instance according to the schema
867    * @return the unmarshaled jalview.schemabinding.version2.JSeq
868    */
869   public static jalview.schemabinding.version2.JSeq unmarshal(
870           final java.io.Reader reader)
871           throws org.exolab.castor.xml.MarshalException,
872           org.exolab.castor.xml.ValidationException
873   {
874     return (jalview.schemabinding.version2.JSeq) Unmarshaller.unmarshal(
875             jalview.schemabinding.version2.JSeq.class, reader);
876   }
877
878   /**
879    * 
880    * 
881    * @throws org.exolab.castor.xml.ValidationException
882    *           if this object is an invalid instance according to the schema
883    */
884   public void validate() throws org.exolab.castor.xml.ValidationException
885   {
886     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
887     validator.validate(this);
888   }
889
890 }