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