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