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