2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 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;
50 public FeatureSettings() {
52 this._settingList = new java.util.Vector();
64 * @throws java.lang.IndexOutOfBoundsException if the index
65 * given is outside the bounds of the collection
67 public void addSetting(
68 final jalview.binding.Setting vSetting)
69 throws java.lang.IndexOutOfBoundsException {
70 this._settingList.addElement(vSetting);
78 * @throws java.lang.IndexOutOfBoundsException if the index
79 * given is outside the bounds of the collection
81 public void addSetting(
83 final jalview.binding.Setting vSetting)
84 throws java.lang.IndexOutOfBoundsException {
85 this._settingList.add(index, vSetting);
89 * Method enumerateSetting.
91 * @return an Enumeration over all jalview.binding.Setting
94 public java.util.Enumeration enumerateSetting(
96 return this._settingList.elements();
103 * @throws java.lang.IndexOutOfBoundsException if the index
104 * given is outside the bounds of the collection
105 * @return the value of the jalview.binding.Setting at the
108 public jalview.binding.Setting getSetting(
110 throws java.lang.IndexOutOfBoundsException {
111 // check bounds for index
112 if (index < 0 || index >= this._settingList.size()) {
113 throw new IndexOutOfBoundsException("getSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]");
116 return (jalview.binding.Setting) _settingList.get(index);
120 * Method getSetting.Returns the contents of the collection in
121 * an Array. <p>Note: Just in case the collection contents
122 * are changing in another thread, we pass a 0-length Array of
123 * the correct type into the API call. This way we <i>know</i>
124 * 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(
153 } catch (org.exolab.castor.xml.ValidationException vex) {
163 * @throws org.exolab.castor.xml.MarshalException if object is
164 * null or if any SAXException is thrown during marshaling
165 * @throws org.exolab.castor.xml.ValidationException if this
166 * object is an invalid instance according to the schema
169 final java.io.Writer out)
170 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
171 Marshaller.marshal(this, out);
178 * @throws java.io.IOException if an IOException occurs during
180 * @throws org.exolab.castor.xml.ValidationException if this
181 * object is an invalid instance according to the schema
182 * @throws org.exolab.castor.xml.MarshalException if object is
183 * null or if any SAXException is thrown during marshaling
186 final org.xml.sax.ContentHandler handler)
187 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
188 Marshaller.marshal(this, handler);
193 public void removeAllSetting(
195 this._settingList.clear();
199 * Method removeSetting.
202 * @return true if the object was removed from the collection.
204 public boolean removeSetting(
205 final jalview.binding.Setting vSetting) {
206 boolean removed = _settingList.remove(vSetting);
211 * Method removeSettingAt.
214 * @return the element removed from the collection
216 public jalview.binding.Setting removeSettingAt(
218 java.lang.Object obj = this._settingList.remove(index);
219 return (jalview.binding.Setting) obj;
227 * @throws java.lang.IndexOutOfBoundsException if the index
228 * given is outside the bounds of the collection
230 public void setSetting(
232 final jalview.binding.Setting vSetting)
233 throws java.lang.IndexOutOfBoundsException {
234 // check bounds for index
235 if (index < 0 || index >= this._settingList.size()) {
236 throw new IndexOutOfBoundsException("setSetting: Index value '" + index + "' not in range [0.." + (this._settingList.size() - 1) + "]");
239 this._settingList.set(index, vSetting);
245 * @param vSettingArray
247 public void setSetting(
248 final jalview.binding.Setting[] vSettingArray) {
250 _settingList.clear();
252 for (int i = 0; i < vSettingArray.length; i++) {
253 this._settingList.add(vSettingArray[i]);
261 * @throws org.exolab.castor.xml.MarshalException if object is
262 * null or if any SAXException is thrown during marshaling
263 * @throws org.exolab.castor.xml.ValidationException if this
264 * object is an invalid instance according to the schema
265 * @return the unmarshaled jalview.binding.FeatureSettings
267 public static jalview.binding.FeatureSettings unmarshal(
268 final java.io.Reader reader)
269 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
270 return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(jalview.binding.FeatureSettings.class, reader);
276 * @throws org.exolab.castor.xml.ValidationException if this
277 * object is an invalid instance according to the schema
279 public void validate(
281 throws org.exolab.castor.xml.ValidationException {
282 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
283 validator.validate(this);