apply gpl development license
[jalview.git] / src / jalview / binding / VAMSAS.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3  * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.binding;
20
21   //---------------------------------/
22  //- Imported classes and packages -/
23 //---------------------------------/
24
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
27
28 /**
29  * Class VAMSAS.
30  * 
31  * @version $Revision$ $Date$
32  */
33 public class VAMSAS implements java.io.Serializable {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * Field _alignmentList.
42      */
43     private java.util.Vector _alignmentList;
44
45     /**
46      * Field _treeList.
47      */
48     private java.util.Vector _treeList;
49
50     /**
51      * Field _sequenceSetList.
52      */
53     private java.util.Vector _sequenceSetList;
54
55
56       //----------------/
57      //- Constructors -/
58     //----------------/
59
60     public VAMSAS() {
61         super();
62         this._alignmentList = new java.util.Vector();
63         this._treeList = new java.util.Vector();
64         this._sequenceSetList = new java.util.Vector();
65     }
66
67
68       //-----------/
69      //- Methods -/
70     //-----------/
71
72     /**
73      * 
74      * 
75      * @param vAlignment
76      * @throws java.lang.IndexOutOfBoundsException if the index
77      * given is outside the bounds of the collection
78      */
79     public void addAlignment(
80             final Alignment vAlignment)
81     throws java.lang.IndexOutOfBoundsException {
82         this._alignmentList.addElement(vAlignment);
83     }
84
85     /**
86      * 
87      * 
88      * @param index
89      * @param vAlignment
90      * @throws java.lang.IndexOutOfBoundsException if the index
91      * given is outside the bounds of the collection
92      */
93     public void addAlignment(
94             final int index,
95             final Alignment vAlignment)
96     throws java.lang.IndexOutOfBoundsException {
97         this._alignmentList.add(index, vAlignment);
98     }
99
100     /**
101      * 
102      * 
103      * @param vSequenceSet
104      * @throws java.lang.IndexOutOfBoundsException if the index
105      * given is outside the bounds of the collection
106      */
107     public void addSequenceSet(
108             final SequenceSet vSequenceSet)
109     throws java.lang.IndexOutOfBoundsException {
110         this._sequenceSetList.addElement(vSequenceSet);
111     }
112
113     /**
114      * 
115      * 
116      * @param index
117      * @param vSequenceSet
118      * @throws java.lang.IndexOutOfBoundsException if the index
119      * given is outside the bounds of the collection
120      */
121     public void addSequenceSet(
122             final int index,
123             final SequenceSet vSequenceSet)
124     throws java.lang.IndexOutOfBoundsException {
125         this._sequenceSetList.add(index, vSequenceSet);
126     }
127
128     /**
129      * 
130      * 
131      * @param vTree
132      * @throws java.lang.IndexOutOfBoundsException if the index
133      * given is outside the bounds of the collection
134      */
135     public void addTree(
136             final java.lang.String vTree)
137     throws java.lang.IndexOutOfBoundsException {
138         this._treeList.addElement(vTree);
139     }
140
141     /**
142      * 
143      * 
144      * @param index
145      * @param vTree
146      * @throws java.lang.IndexOutOfBoundsException if the index
147      * given is outside the bounds of the collection
148      */
149     public void addTree(
150             final int index,
151             final java.lang.String vTree)
152     throws java.lang.IndexOutOfBoundsException {
153         this._treeList.add(index, vTree);
154     }
155
156     /**
157      * Method enumerateAlignment.
158      * 
159      * @return an Enumeration over all Alignment elements
160      */
161     public java.util.Enumeration enumerateAlignment(
162     ) {
163         return this._alignmentList.elements();
164     }
165
166     /**
167      * Method enumerateSequenceSet.
168      * 
169      * @return an Enumeration over all SequenceSet elements
170      */
171     public java.util.Enumeration enumerateSequenceSet(
172     ) {
173         return this._sequenceSetList.elements();
174     }
175
176     /**
177      * Method enumerateTree.
178      * 
179      * @return an Enumeration over all java.lang.String elements
180      */
181     public java.util.Enumeration enumerateTree(
182     ) {
183         return this._treeList.elements();
184     }
185
186     /**
187      * Method getAlignment.
188      * 
189      * @param index
190      * @throws java.lang.IndexOutOfBoundsException if the index
191      * given is outside the bounds of the collection
192      * @return the value of the Alignment at the given index
193      */
194     public Alignment getAlignment(
195             final int index)
196     throws java.lang.IndexOutOfBoundsException {
197         // check bounds for index
198         if (index < 0 || index >= this._alignmentList.size()) {
199             throw new IndexOutOfBoundsException("getAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
200         }
201         
202         return (Alignment) _alignmentList.get(index);
203     }
204
205     /**
206      * Method getAlignment.Returns the contents of the collection
207      * in an Array.  <p>Note:  Just in case the collection contents
208      * are changing in another thread, we pass a 0-length Array of
209      * the correct type into the API call.  This way we <i>know</i>
210      * that the Array returned is of exactly the correct length.
211      * 
212      * @return this collection as an Array
213      */
214     public Alignment[] getAlignment(
215     ) {
216         Alignment[] array = new Alignment[0];
217         return (Alignment[]) this._alignmentList.toArray(array);
218     }
219
220     /**
221      * Method getAlignmentCount.
222      * 
223      * @return the size of this collection
224      */
225     public int getAlignmentCount(
226     ) {
227         return this._alignmentList.size();
228     }
229
230     /**
231      * Method getSequenceSet.
232      * 
233      * @param index
234      * @throws java.lang.IndexOutOfBoundsException if the index
235      * given is outside the bounds of the collection
236      * @return the value of the SequenceSet at the given index
237      */
238     public SequenceSet getSequenceSet(
239             final int index)
240     throws java.lang.IndexOutOfBoundsException {
241         // check bounds for index
242         if (index < 0 || index >= this._sequenceSetList.size()) {
243             throw new IndexOutOfBoundsException("getSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
244         }
245         
246         return (SequenceSet) _sequenceSetList.get(index);
247     }
248
249     /**
250      * Method getSequenceSet.Returns the contents of the collection
251      * in an Array.  <p>Note:  Just in case the collection contents
252      * are changing in another thread, we pass a 0-length Array of
253      * the correct type into the API call.  This way we <i>know</i>
254      * that the Array returned is of exactly the correct length.
255      * 
256      * @return this collection as an Array
257      */
258     public SequenceSet[] getSequenceSet(
259     ) {
260         SequenceSet[] array = new SequenceSet[0];
261         return (SequenceSet[]) this._sequenceSetList.toArray(array);
262     }
263
264     /**
265      * Method getSequenceSetCount.
266      * 
267      * @return the size of this collection
268      */
269     public int getSequenceSetCount(
270     ) {
271         return this._sequenceSetList.size();
272     }
273
274     /**
275      * Method getTree.
276      * 
277      * @param index
278      * @throws java.lang.IndexOutOfBoundsException if the index
279      * given is outside the bounds of the collection
280      * @return the value of the java.lang.String at the given index
281      */
282     public java.lang.String getTree(
283             final int index)
284     throws java.lang.IndexOutOfBoundsException {
285         // check bounds for index
286         if (index < 0 || index >= this._treeList.size()) {
287             throw new IndexOutOfBoundsException("getTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
288         }
289         
290         return (java.lang.String) _treeList.get(index);
291     }
292
293     /**
294      * Method getTree.Returns the contents of the collection in an
295      * Array.  <p>Note:  Just in case the collection contents are
296      * changing in another thread, we pass a 0-length Array of the
297      * correct type into the API call.  This way we <i>know</i>
298      * that the Array returned is of exactly the correct length.
299      * 
300      * @return this collection as an Array
301      */
302     public java.lang.String[] getTree(
303     ) {
304         java.lang.String[] array = new java.lang.String[0];
305         return (java.lang.String[]) this._treeList.toArray(array);
306     }
307
308     /**
309      * Method getTreeCount.
310      * 
311      * @return the size of this collection
312      */
313     public int getTreeCount(
314     ) {
315         return this._treeList.size();
316     }
317
318     /**
319      * Method isValid.
320      * 
321      * @return true if this object is valid according to the schema
322      */
323     public boolean isValid(
324     ) {
325         try {
326             validate();
327         } catch (org.exolab.castor.xml.ValidationException vex) {
328             return false;
329         }
330         return true;
331     }
332
333     /**
334      * 
335      * 
336      * @param out
337      * @throws org.exolab.castor.xml.MarshalException if object is
338      * null or if any SAXException is thrown during marshaling
339      * @throws org.exolab.castor.xml.ValidationException if this
340      * object is an invalid instance according to the schema
341      */
342     public void marshal(
343             final java.io.Writer out)
344     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
345         Marshaller.marshal(this, out);
346     }
347
348     /**
349      * 
350      * 
351      * @param handler
352      * @throws java.io.IOException if an IOException occurs during
353      * marshaling
354      * @throws org.exolab.castor.xml.ValidationException if this
355      * object is an invalid instance according to the schema
356      * @throws org.exolab.castor.xml.MarshalException if object is
357      * null or if any SAXException is thrown during marshaling
358      */
359     public void marshal(
360             final org.xml.sax.ContentHandler handler)
361     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
362         Marshaller.marshal(this, handler);
363     }
364
365     /**
366      * Method removeAlignment.
367      * 
368      * @param vAlignment
369      * @return true if the object was removed from the collection.
370      */
371     public boolean removeAlignment(
372             final Alignment vAlignment) {
373         boolean removed = _alignmentList.remove(vAlignment);
374         return removed;
375     }
376
377     /**
378      * Method removeAlignmentAt.
379      * 
380      * @param index
381      * @return the element removed from the collection
382      */
383     public Alignment removeAlignmentAt(
384             final int index) {
385         java.lang.Object obj = this._alignmentList.remove(index);
386         return (Alignment) obj;
387     }
388
389     /**
390      */
391     public void removeAllAlignment(
392     ) {
393         this._alignmentList.clear();
394     }
395
396     /**
397      */
398     public void removeAllSequenceSet(
399     ) {
400         this._sequenceSetList.clear();
401     }
402
403     /**
404      */
405     public void removeAllTree(
406     ) {
407         this._treeList.clear();
408     }
409
410     /**
411      * Method removeSequenceSet.
412      * 
413      * @param vSequenceSet
414      * @return true if the object was removed from the collection.
415      */
416     public boolean removeSequenceSet(
417             final SequenceSet vSequenceSet) {
418         boolean removed = _sequenceSetList.remove(vSequenceSet);
419         return removed;
420     }
421
422     /**
423      * Method removeSequenceSetAt.
424      * 
425      * @param index
426      * @return the element removed from the collection
427      */
428     public SequenceSet removeSequenceSetAt(
429             final int index) {
430         java.lang.Object obj = this._sequenceSetList.remove(index);
431         return (SequenceSet) obj;
432     }
433
434     /**
435      * Method removeTree.
436      * 
437      * @param vTree
438      * @return true if the object was removed from the collection.
439      */
440     public boolean removeTree(
441             final java.lang.String vTree) {
442         boolean removed = _treeList.remove(vTree);
443         return removed;
444     }
445
446     /**
447      * Method removeTreeAt.
448      * 
449      * @param index
450      * @return the element removed from the collection
451      */
452     public java.lang.String removeTreeAt(
453             final int index) {
454         java.lang.Object obj = this._treeList.remove(index);
455         return (java.lang.String) obj;
456     }
457
458     /**
459      * 
460      * 
461      * @param index
462      * @param vAlignment
463      * @throws java.lang.IndexOutOfBoundsException if the index
464      * given is outside the bounds of the collection
465      */
466     public void setAlignment(
467             final int index,
468             final Alignment vAlignment)
469     throws java.lang.IndexOutOfBoundsException {
470         // check bounds for index
471         if (index < 0 || index >= this._alignmentList.size()) {
472             throw new IndexOutOfBoundsException("setAlignment: Index value '" + index + "' not in range [0.." + (this._alignmentList.size() - 1) + "]");
473         }
474         
475         this._alignmentList.set(index, vAlignment);
476     }
477
478     /**
479      * 
480      * 
481      * @param vAlignmentArray
482      */
483     public void setAlignment(
484             final Alignment[] vAlignmentArray) {
485         //-- copy array
486         _alignmentList.clear();
487         
488         for (int i = 0; i < vAlignmentArray.length; i++) {
489                 this._alignmentList.add(vAlignmentArray[i]);
490         }
491     }
492
493     /**
494      * 
495      * 
496      * @param index
497      * @param vSequenceSet
498      * @throws java.lang.IndexOutOfBoundsException if the index
499      * given is outside the bounds of the collection
500      */
501     public void setSequenceSet(
502             final int index,
503             final SequenceSet vSequenceSet)
504     throws java.lang.IndexOutOfBoundsException {
505         // check bounds for index
506         if (index < 0 || index >= this._sequenceSetList.size()) {
507             throw new IndexOutOfBoundsException("setSequenceSet: Index value '" + index + "' not in range [0.." + (this._sequenceSetList.size() - 1) + "]");
508         }
509         
510         this._sequenceSetList.set(index, vSequenceSet);
511     }
512
513     /**
514      * 
515      * 
516      * @param vSequenceSetArray
517      */
518     public void setSequenceSet(
519             final SequenceSet[] vSequenceSetArray) {
520         //-- copy array
521         _sequenceSetList.clear();
522         
523         for (int i = 0; i < vSequenceSetArray.length; i++) {
524                 this._sequenceSetList.add(vSequenceSetArray[i]);
525         }
526     }
527
528     /**
529      * 
530      * 
531      * @param index
532      * @param vTree
533      * @throws java.lang.IndexOutOfBoundsException if the index
534      * given is outside the bounds of the collection
535      */
536     public void setTree(
537             final int index,
538             final java.lang.String vTree)
539     throws java.lang.IndexOutOfBoundsException {
540         // check bounds for index
541         if (index < 0 || index >= this._treeList.size()) {
542             throw new IndexOutOfBoundsException("setTree: Index value '" + index + "' not in range [0.." + (this._treeList.size() - 1) + "]");
543         }
544         
545         this._treeList.set(index, vTree);
546     }
547
548     /**
549      * 
550      * 
551      * @param vTreeArray
552      */
553     public void setTree(
554             final java.lang.String[] vTreeArray) {
555         //-- copy array
556         _treeList.clear();
557         
558         for (int i = 0; i < vTreeArray.length; i++) {
559                 this._treeList.add(vTreeArray[i]);
560         }
561     }
562
563     /**
564      * Method unmarshal.
565      * 
566      * @param reader
567      * @throws org.exolab.castor.xml.MarshalException if object is
568      * null or if any SAXException is thrown during marshaling
569      * @throws org.exolab.castor.xml.ValidationException if this
570      * object is an invalid instance according to the schema
571      * @return the unmarshaled jalview.binding.VAMSAS
572      */
573     public static jalview.binding.VAMSAS unmarshal(
574             final java.io.Reader reader)
575     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
576         return (jalview.binding.VAMSAS) Unmarshaller.unmarshal(jalview.binding.VAMSAS.class, reader);
577     }
578
579     /**
580      * 
581      * 
582      * @throws org.exolab.castor.xml.ValidationException if this
583      * object is an invalid instance according to the schema
584      */
585     public void validate(
586     )
587     throws org.exolab.castor.xml.ValidationException {
588         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
589         validator.validate(this);
590     }
591
592 }