Copyright test
[jalview.git] / src / jalview / binding / SequenceSet.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 SequenceSet.
39  * 
40  * @version $Revision$ $Date$
41  */
42 public class SequenceSet implements java.io.Serializable
43 {
44
45   // --------------------------/
46   // - Class/Member Variables -/
47   // --------------------------/
48
49   /**
50    * Field _gapChar.
51    */
52   private java.lang.String _gapChar;
53
54   /**
55    * Field _aligned.
56    */
57   private boolean _aligned;
58
59   /**
60    * keeps track of state for field: _aligned
61    */
62   private boolean _has_aligned;
63
64   /**
65    * Field _sequenceList.
66    */
67   private java.util.Vector _sequenceList;
68
69   /**
70    * Field _annotationList.
71    */
72   private java.util.Vector _annotationList;
73
74   // ----------------/
75   // - Constructors -/
76   // ----------------/
77
78   public SequenceSet()
79   {
80     super();
81     this._sequenceList = new java.util.Vector();
82     this._annotationList = new java.util.Vector();
83   }
84
85   // -----------/
86   // - Methods -/
87   // -----------/
88
89   /**
90    * 
91    * 
92    * @param vAnnotation
93    * @throws java.lang.IndexOutOfBoundsException
94    *           if the index given is outside the bounds of the collection
95    */
96   public void addAnnotation(final jalview.binding.Annotation vAnnotation)
97           throws java.lang.IndexOutOfBoundsException
98   {
99     this._annotationList.addElement(vAnnotation);
100   }
101
102   /**
103    * 
104    * 
105    * @param index
106    * @param vAnnotation
107    * @throws java.lang.IndexOutOfBoundsException
108    *           if the index given is outside the bounds of the collection
109    */
110   public void addAnnotation(final int index,
111           final jalview.binding.Annotation vAnnotation)
112           throws java.lang.IndexOutOfBoundsException
113   {
114     this._annotationList.add(index, vAnnotation);
115   }
116
117   /**
118    * 
119    * 
120    * @param vSequence
121    * @throws java.lang.IndexOutOfBoundsException
122    *           if the index given is outside the bounds of the collection
123    */
124   public void addSequence(final jalview.binding.Sequence vSequence)
125           throws java.lang.IndexOutOfBoundsException
126   {
127     this._sequenceList.addElement(vSequence);
128   }
129
130   /**
131    * 
132    * 
133    * @param index
134    * @param vSequence
135    * @throws java.lang.IndexOutOfBoundsException
136    *           if the index given is outside the bounds of the collection
137    */
138   public void addSequence(final int index,
139           final jalview.binding.Sequence vSequence)
140           throws java.lang.IndexOutOfBoundsException
141   {
142     this._sequenceList.add(index, vSequence);
143   }
144
145   /**
146      */
147   public void deleteAligned()
148   {
149     this._has_aligned = false;
150   }
151
152   /**
153    * Method enumerateAnnotation.
154    * 
155    * @return an Enumeration over all jalview.binding.Annotation elements
156    */
157   public java.util.Enumeration enumerateAnnotation()
158   {
159     return this._annotationList.elements();
160   }
161
162   /**
163    * Method enumerateSequence.
164    * 
165    * @return an Enumeration over all jalview.binding.Sequence elements
166    */
167   public java.util.Enumeration enumerateSequence()
168   {
169     return this._sequenceList.elements();
170   }
171
172   /**
173    * Returns the value of field 'aligned'.
174    * 
175    * @return the value of field 'Aligned'.
176    */
177   public boolean getAligned()
178   {
179     return this._aligned;
180   }
181
182   /**
183    * Method getAnnotation.
184    * 
185    * @param index
186    * @throws java.lang.IndexOutOfBoundsException
187    *           if the index given is outside the bounds of the collection
188    * @return the value of the jalview.binding.Annotation at the given index
189    */
190   public jalview.binding.Annotation getAnnotation(final int index)
191           throws java.lang.IndexOutOfBoundsException
192   {
193     // check bounds for index
194     if (index < 0 || index >= this._annotationList.size())
195     {
196       throw new IndexOutOfBoundsException(
197               "getAnnotation: Index value '" + index + "' not in range [0.."
198                       + (this._annotationList.size() - 1) + "]");
199     }
200
201     return (jalview.binding.Annotation) _annotationList.get(index);
202   }
203
204   /**
205    * Method getAnnotation.Returns the contents of the collection in an Array.
206    * <p>
207    * Note: Just in case the collection contents are changing in another thread,
208    * we pass a 0-length Array of the correct type into the API call. This way we
209    * <i>know</i> that the Array returned is of exactly the correct length.
210    * 
211    * @return this collection as an Array
212    */
213   public jalview.binding.Annotation[] getAnnotation()
214   {
215     jalview.binding.Annotation[] array = new jalview.binding.Annotation[0];
216     return (jalview.binding.Annotation[]) this._annotationList
217             .toArray(array);
218   }
219
220   /**
221    * Method getAnnotationCount.
222    * 
223    * @return the size of this collection
224    */
225   public int getAnnotationCount()
226   {
227     return this._annotationList.size();
228   }
229
230   /**
231    * Returns the value of field 'gapChar'.
232    * 
233    * @return the value of field 'GapChar'.
234    */
235   public java.lang.String getGapChar()
236   {
237     return this._gapChar;
238   }
239
240   /**
241    * Method getSequence.
242    * 
243    * @param index
244    * @throws java.lang.IndexOutOfBoundsException
245    *           if the index given is outside the bounds of the collection
246    * @return the value of the jalview.binding.Sequence at the given index
247    */
248   public jalview.binding.Sequence getSequence(final int index)
249           throws java.lang.IndexOutOfBoundsException
250   {
251     // check bounds for index
252     if (index < 0 || index >= this._sequenceList.size())
253     {
254       throw new IndexOutOfBoundsException(
255               "getSequence: Index value '" + index + "' not in range [0.."
256                       + (this._sequenceList.size() - 1) + "]");
257     }
258
259     return (jalview.binding.Sequence) _sequenceList.get(index);
260   }
261
262   /**
263    * Method getSequence.Returns the contents of the collection in an Array.
264    * <p>
265    * Note: Just in case the collection contents are changing in another thread,
266    * we pass a 0-length Array of the correct type into the API call. This way we
267    * <i>know</i> that the Array returned is of exactly the correct length.
268    * 
269    * @return this collection as an Array
270    */
271   public jalview.binding.Sequence[] getSequence()
272   {
273     jalview.binding.Sequence[] array = new jalview.binding.Sequence[0];
274     return (jalview.binding.Sequence[]) this._sequenceList.toArray(array);
275   }
276
277   /**
278    * Method getSequenceCount.
279    * 
280    * @return the size of this collection
281    */
282   public int getSequenceCount()
283   {
284     return this._sequenceList.size();
285   }
286
287   /**
288    * Method hasAligned.
289    * 
290    * @return true if at least one Aligned has been added
291    */
292   public boolean hasAligned()
293   {
294     return this._has_aligned;
295   }
296
297   /**
298    * Returns the value of field 'aligned'.
299    * 
300    * @return the value of field 'Aligned'.
301    */
302   public boolean isAligned()
303   {
304     return this._aligned;
305   }
306
307   /**
308    * Method isValid.
309    * 
310    * @return true if this object is valid according to the schema
311    */
312   public boolean isValid()
313   {
314     try
315     {
316       validate();
317     } catch (org.exolab.castor.xml.ValidationException vex)
318     {
319       return false;
320     }
321     return true;
322   }
323
324   /**
325    * 
326    * 
327    * @param out
328    * @throws org.exolab.castor.xml.MarshalException
329    *           if object is null or if any SAXException is thrown during
330    *           marshaling
331    * @throws org.exolab.castor.xml.ValidationException
332    *           if this object is an invalid instance according to the schema
333    */
334   public void marshal(final java.io.Writer out)
335           throws org.exolab.castor.xml.MarshalException,
336           org.exolab.castor.xml.ValidationException
337   {
338     Marshaller.marshal(this, out);
339   }
340
341   /**
342    * 
343    * 
344    * @param handler
345    * @throws java.io.IOException
346    *           if an IOException occurs during marshaling
347    * @throws org.exolab.castor.xml.ValidationException
348    *           if this object is an invalid instance according to the schema
349    * @throws org.exolab.castor.xml.MarshalException
350    *           if object is null or if any SAXException is thrown during
351    *           marshaling
352    */
353   public void marshal(final org.xml.sax.ContentHandler handler)
354           throws java.io.IOException,
355           org.exolab.castor.xml.MarshalException,
356           org.exolab.castor.xml.ValidationException
357   {
358     Marshaller.marshal(this, handler);
359   }
360
361   /**
362      */
363   public void removeAllAnnotation()
364   {
365     this._annotationList.clear();
366   }
367
368   /**
369      */
370   public void removeAllSequence()
371   {
372     this._sequenceList.clear();
373   }
374
375   /**
376    * Method removeAnnotation.
377    * 
378    * @param vAnnotation
379    * @return true if the object was removed from the collection.
380    */
381   public boolean removeAnnotation(
382           final jalview.binding.Annotation vAnnotation)
383   {
384     boolean removed = _annotationList.remove(vAnnotation);
385     return removed;
386   }
387
388   /**
389    * Method removeAnnotationAt.
390    * 
391    * @param index
392    * @return the element removed from the collection
393    */
394   public jalview.binding.Annotation removeAnnotationAt(final int index)
395   {
396     java.lang.Object obj = this._annotationList.remove(index);
397     return (jalview.binding.Annotation) obj;
398   }
399
400   /**
401    * Method removeSequence.
402    * 
403    * @param vSequence
404    * @return true if the object was removed from the collection.
405    */
406   public boolean removeSequence(final jalview.binding.Sequence vSequence)
407   {
408     boolean removed = _sequenceList.remove(vSequence);
409     return removed;
410   }
411
412   /**
413    * Method removeSequenceAt.
414    * 
415    * @param index
416    * @return the element removed from the collection
417    */
418   public jalview.binding.Sequence removeSequenceAt(final int index)
419   {
420     java.lang.Object obj = this._sequenceList.remove(index);
421     return (jalview.binding.Sequence) obj;
422   }
423
424   /**
425    * Sets the value of field 'aligned'.
426    * 
427    * @param aligned
428    *          the value of field 'aligned'.
429    */
430   public void setAligned(final boolean aligned)
431   {
432     this._aligned = aligned;
433     this._has_aligned = true;
434   }
435
436   /**
437    * 
438    * 
439    * @param index
440    * @param vAnnotation
441    * @throws java.lang.IndexOutOfBoundsException
442    *           if the index given is outside the bounds of the collection
443    */
444   public void setAnnotation(final int index,
445           final jalview.binding.Annotation vAnnotation)
446           throws java.lang.IndexOutOfBoundsException
447   {
448     // check bounds for index
449     if (index < 0 || index >= this._annotationList.size())
450     {
451       throw new IndexOutOfBoundsException(
452               "setAnnotation: Index value '" + index + "' not in range [0.."
453                       + (this._annotationList.size() - 1) + "]");
454     }
455
456     this._annotationList.set(index, vAnnotation);
457   }
458
459   /**
460    * 
461    * 
462    * @param vAnnotationArray
463    */
464   public void setAnnotation(
465           final jalview.binding.Annotation[] vAnnotationArray)
466   {
467     // -- copy array
468     _annotationList.clear();
469
470     for (int i = 0; i < vAnnotationArray.length; i++)
471     {
472       this._annotationList.add(vAnnotationArray[i]);
473     }
474   }
475
476   /**
477    * Sets the value of field 'gapChar'.
478    * 
479    * @param gapChar
480    *          the value of field 'gapChar'.
481    */
482   public void setGapChar(final java.lang.String gapChar)
483   {
484     this._gapChar = gapChar;
485   }
486
487   /**
488    * 
489    * 
490    * @param index
491    * @param vSequence
492    * @throws java.lang.IndexOutOfBoundsException
493    *           if the index given is outside the bounds of the collection
494    */
495   public void setSequence(final int index,
496           final jalview.binding.Sequence vSequence)
497           throws java.lang.IndexOutOfBoundsException
498   {
499     // check bounds for index
500     if (index < 0 || index >= this._sequenceList.size())
501     {
502       throw new IndexOutOfBoundsException(
503               "setSequence: Index value '" + index + "' not in range [0.."
504                       + (this._sequenceList.size() - 1) + "]");
505     }
506
507     this._sequenceList.set(index, vSequence);
508   }
509
510   /**
511    * 
512    * 
513    * @param vSequenceArray
514    */
515   public void setSequence(final jalview.binding.Sequence[] vSequenceArray)
516   {
517     // -- copy array
518     _sequenceList.clear();
519
520     for (int i = 0; i < vSequenceArray.length; i++)
521     {
522       this._sequenceList.add(vSequenceArray[i]);
523     }
524   }
525
526   /**
527    * Method unmarshal.
528    * 
529    * @param reader
530    * @throws org.exolab.castor.xml.MarshalException
531    *           if object is null or if any SAXException is thrown during
532    *           marshaling
533    * @throws org.exolab.castor.xml.ValidationException
534    *           if this object is an invalid instance according to the schema
535    * @return the unmarshaled jalview.binding.SequenceSet
536    */
537   public static jalview.binding.SequenceSet unmarshal(
538           final java.io.Reader reader)
539           throws org.exolab.castor.xml.MarshalException,
540           org.exolab.castor.xml.ValidationException
541   {
542     return (jalview.binding.SequenceSet) Unmarshaller
543             .unmarshal(jalview.binding.SequenceSet.class, reader);
544   }
545
546   /**
547    * 
548    * 
549    * @throws org.exolab.castor.xml.ValidationException
550    *           if this object is an invalid instance according to the schema
551    */
552   public void validate() throws org.exolab.castor.xml.ValidationException
553   {
554     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
555     validator.validate(this);
556   }
557
558 }