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