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