JAL-1432 updated copyright notices
[jalview.git] / src / jalview / schemabinding / version2 / VAMSAS.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 of the License, or (at your option) any later version.
10  *  
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  * The Jalview Authors are detailed in the 'AUTHORS' file.
18  */
19 package jalview.schemabinding.version2;
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 _treeList.
42    */
43   private java.util.Vector _treeList;
44
45   /**
46    * Field _sequenceSetList.
47    */
48   private java.util.Vector _sequenceSetList;
49
50   // ----------------/
51   // - Constructors -/
52   // ----------------/
53
54   public VAMSAS()
55   {
56     super();
57     this._treeList = new java.util.Vector();
58     this._sequenceSetList = new java.util.Vector();
59   }
60
61   // -----------/
62   // - Methods -/
63   // -----------/
64
65   /**
66    * 
67    * 
68    * @param vSequenceSet
69    * @throws java.lang.IndexOutOfBoundsException
70    *           if the index given is outside the bounds of the collection
71    */
72   public void addSequenceSet(
73           final jalview.schemabinding.version2.SequenceSet vSequenceSet)
74           throws java.lang.IndexOutOfBoundsException
75   {
76     this._sequenceSetList.addElement(vSequenceSet);
77   }
78
79   /**
80    * 
81    * 
82    * @param index
83    * @param vSequenceSet
84    * @throws java.lang.IndexOutOfBoundsException
85    *           if the index given is outside the bounds of the collection
86    */
87   public void addSequenceSet(final int index,
88           final jalview.schemabinding.version2.SequenceSet vSequenceSet)
89           throws java.lang.IndexOutOfBoundsException
90   {
91     this._sequenceSetList.add(index, vSequenceSet);
92   }
93
94   /**
95    * 
96    * 
97    * @param vTree
98    * @throws java.lang.IndexOutOfBoundsException
99    *           if the index given is outside the bounds of the collection
100    */
101   public void addTree(final java.lang.String vTree)
102           throws java.lang.IndexOutOfBoundsException
103   {
104     this._treeList.addElement(vTree);
105   }
106
107   /**
108    * 
109    * 
110    * @param index
111    * @param vTree
112    * @throws java.lang.IndexOutOfBoundsException
113    *           if the index given is outside the bounds of the collection
114    */
115   public void addTree(final int index, final java.lang.String vTree)
116           throws java.lang.IndexOutOfBoundsException
117   {
118     this._treeList.add(index, vTree);
119   }
120
121   /**
122    * Method enumerateSequenceSet.
123    * 
124    * @return an Enumeration over all jalview.schemabinding.version2.SequenceSet
125    *         elements
126    */
127   public java.util.Enumeration enumerateSequenceSet()
128   {
129     return this._sequenceSetList.elements();
130   }
131
132   /**
133    * Method enumerateTree.
134    * 
135    * @return an Enumeration over all java.lang.String elements
136    */
137   public java.util.Enumeration enumerateTree()
138   {
139     return this._treeList.elements();
140   }
141
142   /**
143    * Method getSequenceSet.
144    * 
145    * @param index
146    * @throws java.lang.IndexOutOfBoundsException
147    *           if the index given is outside the bounds of the collection
148    * @return the value of the jalview.schemabinding.version2.SequenceSet at the
149    *         given index
150    */
151   public jalview.schemabinding.version2.SequenceSet getSequenceSet(
152           final int index) throws java.lang.IndexOutOfBoundsException
153   {
154     // check bounds for index
155     if (index < 0 || index >= this._sequenceSetList.size())
156     {
157       throw new IndexOutOfBoundsException("getSequenceSet: Index value '"
158               + index + "' not in range [0.."
159               + (this._sequenceSetList.size() - 1) + "]");
160     }
161
162     return (jalview.schemabinding.version2.SequenceSet) _sequenceSetList
163             .get(index);
164   }
165
166   /**
167    * Method getSequenceSet.Returns the contents of the collection in an Array.
168    * <p>
169    * Note: Just in case the collection contents are changing in another thread,
170    * we pass a 0-length Array of the correct type into the API call. This way we
171    * <i>know</i> that the Array returned is of exactly the correct length.
172    * 
173    * @return this collection as an Array
174    */
175   public jalview.schemabinding.version2.SequenceSet[] getSequenceSet()
176   {
177     jalview.schemabinding.version2.SequenceSet[] array = new jalview.schemabinding.version2.SequenceSet[0];
178     return (jalview.schemabinding.version2.SequenceSet[]) this._sequenceSetList
179             .toArray(array);
180   }
181
182   /**
183    * Method getSequenceSetCount.
184    * 
185    * @return the size of this collection
186    */
187   public int getSequenceSetCount()
188   {
189     return this._sequenceSetList.size();
190   }
191
192   /**
193    * Method getTree.
194    * 
195    * @param index
196    * @throws java.lang.IndexOutOfBoundsException
197    *           if the index given is outside the bounds of the collection
198    * @return the value of the java.lang.String at the given index
199    */
200   public java.lang.String getTree(final int index)
201           throws java.lang.IndexOutOfBoundsException
202   {
203     // check bounds for index
204     if (index < 0 || index >= this._treeList.size())
205     {
206       throw new IndexOutOfBoundsException("getTree: Index value '" + index
207               + "' not in range [0.." + (this._treeList.size() - 1) + "]");
208     }
209
210     return (java.lang.String) _treeList.get(index);
211   }
212
213   /**
214    * Method getTree.Returns the contents of the collection in an Array.
215    * <p>
216    * Note: Just in case the collection contents are changing in another thread,
217    * we pass a 0-length Array of the correct type into the API call. This way we
218    * <i>know</i> that the Array returned is of exactly the correct length.
219    * 
220    * @return this collection as an Array
221    */
222   public java.lang.String[] getTree()
223   {
224     java.lang.String[] array = new java.lang.String[0];
225     return (java.lang.String[]) this._treeList.toArray(array);
226   }
227
228   /**
229    * Method getTreeCount.
230    * 
231    * @return the size of this collection
232    */
233   public int getTreeCount()
234   {
235     return this._treeList.size();
236   }
237
238   /**
239    * Method isValid.
240    * 
241    * @return true if this object is valid according to the schema
242    */
243   public boolean isValid()
244   {
245     try
246     {
247       validate();
248     } catch (org.exolab.castor.xml.ValidationException vex)
249     {
250       return false;
251     }
252     return true;
253   }
254
255   /**
256    * 
257    * 
258    * @param out
259    * @throws org.exolab.castor.xml.MarshalException
260    *           if object is null or if any SAXException is thrown during
261    *           marshaling
262    * @throws org.exolab.castor.xml.ValidationException
263    *           if this object is an invalid instance according to the schema
264    */
265   public void marshal(final java.io.Writer out)
266           throws org.exolab.castor.xml.MarshalException,
267           org.exolab.castor.xml.ValidationException
268   {
269     Marshaller.marshal(this, out);
270   }
271
272   /**
273    * 
274    * 
275    * @param handler
276    * @throws java.io.IOException
277    *           if an IOException occurs during marshaling
278    * @throws org.exolab.castor.xml.ValidationException
279    *           if this object is an invalid instance according to the schema
280    * @throws org.exolab.castor.xml.MarshalException
281    *           if object is null or if any SAXException is thrown during
282    *           marshaling
283    */
284   public void marshal(final org.xml.sax.ContentHandler handler)
285           throws java.io.IOException,
286           org.exolab.castor.xml.MarshalException,
287           org.exolab.castor.xml.ValidationException
288   {
289     Marshaller.marshal(this, handler);
290   }
291
292   /**
293      */
294   public void removeAllSequenceSet()
295   {
296     this._sequenceSetList.clear();
297   }
298
299   /**
300      */
301   public void removeAllTree()
302   {
303     this._treeList.clear();
304   }
305
306   /**
307    * Method removeSequenceSet.
308    * 
309    * @param vSequenceSet
310    * @return true if the object was removed from the collection.
311    */
312   public boolean removeSequenceSet(
313           final jalview.schemabinding.version2.SequenceSet vSequenceSet)
314   {
315     boolean removed = _sequenceSetList.remove(vSequenceSet);
316     return removed;
317   }
318
319   /**
320    * Method removeSequenceSetAt.
321    * 
322    * @param index
323    * @return the element removed from the collection
324    */
325   public jalview.schemabinding.version2.SequenceSet removeSequenceSetAt(
326           final int index)
327   {
328     java.lang.Object obj = this._sequenceSetList.remove(index);
329     return (jalview.schemabinding.version2.SequenceSet) obj;
330   }
331
332   /**
333    * Method removeTree.
334    * 
335    * @param vTree
336    * @return true if the object was removed from the collection.
337    */
338   public boolean removeTree(final java.lang.String vTree)
339   {
340     boolean removed = _treeList.remove(vTree);
341     return removed;
342   }
343
344   /**
345    * Method removeTreeAt.
346    * 
347    * @param index
348    * @return the element removed from the collection
349    */
350   public java.lang.String removeTreeAt(final int index)
351   {
352     java.lang.Object obj = this._treeList.remove(index);
353     return (java.lang.String) obj;
354   }
355
356   /**
357    * 
358    * 
359    * @param index
360    * @param vSequenceSet
361    * @throws java.lang.IndexOutOfBoundsException
362    *           if the index given is outside the bounds of the collection
363    */
364   public void setSequenceSet(final int index,
365           final jalview.schemabinding.version2.SequenceSet vSequenceSet)
366           throws java.lang.IndexOutOfBoundsException
367   {
368     // check bounds for index
369     if (index < 0 || index >= this._sequenceSetList.size())
370     {
371       throw new IndexOutOfBoundsException("setSequenceSet: Index value '"
372               + index + "' not in range [0.."
373               + (this._sequenceSetList.size() - 1) + "]");
374     }
375
376     this._sequenceSetList.set(index, vSequenceSet);
377   }
378
379   /**
380    * 
381    * 
382    * @param vSequenceSetArray
383    */
384   public void setSequenceSet(
385           final jalview.schemabinding.version2.SequenceSet[] vSequenceSetArray)
386   {
387     // -- copy array
388     _sequenceSetList.clear();
389
390     for (int i = 0; i < vSequenceSetArray.length; i++)
391     {
392       this._sequenceSetList.add(vSequenceSetArray[i]);
393     }
394   }
395
396   /**
397    * 
398    * 
399    * @param index
400    * @param vTree
401    * @throws java.lang.IndexOutOfBoundsException
402    *           if the index given is outside the bounds of the collection
403    */
404   public void setTree(final int index, final java.lang.String vTree)
405           throws java.lang.IndexOutOfBoundsException
406   {
407     // check bounds for index
408     if (index < 0 || index >= this._treeList.size())
409     {
410       throw new IndexOutOfBoundsException("setTree: Index value '" + index
411               + "' not in range [0.." + (this._treeList.size() - 1) + "]");
412     }
413
414     this._treeList.set(index, vTree);
415   }
416
417   /**
418    * 
419    * 
420    * @param vTreeArray
421    */
422   public void setTree(final java.lang.String[] vTreeArray)
423   {
424     // -- copy array
425     _treeList.clear();
426
427     for (int i = 0; i < vTreeArray.length; i++)
428     {
429       this._treeList.add(vTreeArray[i]);
430     }
431   }
432
433   /**
434    * Method unmarshal.
435    * 
436    * @param reader
437    * @throws org.exolab.castor.xml.MarshalException
438    *           if object is null or if any SAXException is thrown during
439    *           marshaling
440    * @throws org.exolab.castor.xml.ValidationException
441    *           if this object is an invalid instance according to the schema
442    * @return the unmarshaled jalview.schemabinding.version2.VAMSAS
443    */
444   public static jalview.schemabinding.version2.VAMSAS unmarshal(
445           final java.io.Reader reader)
446           throws org.exolab.castor.xml.MarshalException,
447           org.exolab.castor.xml.ValidationException
448   {
449     return (jalview.schemabinding.version2.VAMSAS) Unmarshaller.unmarshal(
450             jalview.schemabinding.version2.VAMSAS.class, reader);
451   }
452
453   /**
454    * 
455    * 
456    * @throws org.exolab.castor.xml.ValidationException
457    *           if this object is an invalid instance according to the schema
458    */
459   public void validate() throws org.exolab.castor.xml.ValidationException
460   {
461     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
462     validator.validate(this);
463   }
464
465 }