2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
\r
3 * Copyright (C) 2009 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
55 public FeatureSettings() {
\r
57 this._settingList = new java.util.Vector();
\r
58 this._groupList = new java.util.Vector();
\r
70 * @throws java.lang.IndexOutOfBoundsException if the index
\r
71 * given is outside the bounds of the collection
\r
73 public void addGroup(
\r
74 final jalview.schemabinding.version2.Group vGroup)
\r
75 throws java.lang.IndexOutOfBoundsException {
\r
76 this._groupList.addElement(vGroup);
\r
84 * @throws java.lang.IndexOutOfBoundsException if the index
\r
85 * given is outside the bounds of the collection
\r
87 public void addGroup(
\r
89 final jalview.schemabinding.version2.Group vGroup)
\r
90 throws java.lang.IndexOutOfBoundsException {
\r
91 this._groupList.add(index, vGroup);
\r
98 * @throws java.lang.IndexOutOfBoundsException if the index
\r
99 * given is outside the bounds of the collection
\r
101 public void addSetting(
\r
102 final jalview.schemabinding.version2.Setting vSetting)
\r
103 throws java.lang.IndexOutOfBoundsException {
\r
104 this._settingList.addElement(vSetting);
\r
112 * @throws java.lang.IndexOutOfBoundsException if the index
\r
113 * given is outside the bounds of the collection
\r
115 public void addSetting(
\r
117 final jalview.schemabinding.version2.Setting vSetting)
\r
118 throws java.lang.IndexOutOfBoundsException {
\r
119 this._settingList.add(index, vSetting);
\r
123 * Method enumerateGroup.
\r
125 * @return an Enumeration over all
\r
126 * jalview.schemabinding.version2.Group elements
\r
128 public java.util.Enumeration enumerateGroup(
\r
130 return this._groupList.elements();
\r
134 * Method enumerateSetting.
\r
136 * @return an Enumeration over all
\r
137 * jalview.schemabinding.version2.Setting elements
\r
139 public java.util.Enumeration enumerateSetting(
\r
141 return this._settingList.elements();
\r
148 * @throws java.lang.IndexOutOfBoundsException if the index
\r
149 * given is outside the bounds of the collection
\r
150 * @return the value of the
\r
151 * jalview.schemabinding.version2.Group at the given index
\r
153 public jalview.schemabinding.version2.Group getGroup(
\r
155 throws java.lang.IndexOutOfBoundsException {
\r
156 // check bounds for index
\r
157 if (index < 0 || index >= this._groupList.size()) {
\r
158 throw new IndexOutOfBoundsException("getGroup: Index value '" + index + "' not in range [0.." + (this._groupList.size() - 1) + "]");
\r
161 return (jalview.schemabinding.version2.Group) _groupList.get(index);
\r
165 * Method getGroup.Returns the contents of the collection in an
\r
166 * Array. <p>Note: Just in case the collection contents are
\r
167 * changing in another thread, we pass a 0-length Array of the
\r
168 * correct type into the API call. This way we <i>know</i>
\r
169 * that the Array returned is of exactly the correct length.
\r
171 * @return this collection as an Array
\r
173 public jalview.schemabinding.version2.Group[] getGroup(
\r
175 jalview.schemabinding.version2.Group[] array = new jalview.schemabinding.version2.Group[0];
\r
176 return (jalview.schemabinding.version2.Group[]) this._groupList.toArray(array);
\r
180 * Method getGroupCount.
\r
182 * @return the size of this collection
\r
184 public int getGroupCount(
\r
186 return this._groupList.size();
\r
190 * Method getSetting.
\r
193 * @throws java.lang.IndexOutOfBoundsException if the index
\r
194 * given is outside the bounds of the collection
\r
195 * @return the value of the
\r
196 * jalview.schemabinding.version2.Setting at the given index
\r
198 public jalview.schemabinding.version2.Setting getSetting(
\r
200 throws java.lang.IndexOutOfBoundsException {
\r
201 // check bounds for index
\r
202 if (index < 0 || index >= this._settingList.size()) {
\r
203 throw new IndexOutOfBoundsException("getSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]");
\r
206 return (jalview.schemabinding.version2.Setting) _settingList.get(index);
\r
210 * Method getSetting.Returns the contents of the collection in
\r
211 * an Array. <p>Note: Just in case the collection contents
\r
212 * are changing in another thread, we pass a 0-length Array of
\r
213 * the correct type into the API call. This way we <i>know</i>
\r
214 * that the Array returned is of exactly the correct length.
\r
216 * @return this collection as an Array
\r
218 public jalview.schemabinding.version2.Setting[] getSetting(
\r
220 jalview.schemabinding.version2.Setting[] array = new jalview.schemabinding.version2.Setting[0];
\r
221 return (jalview.schemabinding.version2.Setting[]) this._settingList.toArray(array);
\r
225 * Method getSettingCount.
\r
227 * @return the size of this collection
\r
229 public int getSettingCount(
\r
231 return this._settingList.size();
\r
237 * @return true if this object is valid according to the schema
\r
239 public boolean isValid(
\r
243 } catch (org.exolab.castor.xml.ValidationException vex) {
\r
253 * @throws org.exolab.castor.xml.MarshalException if object is
\r
254 * null or if any SAXException is thrown during marshaling
\r
255 * @throws org.exolab.castor.xml.ValidationException if this
\r
256 * object is an invalid instance according to the schema
\r
258 public void marshal(
\r
259 final java.io.Writer out)
\r
260 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
261 Marshaller.marshal(this, out);
\r
268 * @throws java.io.IOException if an IOException occurs during
\r
270 * @throws org.exolab.castor.xml.ValidationException if this
\r
271 * object is an invalid instance according to the schema
\r
272 * @throws org.exolab.castor.xml.MarshalException if object is
\r
273 * null or if any SAXException is thrown during marshaling
\r
275 public void marshal(
\r
276 final org.xml.sax.ContentHandler handler)
\r
277 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
278 Marshaller.marshal(this, handler);
\r
283 public void removeAllGroup(
\r
285 this._groupList.clear();
\r
290 public void removeAllSetting(
\r
292 this._settingList.clear();
\r
296 * Method removeGroup.
\r
299 * @return true if the object was removed from the collection.
\r
301 public boolean removeGroup(
\r
302 final jalview.schemabinding.version2.Group vGroup) {
\r
303 boolean removed = _groupList.remove(vGroup);
\r
308 * Method removeGroupAt.
\r
311 * @return the element removed from the collection
\r
313 public jalview.schemabinding.version2.Group removeGroupAt(
\r
315 java.lang.Object obj = this._groupList.remove(index);
\r
316 return (jalview.schemabinding.version2.Group) obj;
\r
320 * Method removeSetting.
\r
323 * @return true if the object was removed from the collection.
\r
325 public boolean removeSetting(
\r
326 final jalview.schemabinding.version2.Setting vSetting) {
\r
327 boolean removed = _settingList.remove(vSetting);
\r
332 * Method removeSettingAt.
\r
335 * @return the element removed from the collection
\r
337 public jalview.schemabinding.version2.Setting removeSettingAt(
\r
339 java.lang.Object obj = this._settingList.remove(index);
\r
340 return (jalview.schemabinding.version2.Setting) obj;
\r
348 * @throws java.lang.IndexOutOfBoundsException if the index
\r
349 * given is outside the bounds of the collection
\r
351 public void setGroup(
\r
353 final jalview.schemabinding.version2.Group vGroup)
\r
354 throws java.lang.IndexOutOfBoundsException {
\r
355 // check bounds for index
\r
356 if (index < 0 || index >= this._groupList.size()) {
\r
357 throw new IndexOutOfBoundsException("setGroup: Index value '" + index + "' not in range [0.." + (this._groupList.size() - 1) + "]");
\r
360 this._groupList.set(index, vGroup);
\r
366 * @param vGroupArray
\r
368 public void setGroup(
\r
369 final jalview.schemabinding.version2.Group[] vGroupArray) {
\r
371 _groupList.clear();
\r
373 for (int i = 0; i < vGroupArray.length; i++) {
\r
374 this._groupList.add(vGroupArray[i]);
\r
383 * @throws java.lang.IndexOutOfBoundsException if the index
\r
384 * given is outside the bounds of the collection
\r
386 public void setSetting(
\r
388 final jalview.schemabinding.version2.Setting vSetting)
\r
389 throws java.lang.IndexOutOfBoundsException {
\r
390 // check bounds for index
\r
391 if (index < 0 || index >= this._settingList.size()) {
\r
392 throw new IndexOutOfBoundsException("setSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]");
\r
395 this._settingList.set(index, vSetting);
\r
401 * @param vSettingArray
\r
403 public void setSetting(
\r
404 final jalview.schemabinding.version2.Setting[] vSettingArray) {
\r
406 _settingList.clear();
\r
408 for (int i = 0; i < vSettingArray.length; i++) {
\r
409 this._settingList.add(vSettingArray[i]);
\r
414 * Method unmarshal.
\r
417 * @throws org.exolab.castor.xml.MarshalException if object is
\r
418 * null or if any SAXException is thrown during marshaling
\r
419 * @throws org.exolab.castor.xml.ValidationException if this
\r
420 * object is an invalid instance according to the schema
\r
421 * @return the unmarshaled
\r
422 * jalview.schemabinding.version2.FeatureSettings
\r
424 public static jalview.schemabinding.version2.FeatureSettings unmarshal(
\r
425 final java.io.Reader reader)
\r
426 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
\r
427 return (jalview.schemabinding.version2.FeatureSettings) Unmarshaller.unmarshal(jalview.schemabinding.version2.FeatureSettings.class, reader);
\r
433 * @throws org.exolab.castor.xml.ValidationException if this
\r
434 * object is an invalid instance according to the schema
\r
436 public void validate(
\r
438 throws org.exolab.castor.xml.ValidationException {
\r
439 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
\r
440 validator.validate(this);
\r