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