2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
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.
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.
21 package jalview.schemabinding.version2;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
31 * Class FeatureSettings.
33 * @version $Revision$ $Date$
35 public class FeatureSettings implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private java.util.Vector _settingList;
50 private java.util.Vector _groupList;
56 public FeatureSettings()
59 this._settingList = new java.util.Vector();
60 this._groupList = new java.util.Vector();
71 * @throws java.lang.IndexOutOfBoundsException
72 * if the index given is outside the bounds of the collection
74 public void addGroup(final jalview.schemabinding.version2.Group vGroup)
75 throws java.lang.IndexOutOfBoundsException
77 this._groupList.addElement(vGroup);
85 * @throws java.lang.IndexOutOfBoundsException
86 * if the index given is outside the bounds of the collection
88 public void addGroup(final int index,
89 final jalview.schemabinding.version2.Group vGroup)
90 throws java.lang.IndexOutOfBoundsException
92 this._groupList.add(index, vGroup);
99 * @throws java.lang.IndexOutOfBoundsException
100 * if the index given is outside the bounds of the collection
102 public void addSetting(
103 final jalview.schemabinding.version2.Setting vSetting)
104 throws java.lang.IndexOutOfBoundsException
106 this._settingList.addElement(vSetting);
114 * @throws java.lang.IndexOutOfBoundsException
115 * if the index given is outside the bounds of the collection
117 public void addSetting(final int index,
118 final jalview.schemabinding.version2.Setting vSetting)
119 throws java.lang.IndexOutOfBoundsException
121 this._settingList.add(index, vSetting);
125 * Method enumerateGroup.
127 * @return an Enumeration over all jalview.schemabinding.version2.Group
130 public java.util.Enumeration enumerateGroup()
132 return this._groupList.elements();
136 * Method enumerateSetting.
138 * @return an Enumeration over all jalview.schemabinding.version2.Setting
141 public java.util.Enumeration enumerateSetting()
143 return this._settingList.elements();
150 * @throws java.lang.IndexOutOfBoundsException
151 * if the index given is outside the bounds of the collection
152 * @return the value of the jalview.schemabinding.version2.Group at the given
155 public jalview.schemabinding.version2.Group getGroup(final int index)
156 throws java.lang.IndexOutOfBoundsException
158 // check bounds for index
159 if (index < 0 || index >= this._groupList.size())
161 throw new IndexOutOfBoundsException("getGroup: Index value '" + index
162 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
165 return (jalview.schemabinding.version2.Group) _groupList.get(index);
169 * Method getGroup.Returns the contents of the collection in an Array.
171 * Note: Just in case the collection contents are changing in another thread,
172 * we pass a 0-length Array of the correct type into the API call. This way we
173 * <i>know</i> that the Array returned is of exactly the correct length.
175 * @return this collection as an Array
177 public jalview.schemabinding.version2.Group[] getGroup()
179 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
180 return (jalview.schemabinding.version2.Group[]) this._groupList
185 * Method getGroupCount.
187 * @return the size of this collection
189 public int getGroupCount()
191 return this._groupList.size();
198 * @throws java.lang.IndexOutOfBoundsException
199 * if the index given is outside the bounds of the collection
200 * @return the value of the jalview.schemabinding.version2.Setting at the
203 public jalview.schemabinding.version2.Setting getSetting(final int index)
204 throws java.lang.IndexOutOfBoundsException
206 // check bounds for index
207 if (index < 0 || index >= this._settingList.size())
209 throw new IndexOutOfBoundsException("getSetting: Index value '"
210 + index + "' not in range [0.."
211 + (this._settingList.size() - 1) + "]");
214 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
218 * Method getSetting.Returns the contents of the collection in an Array.
220 * Note: Just in case the collection contents are changing in another thread,
221 * we pass a 0-length Array of the correct type into the API call. This way we
222 * <i>know</i> that the Array returned is of exactly the correct length.
224 * @return this collection as an Array
226 public jalview.schemabinding.version2.Setting[] getSetting()
228 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
229 return (jalview.schemabinding.version2.Setting[]) this._settingList
234 * Method getSettingCount.
236 * @return the size of this collection
238 public int getSettingCount()
240 return this._settingList.size();
246 * @return true if this object is valid according to the schema
248 public boolean isValid()
253 } catch (org.exolab.castor.xml.ValidationException vex)
264 * @throws org.exolab.castor.xml.MarshalException
265 * if object is null or if any SAXException is thrown during
267 * @throws org.exolab.castor.xml.ValidationException
268 * if this object is an invalid instance according to the schema
270 public void marshal(final java.io.Writer out)
271 throws org.exolab.castor.xml.MarshalException,
272 org.exolab.castor.xml.ValidationException
274 Marshaller.marshal(this, out);
281 * @throws java.io.IOException
282 * if an IOException occurs during marshaling
283 * @throws org.exolab.castor.xml.ValidationException
284 * if this object is an invalid instance according to the schema
285 * @throws org.exolab.castor.xml.MarshalException
286 * if object is null or if any SAXException is thrown during
289 public void marshal(final org.xml.sax.ContentHandler handler)
290 throws java.io.IOException,
291 org.exolab.castor.xml.MarshalException,
292 org.exolab.castor.xml.ValidationException
294 Marshaller.marshal(this, handler);
299 public void removeAllGroup()
301 this._groupList.clear();
306 public void removeAllSetting()
308 this._settingList.clear();
312 * Method removeGroup.
315 * @return true if the object was removed from the collection.
317 public boolean removeGroup(
318 final jalview.schemabinding.version2.Group vGroup)
320 boolean removed = _groupList.remove(vGroup);
325 * Method removeGroupAt.
328 * @return the element removed from the collection
330 public jalview.schemabinding.version2.Group removeGroupAt(final int index)
332 java.lang.Object obj = this._groupList.remove(index);
333 return (jalview.schemabinding.version2.Group) obj;
337 * Method removeSetting.
340 * @return true if the object was removed from the collection.
342 public boolean removeSetting(
343 final jalview.schemabinding.version2.Setting vSetting)
345 boolean removed = _settingList.remove(vSetting);
350 * Method removeSettingAt.
353 * @return the element removed from the collection
355 public jalview.schemabinding.version2.Setting removeSettingAt(
358 java.lang.Object obj = this._settingList.remove(index);
359 return (jalview.schemabinding.version2.Setting) obj;
367 * @throws java.lang.IndexOutOfBoundsException
368 * if the index given is outside the bounds of the collection
370 public void setGroup(final int index,
371 final jalview.schemabinding.version2.Group vGroup)
372 throws java.lang.IndexOutOfBoundsException
374 // check bounds for index
375 if (index < 0 || index >= this._groupList.size())
377 throw new IndexOutOfBoundsException("setGroup: Index value '" + index
378 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
381 this._groupList.set(index, vGroup);
389 public void setGroup(
390 final jalview.schemabinding.version2.Group[] vGroupArray)
395 for (int i = 0; i < vGroupArray.length; i++)
397 this._groupList.add(vGroupArray[i]);
406 * @throws java.lang.IndexOutOfBoundsException
407 * if the index given is outside the bounds of the collection
409 public void setSetting(final int index,
410 final jalview.schemabinding.version2.Setting vSetting)
411 throws java.lang.IndexOutOfBoundsException
413 // check bounds for index
414 if (index < 0 || index >= this._settingList.size())
416 throw new IndexOutOfBoundsException("setSetting: Index value '"
417 + index + "' not in range [0.."
418 + (this._settingList.size() - 1) + "]");
421 this._settingList.set(index, vSetting);
427 * @param vSettingArray
429 public void setSetting(
430 final jalview.schemabinding.version2.Setting[] vSettingArray)
433 _settingList.clear();
435 for (int i = 0; i < vSettingArray.length; i++)
437 this._settingList.add(vSettingArray[i]);
445 * @throws org.exolab.castor.xml.MarshalException
446 * if object is null or if any SAXException is thrown during
448 * @throws org.exolab.castor.xml.ValidationException
449 * if this object is an invalid instance according to the schema
450 * @return the unmarshaled jalview.schemabinding.version2.FeatureSettings
452 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
453 final java.io.Reader reader)
454 throws org.exolab.castor.xml.MarshalException,
455 org.exolab.castor.xml.ValidationException
457 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller
459 jalview.schemabinding.version2.FeatureSettings.class,
466 * @throws org.exolab.castor.xml.ValidationException
467 * if this object is an invalid instance according to the schema
469 public void validate() throws org.exolab.castor.xml.ValidationException
471 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
472 validator.validate(this);