2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
\r
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\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
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
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
19 package jalview.schemabinding.version2;
\r
21 // ---------------------------------/
\r
22 // - Imported classes and packages -/
\r
23 // ---------------------------------/
\r
25 import org.exolab.castor.xml.Marshaller;
\r
26 import org.exolab.castor.xml.Unmarshaller;
\r
29 * Class FeatureSettings.
\r
31 * @version $Revision$ $Date$
\r
33 public class FeatureSettings implements java.io.Serializable
\r
36 // --------------------------/
\r
37 // - Class/Member Variables -/
\r
38 // --------------------------/
\r
41 * Field _settingList.
\r
43 private java.util.Vector _settingList;
\r
48 private java.util.Vector _groupList;
\r
50 // ----------------/
\r
51 // - Constructors -/
\r
52 // ----------------/
\r
54 public FeatureSettings()
\r
57 this._settingList = new java.util.Vector();
\r
58 this._groupList = new java.util.Vector();
\r
69 * @throws java.lang.IndexOutOfBoundsException
\r
70 * if the index given is outside the bounds of the collection
\r
72 public void addGroup(final jalview.schemabinding.version2.Group vGroup)
\r
73 throws java.lang.IndexOutOfBoundsException
\r
75 this._groupList.addElement(vGroup);
\r
83 * @throws java.lang.IndexOutOfBoundsException
\r
84 * if the index given is outside the bounds of the collection
\r
86 public void addGroup(final int index,
\r
87 final jalview.schemabinding.version2.Group vGroup)
\r
88 throws java.lang.IndexOutOfBoundsException
\r
90 this._groupList.add(index, vGroup);
\r
97 * @throws java.lang.IndexOutOfBoundsException
\r
98 * if the index given is outside the bounds of the collection
\r
100 public void addSetting(
\r
101 final jalview.schemabinding.version2.Setting vSetting)
\r
102 throws java.lang.IndexOutOfBoundsException
\r
104 this._settingList.addElement(vSetting);
\r
112 * @throws java.lang.IndexOutOfBoundsException
\r
113 * if the index given is outside the bounds of the collection
\r
115 public void addSetting(final int index,
\r
116 final jalview.schemabinding.version2.Setting vSetting)
\r
117 throws java.lang.IndexOutOfBoundsException
\r
119 this._settingList.add(index, vSetting);
\r
123 * Method enumerateGroup.
\r
125 * @return an Enumeration over all jalview.schemabinding.version2.Group
\r
128 public java.util.Enumeration enumerateGroup()
\r
130 return this._groupList.elements();
\r
134 * Method enumerateSetting.
\r
136 * @return an Enumeration over all jalview.schemabinding.version2.Setting
\r
139 public java.util.Enumeration enumerateSetting()
\r
141 return this._settingList.elements();
\r
148 * @throws java.lang.IndexOutOfBoundsException
\r
149 * if the index given is outside the bounds of the collection
\r
150 * @return the value of the jalview.schemabinding.version2.Group at the given
\r
153 public jalview.schemabinding.version2.Group getGroup(final int index)
\r
154 throws java.lang.IndexOutOfBoundsException
\r
156 // check bounds for index
\r
157 if (index < 0 || index >= this._groupList.size())
\r
159 throw new IndexOutOfBoundsException("getGroup: Index value '" + index
\r
160 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
\r
163 return (jalview.schemabinding.version2.Group) _groupList.get(index);
\r
167 * Method getGroup.Returns the contents of the collection in an Array.
\r
169 * Note: Just in case the collection contents are changing in another thread,
\r
170 * we pass a 0-length Array of the correct type into the API call. This way we
\r
171 * <i>know</i> that the Array returned is of exactly the correct length.
\r
173 * @return this collection as an Array
\r
175 public jalview.schemabinding.version2.Group[] getGroup()
\r
177 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
\r
178 return (jalview.schemabinding.version2.Group[]) this._groupList
\r
183 * Method getGroupCount.
\r
185 * @return the size of this collection
\r
187 public int getGroupCount()
\r
189 return this._groupList.size();
\r
193 * Method getSetting.
\r
196 * @throws java.lang.IndexOutOfBoundsException
\r
197 * if the index given is outside the bounds of the collection
\r
198 * @return the value of the jalview.schemabinding.version2.Setting at the
\r
201 public jalview.schemabinding.version2.Setting getSetting(final int index)
\r
202 throws java.lang.IndexOutOfBoundsException
\r
204 // check bounds for index
\r
205 if (index < 0 || index >= this._settingList.size())
\r
207 throw new IndexOutOfBoundsException("getSetting: Index value '"
\r
208 + index + "' not in range [0.."
\r
209 + (this._settingList.size() - 1) + "]");
\r
212 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
\r
216 * Method getSetting.Returns the contents of the collection in an Array.
\r
218 * Note: Just in case the collection contents are changing in another thread,
\r
219 * we pass a 0-length Array of the correct type into the API call. This way we
\r
220 * <i>know</i> that the Array returned is of exactly the correct length.
\r
222 * @return this collection as an Array
\r
224 public jalview.schemabinding.version2.Setting[] getSetting()
\r
226 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
\r
227 return (jalview.schemabinding.version2.Setting[]) this._settingList
\r
232 * Method getSettingCount.
\r
234 * @return the size of this collection
\r
236 public int getSettingCount()
\r
238 return this._settingList.size();
\r
244 * @return true if this object is valid according to the schema
\r
246 public boolean isValid()
\r
251 } catch (org.exolab.castor.xml.ValidationException vex)
\r
262 * @throws org.exolab.castor.xml.MarshalException
\r
263 * if object is null or if any SAXException is thrown during
\r
265 * @throws org.exolab.castor.xml.ValidationException
\r
266 * if this object is an invalid instance according to the
\r
269 public void marshal(final java.io.Writer out)
\r
270 throws org.exolab.castor.xml.MarshalException,
\r
271 org.exolab.castor.xml.ValidationException
\r
273 Marshaller.marshal(this, out);
\r
280 * @throws java.io.IOException
\r
281 * if an IOException occurs during marshaling
\r
282 * @throws org.exolab.castor.xml.ValidationException
\r
283 * if this object is an invalid instance according to the
\r
285 * @throws org.exolab.castor.xml.MarshalException
\r
286 * if object is null or if any SAXException is thrown during
\r
289 public void marshal(final org.xml.sax.ContentHandler handler)
\r
290 throws java.io.IOException,
\r
291 org.exolab.castor.xml.MarshalException,
\r
292 org.exolab.castor.xml.ValidationException
\r
294 Marshaller.marshal(this, handler);
\r
299 public void removeAllGroup()
\r
301 this._groupList.clear();
\r
306 public void removeAllSetting()
\r
308 this._settingList.clear();
\r
312 * Method removeGroup.
\r
315 * @return true if the object was removed from the collection.
\r
317 public boolean removeGroup(
\r
318 final jalview.schemabinding.version2.Group vGroup)
\r
320 boolean removed = _groupList.remove(vGroup);
\r
325 * Method removeGroupAt.
\r
328 * @return the element removed from the collection
\r
330 public jalview.schemabinding.version2.Group removeGroupAt(final int index)
\r
332 java.lang.Object obj = this._groupList.remove(index);
\r
333 return (jalview.schemabinding.version2.Group) obj;
\r
337 * Method removeSetting.
\r
340 * @return true if the object was removed from the collection.
\r
342 public boolean removeSetting(
\r
343 final jalview.schemabinding.version2.Setting vSetting)
\r
345 boolean removed = _settingList.remove(vSetting);
\r
350 * Method removeSettingAt.
\r
353 * @return the element removed from the collection
\r
355 public jalview.schemabinding.version2.Setting removeSettingAt(
\r
358 java.lang.Object obj = this._settingList.remove(index);
\r
359 return (jalview.schemabinding.version2.Setting) obj;
\r
367 * @throws java.lang.IndexOutOfBoundsException
\r
368 * if the index given is outside the bounds of the collection
\r
370 public void setGroup(final int index,
\r
371 final jalview.schemabinding.version2.Group vGroup)
\r
372 throws java.lang.IndexOutOfBoundsException
\r
374 // check bounds for index
\r
375 if (index < 0 || index >= this._groupList.size())
\r
377 throw new IndexOutOfBoundsException("setGroup: Index value '" + index
\r
378 + "' not in range [0.." + (this._groupList.size() - 1) + "]");
\r
381 this._groupList.set(index, vGroup);
\r
387 * @param vGroupArray
\r
389 public void setGroup(
\r
390 final jalview.schemabinding.version2.Group[] vGroupArray)
\r
393 _groupList.clear();
\r
395 for (int i = 0; i < vGroupArray.length; i++)
\r
397 this._groupList.add(vGroupArray[i]);
\r
406 * @throws java.lang.IndexOutOfBoundsException
\r
407 * if the index given is outside the bounds of the collection
\r
409 public void setSetting(final int index,
\r
410 final jalview.schemabinding.version2.Setting vSetting)
\r
411 throws java.lang.IndexOutOfBoundsException
\r
413 // check bounds for index
\r
414 if (index < 0 || index >= this._settingList.size())
\r
416 throw new IndexOutOfBoundsException("setSetting: Index value '"
\r
417 + index + "' not in range [0.."
\r
418 + (this._settingList.size() - 1) + "]");
\r
421 this._settingList.set(index, vSetting);
\r
427 * @param vSettingArray
\r
429 public void setSetting(
\r
430 final jalview.schemabinding.version2.Setting[] vSettingArray)
\r
433 _settingList.clear();
\r
435 for (int i = 0; i < vSettingArray.length; i++)
\r
437 this._settingList.add(vSettingArray[i]);
\r
442 * Method unmarshal.
\r
445 * @throws org.exolab.castor.xml.MarshalException
\r
446 * if object is null or if any SAXException is thrown during
\r
448 * @throws org.exolab.castor.xml.ValidationException
\r
449 * if this object is an invalid instance according to the
\r
451 * @return the unmarshaled jalview.schemabinding.version2.FeatureSettings
\r
453 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
\r
454 final java.io.Reader reader)
\r
455 throws org.exolab.castor.xml.MarshalException,
\r
456 org.exolab.castor.xml.ValidationException
\r
458 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller
\r
460 jalview.schemabinding.version2.FeatureSettings.class,
\r
467 * @throws org.exolab.castor.xml.ValidationException
\r
468 * if this object is an invalid instance according to the
\r
471 public void validate() throws org.exolab.castor.xml.ValidationException
\r
473 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
474 validator.validate(this);
\r