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