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