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