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