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