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