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