2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.binding;
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
28 * Class FeatureSettings.
30 * @version $Revision$ $Date$
32 public class FeatureSettings implements java.io.Serializable
35 // --------------------------/
36 // - Class/Member Variables -/
37 // --------------------------/
42 private java.util.Vector _settingList;
48 public FeatureSettings()
51 this._settingList = new java.util.Vector();
62 * @throws java.lang.IndexOutOfBoundsException
63 * if the index given is outside the bounds of the collection
65 public void addSetting(final jalview.binding.Setting vSetting)
66 throws java.lang.IndexOutOfBoundsException
68 this._settingList.addElement(vSetting);
76 * @throws java.lang.IndexOutOfBoundsException
77 * if the index given is outside the bounds of the collection
79 public void addSetting(final int index,
80 final jalview.binding.Setting vSetting)
81 throws java.lang.IndexOutOfBoundsException
83 this._settingList.add(index, vSetting);
87 * Method enumerateSetting.
89 * @return an Enumeration over all jalview.binding.Setting elements
91 public java.util.Enumeration enumerateSetting()
93 return this._settingList.elements();
100 * @throws java.lang.IndexOutOfBoundsException
101 * if the index given is outside the bounds of the collection
102 * @return the value of the jalview.binding.Setting at the given index
104 public jalview.binding.Setting getSetting(final int index)
105 throws java.lang.IndexOutOfBoundsException
107 // check bounds for index
108 if (index < 0 || index >= this._settingList.size())
110 throw new IndexOutOfBoundsException("getSetting: Index value '"
111 + index + "' not in range [0.."
112 + (this._settingList.size() - 1) + "]");
115 return (jalview.binding.Setting) _settingList.get(index);
119 * Method getSetting.Returns the contents of the collection in an Array.
121 * Note: Just in case the collection contents are changing in another thread,
122 * we pass a 0-length Array of the correct type into the API call. This way we
123 * <i>know</i> that the Array returned is of exactly the correct length.
125 * @return this collection as an Array
127 public jalview.binding.Setting[] getSetting()
129 jalview.binding.Setting[] array = new jalview.binding.Setting[0];
130 return (jalview.binding.Setting[]) this._settingList.toArray(array);
134 * Method getSettingCount.
136 * @return the size of this collection
138 public int getSettingCount()
140 return this._settingList.size();
146 * @return true if this object is valid according to the schema
148 public boolean isValid()
153 } catch (org.exolab.castor.xml.ValidationException vex)
164 * @throws org.exolab.castor.xml.MarshalException
165 * if object is null or if any SAXException is thrown during
167 * @throws org.exolab.castor.xml.ValidationException
168 * if this object is an invalid instance according to the schema
170 public void marshal(final java.io.Writer out)
171 throws org.exolab.castor.xml.MarshalException,
172 org.exolab.castor.xml.ValidationException
174 Marshaller.marshal(this, out);
181 * @throws java.io.IOException
182 * if an IOException occurs during marshaling
183 * @throws org.exolab.castor.xml.ValidationException
184 * if this object is an invalid instance according to the schema
185 * @throws org.exolab.castor.xml.MarshalException
186 * if object is null or if any SAXException is thrown during
189 public void marshal(final org.xml.sax.ContentHandler handler)
190 throws java.io.IOException,
191 org.exolab.castor.xml.MarshalException,
192 org.exolab.castor.xml.ValidationException
194 Marshaller.marshal(this, handler);
199 public void removeAllSetting()
201 this._settingList.clear();
205 * Method removeSetting.
208 * @return true if the object was removed from the collection.
210 public boolean removeSetting(final jalview.binding.Setting vSetting)
212 boolean removed = _settingList.remove(vSetting);
217 * Method removeSettingAt.
220 * @return the element removed from the collection
222 public jalview.binding.Setting removeSettingAt(final int index)
224 java.lang.Object obj = this._settingList.remove(index);
225 return (jalview.binding.Setting) obj;
233 * @throws java.lang.IndexOutOfBoundsException
234 * if the index given is outside the bounds of the collection
236 public void setSetting(final int index,
237 final jalview.binding.Setting vSetting)
238 throws java.lang.IndexOutOfBoundsException
240 // check bounds for index
241 if (index < 0 || index >= this._settingList.size())
243 throw new IndexOutOfBoundsException("setSetting: Index value '"
244 + index + "' not in range [0.."
245 + (this._settingList.size() - 1) + "]");
248 this._settingList.set(index, vSetting);
254 * @param vSettingArray
256 public void setSetting(final jalview.binding.Setting[] vSettingArray)
259 _settingList.clear();
261 for (int i = 0; i < vSettingArray.length; i++)
263 this._settingList.add(vSettingArray[i]);
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
276 * @return the unmarshaled jalview.binding.FeatureSettings
278 public static jalview.binding.FeatureSettings unmarshal(
279 final java.io.Reader reader)
280 throws org.exolab.castor.xml.MarshalException,
281 org.exolab.castor.xml.ValidationException
283 return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(
284 jalview.binding.FeatureSettings.class, reader);
290 * @throws org.exolab.castor.xml.ValidationException
291 * if this object is an invalid instance according to the schema
293 public void validate() throws org.exolab.castor.xml.ValidationException
295 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
296 validator.validate(this);