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