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