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