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