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