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