2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
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.
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.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.schemabinding.version2;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
28 * Class FeatureSettings.
30 * @version $Revision$ $Date$
32 public class FeatureSettings implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
42 private java.util.Vector _settingList;
47 private java.util.Vector _groupList;
53 public FeatureSettings()
56 this._settingList = new java.util.Vector();
57 this._groupList = new java.util.Vector();
68 * @throws java.lang.IndexOutOfBoundsException
69 * if the index given is outside the bounds of the collection
71 public void addGroup(final jalview.schemabinding.version2.Group vGroup)
72 throws java.lang.IndexOutOfBoundsException
74 this._groupList.addElement(vGroup);
82 * @throws java.lang.IndexOutOfBoundsException
83 * if the index given is outside the bounds of the collection
85 public void addGroup(final int index,
86 final jalview.schemabinding.version2.Group vGroup)
87 throws java.lang.IndexOutOfBoundsException
89 this._groupList.add(index, vGroup);
96 * @throws java.lang.IndexOutOfBoundsException
97 * if the index given is outside the bounds of the collection
99 public void addSetting(
100 final jalview.schemabinding.version2.Setting vSetting)
101 throws java.lang.IndexOutOfBoundsException
103 this._settingList.addElement(vSetting);
111 * @throws java.lang.IndexOutOfBoundsException
112 * if the index given is outside the bounds of the collection
114 public void addSetting(final int index,
115 final jalview.schemabinding.version2.Setting vSetting)
116 throws java.lang.IndexOutOfBoundsException
118 this._settingList.add(index, vSetting);
122 * Method enumerateGroup.
124 * @return an Enumeration over all jalview.schemabinding.version2.Group
127 public java.util.Enumeration enumerateGroup()
129 return this._groupList.elements();
133 * Method enumerateSetting.
135 * @return an Enumeration over all jalview.schemabinding.version2.Setting
138 public java.util.Enumeration enumerateSetting()
140 return this._settingList.elements();
147 * @throws java.lang.IndexOutOfBoundsException
148 * if the index given is outside the bounds of the collection
149 * @return the value of the jalview.schemabinding.version2.Group at the given
152 public jalview.schemabinding.version2.Group getGroup(final int index)
153 throws java.lang.IndexOutOfBoundsException
155 // check bounds for index
156 if (index < 0 || index >= this._groupList.size())
158 throw new IndexOutOfBoundsException("getGroup: Index value '" + index
159 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
162 return (jalview.schemabinding.version2.Group) _groupList.get(index);
166 * Method getGroup.Returns the contents of the collection in an Array.
168 * Note: Just in case the collection contents are changing in another thread,
169 * we pass a 0-length Array of the correct type into the API call. This way we
170 * <i>know</i> that the Array returned is of exactly the correct length.
172 * @return this collection as an Array
174 public jalview.schemabinding.version2.Group[] getGroup()
176 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
177 return (jalview.schemabinding.version2.Group[]) this._groupList
182 * Method getGroupCount.
184 * @return the size of this collection
186 public int getGroupCount()
188 return this._groupList.size();
195 * @throws java.lang.IndexOutOfBoundsException
196 * if the index given is outside the bounds of the collection
197 * @return the value of the jalview.schemabinding.version2.Setting at the
200 public jalview.schemabinding.version2.Setting getSetting(final int index)
201 throws java.lang.IndexOutOfBoundsException
203 // check bounds for index
204 if (index < 0 || index >= this._settingList.size())
206 throw new IndexOutOfBoundsException("getSetting: Index value '"
207 + index + "' not in range [0.."
208 + (this._settingList.size() - 1) + "]");
211 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
215 * Method getSetting.Returns the contents of the collection in an Array.
217 * Note: Just in case the collection contents are changing in another thread,
218 * we pass a 0-length Array of the correct type into the API call. This way we
219 * <i>know</i> that the Array returned is of exactly the correct length.
221 * @return this collection as an Array
223 public jalview.schemabinding.version2.Setting[] getSetting()
225 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
226 return (jalview.schemabinding.version2.Setting[]) this._settingList
231 * Method getSettingCount.
233 * @return the size of this collection
235 public int getSettingCount()
237 return this._settingList.size();
243 * @return true if this object is valid according to the schema
245 public boolean isValid()
250 } catch (org.exolab.castor.xml.ValidationException vex)
261 * @throws org.exolab.castor.xml.MarshalException
262 * if object is null or if any SAXException is thrown during
264 * @throws org.exolab.castor.xml.ValidationException
265 * if this object is an invalid instance according to the schema
267 public void marshal(final java.io.Writer out)
268 throws org.exolab.castor.xml.MarshalException,
269 org.exolab.castor.xml.ValidationException
271 Marshaller.marshal(this, out);
278 * @throws java.io.IOException
279 * if an IOException occurs during marshaling
280 * @throws org.exolab.castor.xml.ValidationException
281 * if this object is an invalid instance according to the schema
282 * @throws org.exolab.castor.xml.MarshalException
283 * if object is null or if any SAXException is thrown during
286 public void marshal(final org.xml.sax.ContentHandler handler)
287 throws java.io.IOException,
288 org.exolab.castor.xml.MarshalException,
289 org.exolab.castor.xml.ValidationException
291 Marshaller.marshal(this, handler);
296 public void removeAllGroup()
298 this._groupList.clear();
303 public void removeAllSetting()
305 this._settingList.clear();
309 * Method removeGroup.
312 * @return true if the object was removed from the collection.
314 public boolean removeGroup(
315 final jalview.schemabinding.version2.Group vGroup)
317 boolean removed = _groupList.remove(vGroup);
322 * Method removeGroupAt.
325 * @return the element removed from the collection
327 public jalview.schemabinding.version2.Group removeGroupAt(final int index)
329 java.lang.Object obj = this._groupList.remove(index);
330 return (jalview.schemabinding.version2.Group) obj;
334 * Method removeSetting.
337 * @return true if the object was removed from the collection.
339 public boolean removeSetting(
340 final jalview.schemabinding.version2.Setting vSetting)
342 boolean removed = _settingList.remove(vSetting);
347 * Method removeSettingAt.
350 * @return the element removed from the collection
352 public jalview.schemabinding.version2.Setting removeSettingAt(
355 java.lang.Object obj = this._settingList.remove(index);
356 return (jalview.schemabinding.version2.Setting) obj;
364 * @throws java.lang.IndexOutOfBoundsException
365 * if the index given is outside the bounds of the collection
367 public void setGroup(final int index,
368 final jalview.schemabinding.version2.Group vGroup)
369 throws java.lang.IndexOutOfBoundsException
371 // check bounds for index
372 if (index < 0 || index >= this._groupList.size())
374 throw new IndexOutOfBoundsException("setGroup: Index value '" + index
375 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
378 this._groupList.set(index, vGroup);
386 public void setGroup(
387 final jalview.schemabinding.version2.Group[] vGroupArray)
392 for (int i = 0; i < vGroupArray.length; i++)
394 this._groupList.add(vGroupArray[i]);
403 * @throws java.lang.IndexOutOfBoundsException
404 * if the index given is outside the bounds of the collection
406 public void setSetting(final int index,
407 final jalview.schemabinding.version2.Setting vSetting)
408 throws java.lang.IndexOutOfBoundsException
410 // check bounds for index
411 if (index < 0 || index >= this._settingList.size())
413 throw new IndexOutOfBoundsException("setSetting: Index value '"
414 + index + "' not in range [0.."
415 + (this._settingList.size() - 1) + "]");
418 this._settingList.set(index, vSetting);
424 * @param vSettingArray
426 public void setSetting(
427 final jalview.schemabinding.version2.Setting[] vSettingArray)
430 _settingList.clear();
432 for (int i = 0; i < vSettingArray.length; i++)
434 this._settingList.add(vSettingArray[i]);
442 * @throws org.exolab.castor.xml.MarshalException
443 * if object is null or if any SAXException is thrown during
445 * @throws org.exolab.castor.xml.ValidationException
446 * if this object is an invalid instance according to the schema
447 * @return the unmarshaled jalview.schemabinding.version2.FeatureSettings
449 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
450 final java.io.Reader reader)
451 throws org.exolab.castor.xml.MarshalException,
452 org.exolab.castor.xml.ValidationException
454 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller
456 jalview.schemabinding.version2.FeatureSettings.class,
463 * @throws org.exolab.castor.xml.ValidationException
464 * if this object is an invalid instance according to the schema
466 public void validate() throws org.exolab.castor.xml.ValidationException
468 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
469 validator.validate(this);