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