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