2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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 jalview.util.MessageManager;
29 import org.exolab.castor.xml.Marshaller;
30 import org.exolab.castor.xml.Unmarshaller;
33 * Class FeatureSettings.
35 * @version $Revision$ $Date$
37 public class FeatureSettings implements java.io.Serializable
40 // --------------------------/
41 // - Class/Member Variables -/
42 // --------------------------/
47 private java.util.Vector _settingList;
52 private java.util.Vector _groupList;
58 public FeatureSettings()
61 this._settingList = new java.util.Vector();
62 this._groupList = new java.util.Vector();
73 * @throws java.lang.IndexOutOfBoundsException
74 * if the index given is outside the bounds of the collection
76 public void addGroup(final jalview.schemabinding.version2.Group vGroup)
77 throws java.lang.IndexOutOfBoundsException
79 this._groupList.addElement(vGroup);
87 * @throws java.lang.IndexOutOfBoundsException
88 * if the index given is outside the bounds of the collection
90 public void addGroup(final int index,
91 final jalview.schemabinding.version2.Group vGroup)
92 throws java.lang.IndexOutOfBoundsException
94 this._groupList.add(index, vGroup);
101 * @throws java.lang.IndexOutOfBoundsException
102 * if the index given is outside the bounds of the collection
104 public void addSetting(
105 final jalview.schemabinding.version2.Setting vSetting)
106 throws java.lang.IndexOutOfBoundsException
108 this._settingList.addElement(vSetting);
116 * @throws java.lang.IndexOutOfBoundsException
117 * if the index given is outside the bounds of the collection
119 public void addSetting(final int index,
120 final jalview.schemabinding.version2.Setting vSetting)
121 throws java.lang.IndexOutOfBoundsException
123 this._settingList.add(index, vSetting);
127 * Method enumerateGroup.
129 * @return an Enumeration over all jalview.schemabinding.version2.Group
132 public java.util.Enumeration enumerateGroup()
134 return this._groupList.elements();
138 * Method enumerateSetting.
140 * @return an Enumeration over all jalview.schemabinding.version2.Setting
143 public java.util.Enumeration enumerateSetting()
145 return this._settingList.elements();
152 * @throws java.lang.IndexOutOfBoundsException
153 * if the index given is outside the bounds of the collection
154 * @return the value of the jalview.schemabinding.version2.Group at the given
157 public jalview.schemabinding.version2.Group getGroup(final int index)
158 throws java.lang.IndexOutOfBoundsException
160 // check bounds for index
161 if (index < 0 || index >= this._groupList.size())
163 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
165 Integer.valueOf(index).toString(),
166 Integer.valueOf((this._groupList.size() - 1)).toString()
170 return (jalview.schemabinding.version2.Group) _groupList.get(index);
174 * Method getGroup.Returns the contents of the collection in an Array.
176 * Note: Just in case the collection contents are changing in another thread,
177 * we pass a 0-length Array of the correct type into the API call. This way we
178 * <i>know</i> that the Array returned is of exactly the correct length.
180 * @return this collection as an Array
182 public jalview.schemabinding.version2.Group[] getGroup()
184 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
185 return (jalview.schemabinding.version2.Group[]) this._groupList
190 * Method getGroupCount.
192 * @return the size of this collection
194 public int getGroupCount()
196 return this._groupList.size();
203 * @throws java.lang.IndexOutOfBoundsException
204 * if the index given is outside the bounds of the collection
205 * @return the value of the jalview.schemabinding.version2.Setting at the
208 public jalview.schemabinding.version2.Setting getSetting(final int index)
209 throws java.lang.IndexOutOfBoundsException
211 // check bounds for index
212 if (index < 0 || index >= this._settingList.size())
214 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
216 Integer.valueOf(index).toString(),
217 Integer.valueOf((this._settingList.size() - 1)).toString()
221 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
225 * Method getSetting.Returns the contents of the collection in an Array.
227 * Note: Just in case the collection contents are changing in another thread,
228 * we pass a 0-length Array of the correct type into the API call. This way we
229 * <i>know</i> that the Array returned is of exactly the correct length.
231 * @return this collection as an Array
233 public jalview.schemabinding.version2.Setting[] getSetting()
235 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
236 return (jalview.schemabinding.version2.Setting[]) this._settingList
241 * Method getSettingCount.
243 * @return the size of this collection
245 public int getSettingCount()
247 return this._settingList.size();
253 * @return true if this object is valid according to the schema
255 public boolean isValid()
260 } catch (org.exolab.castor.xml.ValidationException vex)
271 * @throws org.exolab.castor.xml.MarshalException
272 * if object is null or if any SAXException is thrown during
274 * @throws org.exolab.castor.xml.ValidationException
275 * if this object is an invalid instance according to the schema
277 public void marshal(final java.io.Writer out)
278 throws org.exolab.castor.xml.MarshalException,
279 org.exolab.castor.xml.ValidationException
281 Marshaller.marshal(this, out);
288 * @throws java.io.IOException
289 * if an IOException occurs during marshaling
290 * @throws org.exolab.castor.xml.ValidationException
291 * if this object is an invalid instance according to the schema
292 * @throws org.exolab.castor.xml.MarshalException
293 * if object is null or if any SAXException is thrown during
296 public void marshal(final org.xml.sax.ContentHandler handler)
297 throws java.io.IOException,
298 org.exolab.castor.xml.MarshalException,
299 org.exolab.castor.xml.ValidationException
301 Marshaller.marshal(this, handler);
306 public void removeAllGroup()
308 this._groupList.clear();
313 public void removeAllSetting()
315 this._settingList.clear();
319 * Method removeGroup.
322 * @return true if the object was removed from the collection.
324 public boolean removeGroup(
325 final jalview.schemabinding.version2.Group vGroup)
327 boolean removed = _groupList.remove(vGroup);
332 * Method removeGroupAt.
335 * @return the element removed from the collection
337 public jalview.schemabinding.version2.Group removeGroupAt(final int index)
339 java.lang.Object obj = this._groupList.remove(index);
340 return (jalview.schemabinding.version2.Group) obj;
344 * Method removeSetting.
347 * @return true if the object was removed from the collection.
349 public boolean removeSetting(
350 final jalview.schemabinding.version2.Setting vSetting)
352 boolean removed = _settingList.remove(vSetting);
357 * Method removeSettingAt.
360 * @return the element removed from the collection
362 public jalview.schemabinding.version2.Setting removeSettingAt(
365 java.lang.Object obj = this._settingList.remove(index);
366 return (jalview.schemabinding.version2.Setting) obj;
374 * @throws java.lang.IndexOutOfBoundsException
375 * if the index given is outside the bounds of the collection
377 public void setGroup(final int index,
378 final jalview.schemabinding.version2.Group vGroup)
379 throws java.lang.IndexOutOfBoundsException
381 // check bounds for index
382 if (index < 0 || index >= this._groupList.size())
384 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
386 Integer.valueOf(index).toString(),
387 Integer.valueOf((this._groupList.size() - 1)).toString()
391 this._groupList.set(index, vGroup);
399 public void setGroup(
400 final jalview.schemabinding.version2.Group[] vGroupArray)
405 for (int i = 0; i < vGroupArray.length; i++)
407 this._groupList.add(vGroupArray[i]);
416 * @throws java.lang.IndexOutOfBoundsException
417 * if the index given is outside the bounds of the collection
419 public void setSetting(final int index,
420 final jalview.schemabinding.version2.Setting vSetting)
421 throws java.lang.IndexOutOfBoundsException
423 // check bounds for index
424 if (index < 0 || index >= this._settingList.size())
426 throw new IndexOutOfBoundsException(MessageManager.formatMessage("exception.index_value_not_in_range", new String[]{
428 Integer.valueOf(index).toString(),
429 Integer.valueOf((this._settingList.size() - 1)).toString()
433 this._settingList.set(index, vSetting);
439 * @param vSettingArray
441 public void setSetting(
442 final jalview.schemabinding.version2.Setting[] vSettingArray)
445 _settingList.clear();
447 for (int i = 0; i < vSettingArray.length; i++)
449 this._settingList.add(vSettingArray[i]);
457 * @throws org.exolab.castor.xml.MarshalException
458 * if object is null or if any SAXException is thrown during
460 * @throws org.exolab.castor.xml.ValidationException
461 * if this object is an invalid instance according to the schema
462 * @return the unmarshaled jalview.schemabinding.version2.FeatureSettings
464 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
465 final java.io.Reader reader)
466 throws org.exolab.castor.xml.MarshalException,
467 org.exolab.castor.xml.ValidationException
469 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller
471 jalview.schemabinding.version2.FeatureSettings.class,
478 * @throws org.exolab.castor.xml.ValidationException
479 * if this object is an invalid instance according to the schema
481 public void validate() throws org.exolab.castor.xml.ValidationException
483 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
484 validator.validate(this);