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