2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3 * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.binding;
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;
49 public FeatureSettings()
52 this._settingList = new java.util.Vector();
63 * @throws java.lang.IndexOutOfBoundsException
64 * if the index given is outside the bounds of the collection
66 public void addSetting(final jalview.binding.Setting vSetting)
67 throws java.lang.IndexOutOfBoundsException
69 this._settingList.addElement(vSetting);
77 * @throws java.lang.IndexOutOfBoundsException
78 * if the index given is outside the bounds of the collection
80 public void addSetting(final int index,
81 final jalview.binding.Setting vSetting)
82 throws java.lang.IndexOutOfBoundsException
84 this._settingList.add(index, vSetting);
88 * Method enumerateSetting.
90 * @return an Enumeration over all jalview.binding.Setting elements
92 public java.util.Enumeration enumerateSetting()
94 return this._settingList.elements();
101 * @throws java.lang.IndexOutOfBoundsException
102 * if the index given is outside the bounds of the collection
103 * @return the value of the jalview.binding.Setting at the given index
105 public jalview.binding.Setting getSetting(final int index)
106 throws java.lang.IndexOutOfBoundsException
108 // check bounds for index
109 if (index < 0 || index >= this._settingList.size())
111 throw new IndexOutOfBoundsException("getSetting: Index value '"
112 + index + "' not in range [0.."
113 + (this._settingList.size() - 1) + "]");
116 return (jalview.binding.Setting) _settingList.get(index);
120 * Method getSetting.Returns the contents of the collection in an Array.
122 * Note: Just in case the collection contents are changing in another thread,
123 * we pass a 0-length Array of the correct type into the API call. This way we
124 * <i>know</i> that the Array returned is of exactly the correct length.
126 * @return this collection as an Array
128 public jalview.binding.Setting[] getSetting()
130 jalview.binding.Setting[] array = new jalview.binding.Setting[0];
131 return (jalview.binding.Setting[]) this._settingList.toArray(array);
135 * Method getSettingCount.
137 * @return the size of this collection
139 public int getSettingCount()
141 return this._settingList.size();
147 * @return true if this object is valid according to the schema
149 public boolean isValid()
154 } catch (org.exolab.castor.xml.ValidationException vex)
165 * @throws org.exolab.castor.xml.MarshalException
166 * if object is null or if any SAXException is thrown during
168 * @throws org.exolab.castor.xml.ValidationException
169 * if this object is an invalid instance according to the
172 public void marshal(final java.io.Writer out)
173 throws org.exolab.castor.xml.MarshalException,
174 org.exolab.castor.xml.ValidationException
176 Marshaller.marshal(this, out);
183 * @throws java.io.IOException
184 * if an IOException occurs during marshaling
185 * @throws org.exolab.castor.xml.ValidationException
186 * if this object is an invalid instance according to the
188 * @throws org.exolab.castor.xml.MarshalException
189 * if object is null or if any SAXException is thrown during
192 public void marshal(final org.xml.sax.ContentHandler handler)
193 throws java.io.IOException,
194 org.exolab.castor.xml.MarshalException,
195 org.exolab.castor.xml.ValidationException
197 Marshaller.marshal(this, handler);
202 public void removeAllSetting()
204 this._settingList.clear();
208 * Method removeSetting.
211 * @return true if the object was removed from the collection.
213 public boolean removeSetting(final jalview.binding.Setting vSetting)
215 boolean removed = _settingList.remove(vSetting);
220 * Method removeSettingAt.
223 * @return the element removed from the collection
225 public jalview.binding.Setting removeSettingAt(final int index)
227 java.lang.Object obj = this._settingList.remove(index);
228 return (jalview.binding.Setting) obj;
236 * @throws java.lang.IndexOutOfBoundsException
237 * if the index given is outside the bounds of the collection
239 public void setSetting(final int index,
240 final jalview.binding.Setting vSetting)
241 throws java.lang.IndexOutOfBoundsException
243 // check bounds for index
244 if (index < 0 || index >= this._settingList.size())
246 throw new IndexOutOfBoundsException("setSetting: Index value '"
247 + index + "' not in range [0.."
248 + (this._settingList.size() - 1) + "]");
251 this._settingList.set(index, vSetting);
257 * @param vSettingArray
259 public void setSetting(final jalview.binding.Setting[] vSettingArray)
262 _settingList.clear();
264 for (int i = 0; i < vSettingArray.length; i++)
266 this._settingList.add(vSettingArray[i]);
274 * @throws org.exolab.castor.xml.MarshalException
275 * if object is null or if any SAXException is thrown during
277 * @throws org.exolab.castor.xml.ValidationException
278 * if this object is an invalid instance according to the
280 * @return the unmarshaled jalview.binding.FeatureSettings
282 public static jalview.binding.FeatureSettings unmarshal(
283 final java.io.Reader reader)
284 throws org.exolab.castor.xml.MarshalException,
285 org.exolab.castor.xml.ValidationException
287 return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(
288 jalview.binding.FeatureSettings.class, reader);
294 * @throws org.exolab.castor.xml.ValidationException
295 * if this object is an invalid instance according to the
298 public void validate() throws org.exolab.castor.xml.ValidationException
300 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
301 validator.validate(this);