2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 package jalview.schemabinding.version2;
21 //---------------------------------/
22 //- Imported classes and packages -/
23 //---------------------------------/
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
29 * Class FeatureSettings.
31 * @version $Revision$ $Date$
33 public class FeatureSettings implements java.io.Serializable
36 // --------------------------/
37 // - Class/Member Variables -/
38 // --------------------------/
43 private java.util.Vector _settingList;
48 private java.util.Vector _groupList;
54 public FeatureSettings()
57 this._settingList = new java.util.Vector();
58 this._groupList = new java.util.Vector();
69 * @throws java.lang.IndexOutOfBoundsException
70 * if the index given is outside the bounds of the collection
72 public void addGroup(final jalview.schemabinding.version2.Group vGroup)
73 throws java.lang.IndexOutOfBoundsException
75 this._groupList.addElement(vGroup);
83 * @throws java.lang.IndexOutOfBoundsException
84 * if the index given is outside the bounds of the collection
86 public void addGroup(final int index,
87 final jalview.schemabinding.version2.Group vGroup)
88 throws java.lang.IndexOutOfBoundsException
90 this._groupList.add(index, vGroup);
97 * @throws java.lang.IndexOutOfBoundsException
98 * if the index given is outside the bounds of the collection
100 public void addSetting(
101 final jalview.schemabinding.version2.Setting vSetting)
102 throws java.lang.IndexOutOfBoundsException
104 this._settingList.addElement(vSetting);
112 * @throws java.lang.IndexOutOfBoundsException
113 * if the index given is outside the bounds of the collection
115 public void addSetting(final int index,
116 final jalview.schemabinding.version2.Setting vSetting)
117 throws java.lang.IndexOutOfBoundsException
119 this._settingList.add(index, vSetting);
123 * Method enumerateGroup.
125 * @return an Enumeration over all jalview.schemabinding.version2.Group
128 public java.util.Enumeration enumerateGroup()
130 return this._groupList.elements();
134 * Method enumerateSetting.
136 * @return an Enumeration over all jalview.schemabinding.version2.Setting
139 public java.util.Enumeration enumerateSetting()
141 return this._settingList.elements();
148 * @throws java.lang.IndexOutOfBoundsException
149 * if the index given is outside the bounds of the collection
150 * @return the value of the jalview.schemabinding.version2.Group at the given
153 public jalview.schemabinding.version2.Group getGroup(final int index)
154 throws java.lang.IndexOutOfBoundsException
156 // check bounds for index
157 if (index < 0 || index >= this._groupList.size())
159 throw new IndexOutOfBoundsException("getGroup: Index value '" + index
160 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
163 return (jalview.schemabinding.version2.Group) _groupList.get(index);
167 * Method getGroup.Returns the contents of the collection in an Array.
169 * Note: Just in case the collection contents are changing in another thread,
170 * we pass a 0-length Array of the correct type into the API call. This way we
171 * <i>know</i> that the Array returned is of exactly the correct length.
173 * @return this collection as an Array
175 public jalview.schemabinding.version2.Group[] getGroup()
177 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
178 return (jalview.schemabinding.version2.Group[]) this._groupList
183 * Method getGroupCount.
185 * @return the size of this collection
187 public int getGroupCount()
189 return this._groupList.size();
196 * @throws java.lang.IndexOutOfBoundsException
197 * if the index given is outside the bounds of the collection
198 * @return the value of the jalview.schemabinding.version2.Setting at the
201 public jalview.schemabinding.version2.Setting getSetting(final int index)
202 throws java.lang.IndexOutOfBoundsException
204 // check bounds for index
205 if (index < 0 || index >= this._settingList.size())
207 throw new IndexOutOfBoundsException("getSetting: Index value '"
208 + index + "' not in range [0.."
209 + (this._settingList.size() - 1) + "]");
212 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
216 * Method getSetting.Returns the contents of the collection in an Array.
218 * Note: Just in case the collection contents are changing in another thread,
219 * we pass a 0-length Array of the correct type into the API call. This way we
220 * <i>know</i> that the Array returned is of exactly the correct length.
222 * @return this collection as an Array
224 public jalview.schemabinding.version2.Setting[] getSetting()
226 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
227 return (jalview.schemabinding.version2.Setting[]) this._settingList
232 * Method getSettingCount.
234 * @return the size of this collection
236 public int getSettingCount()
238 return this._settingList.size();
244 * @return true if this object is valid according to the schema
246 public boolean isValid()
251 } catch (org.exolab.castor.xml.ValidationException vex)
262 * @throws org.exolab.castor.xml.MarshalException
263 * if object is null or if any SAXException is thrown during
265 * @throws org.exolab.castor.xml.ValidationException
266 * if this object is an invalid instance according to the schema
268 public void marshal(final java.io.Writer out)
269 throws org.exolab.castor.xml.MarshalException,
270 org.exolab.castor.xml.ValidationException
272 Marshaller.marshal(this, out);
279 * @throws java.io.IOException
280 * if an IOException occurs during marshaling
281 * @throws org.exolab.castor.xml.ValidationException
282 * if this object is an invalid instance according to the schema
283 * @throws org.exolab.castor.xml.MarshalException
284 * if object is null or if any SAXException is thrown during
287 public void marshal(final org.xml.sax.ContentHandler handler)
288 throws java.io.IOException,
289 org.exolab.castor.xml.MarshalException,
290 org.exolab.castor.xml.ValidationException
292 Marshaller.marshal(this, handler);
297 public void removeAllGroup()
299 this._groupList.clear();
304 public void removeAllSetting()
306 this._settingList.clear();
310 * Method removeGroup.
313 * @return true if the object was removed from the collection.
315 public boolean removeGroup(
316 final jalview.schemabinding.version2.Group vGroup)
318 boolean removed = _groupList.remove(vGroup);
323 * Method removeGroupAt.
326 * @return the element removed from the collection
328 public jalview.schemabinding.version2.Group removeGroupAt(final int index)
330 java.lang.Object obj = this._groupList.remove(index);
331 return (jalview.schemabinding.version2.Group) obj;
335 * Method removeSetting.
338 * @return true if the object was removed from the collection.
340 public boolean removeSetting(
341 final jalview.schemabinding.version2.Setting vSetting)
343 boolean removed = _settingList.remove(vSetting);
348 * Method removeSettingAt.
351 * @return the element removed from the collection
353 public jalview.schemabinding.version2.Setting removeSettingAt(
356 java.lang.Object obj = this._settingList.remove(index);
357 return (jalview.schemabinding.version2.Setting) obj;
365 * @throws java.lang.IndexOutOfBoundsException
366 * if the index given is outside the bounds of the collection
368 public void setGroup(final int index,
369 final jalview.schemabinding.version2.Group vGroup)
370 throws java.lang.IndexOutOfBoundsException
372 // check bounds for index
373 if (index < 0 || index >= this._groupList.size())
375 throw new IndexOutOfBoundsException("setGroup: Index value '" + index
376 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
379 this._groupList.set(index, vGroup);
387 public void setGroup(
388 final jalview.schemabinding.version2.Group[] vGroupArray)
393 for (int i = 0; i < vGroupArray.length; i++)
395 this._groupList.add(vGroupArray[i]);
404 * @throws java.lang.IndexOutOfBoundsException
405 * if the index given is outside the bounds of the collection
407 public void setSetting(final int index,
408 final jalview.schemabinding.version2.Setting vSetting)
409 throws java.lang.IndexOutOfBoundsException
411 // check bounds for index
412 if (index < 0 || index >= this._settingList.size())
414 throw new IndexOutOfBoundsException("setSetting: Index value '"
415 + index + "' not in range [0.."
416 + (this._settingList.size() - 1) + "]");
419 this._settingList.set(index, vSetting);
425 * @param vSettingArray
427 public void setSetting(
428 final jalview.schemabinding.version2.Setting[] vSettingArray)
431 _settingList.clear();
433 for (int i = 0; i < vSettingArray.length; i++)
435 this._settingList.add(vSettingArray[i]);
443 * @throws org.exolab.castor.xml.MarshalException
444 * if object is null or if any SAXException is thrown during
446 * @throws org.exolab.castor.xml.ValidationException
447 * if this object is an invalid instance according to the schema
448 * @return the unmarshaled jalview.schemabinding.version2.FeatureSettings
450 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
451 final java.io.Reader reader)
452 throws org.exolab.castor.xml.MarshalException,
453 org.exolab.castor.xml.ValidationException
455 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller
457 jalview.schemabinding.version2.FeatureSettings.class,
464 * @throws org.exolab.castor.xml.ValidationException
465 * if this object is an invalid instance according to the schema
467 public void validate() throws org.exolab.castor.xml.ValidationException
469 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
470 validator.validate(this);