2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.binding;
23 //---------------------------------/
24 //- Imported classes and packages -/
25 //---------------------------------/
27 import org.exolab.castor.xml.Marshaller;
28 import org.exolab.castor.xml.Unmarshaller;
31 * Class FeatureSettings.
33 * @version $Revision$ $Date$
35 public class FeatureSettings implements java.io.Serializable
38 // --------------------------/
39 // - Class/Member Variables -/
40 // --------------------------/
45 private java.util.Vector _settingList;
51 public FeatureSettings()
54 this._settingList = new java.util.Vector();
65 * @throws java.lang.IndexOutOfBoundsException
66 * if the index given is outside the bounds of the collection
68 public void addSetting(final jalview.binding.Setting vSetting)
69 throws java.lang.IndexOutOfBoundsException
71 this._settingList.addElement(vSetting);
79 * @throws java.lang.IndexOutOfBoundsException
80 * if the index given is outside the bounds of the collection
82 public void addSetting(final int index,
83 final jalview.binding.Setting vSetting)
84 throws java.lang.IndexOutOfBoundsException
86 this._settingList.add(index, vSetting);
90 * Method enumerateSetting.
92 * @return an Enumeration over all jalview.binding.Setting elements
94 public java.util.Enumeration enumerateSetting()
96 return this._settingList.elements();
103 * @throws java.lang.IndexOutOfBoundsException
104 * if the index given is outside the bounds of the collection
105 * @return the value of the jalview.binding.Setting at the given index
107 public jalview.binding.Setting getSetting(final int index)
108 throws java.lang.IndexOutOfBoundsException
110 // check bounds for index
111 if (index < 0 || index >= this._settingList.size())
113 throw new IndexOutOfBoundsException("getSetting: Index value '"
114 + index + "' not in range [0.."
115 + (this._settingList.size() - 1) + "]");
118 return (jalview.binding.Setting) _settingList.get(index);
122 * Method getSetting.Returns the contents of the collection in an Array.
124 * Note: Just in case the collection contents are changing in another thread,
125 * we pass a 0-length Array of the correct type into the API call. This way we
126 * <i>know</i> that the Array returned is of exactly the correct length.
128 * @return this collection as an Array
130 public jalview.binding.Setting[] getSetting()
132 jalview.binding.Setting[] array = new jalview.binding.Setting[0];
133 return (jalview.binding.Setting[]) this._settingList.toArray(array);
137 * Method getSettingCount.
139 * @return the size of this collection
141 public int getSettingCount()
143 return this._settingList.size();
149 * @return true if this object is valid according to the schema
151 public boolean isValid()
156 } catch (org.exolab.castor.xml.ValidationException vex)
167 * @throws org.exolab.castor.xml.MarshalException
168 * if object is null or if any SAXException is thrown during
170 * @throws org.exolab.castor.xml.ValidationException
171 * if this object is an invalid instance according to the schema
173 public void marshal(final java.io.Writer out)
174 throws org.exolab.castor.xml.MarshalException,
175 org.exolab.castor.xml.ValidationException
177 Marshaller.marshal(this, out);
184 * @throws java.io.IOException
185 * if an IOException occurs during marshaling
186 * @throws org.exolab.castor.xml.ValidationException
187 * if this object is an invalid instance according to the schema
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 schema
279 * @return the unmarshaled jalview.binding.FeatureSettings
281 public static jalview.binding.FeatureSettings unmarshal(
282 final java.io.Reader reader)
283 throws org.exolab.castor.xml.MarshalException,
284 org.exolab.castor.xml.ValidationException
286 return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(
287 jalview.binding.FeatureSettings.class, reader);
293 * @throws org.exolab.castor.xml.ValidationException
294 * if this object is an invalid instance according to the schema
296 public void validate() throws org.exolab.castor.xml.ValidationException
298 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
299 validator.validate(this);