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