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