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