2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.1)
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 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/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
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 schema
171 public void marshal(final java.io.Writer out)
172 throws org.exolab.castor.xml.MarshalException,
173 org.exolab.castor.xml.ValidationException
175 Marshaller.marshal(this, out);
182 * @throws java.io.IOException
183 * if an IOException occurs during marshaling
184 * @throws org.exolab.castor.xml.ValidationException
185 * if this object is an invalid instance according to the schema
186 * @throws org.exolab.castor.xml.MarshalException
187 * if object is null or if any SAXException is thrown during
190 public void marshal(final org.xml.sax.ContentHandler handler)
191 throws java.io.IOException,
192 org.exolab.castor.xml.MarshalException,
193 org.exolab.castor.xml.ValidationException
195 Marshaller.marshal(this, handler);
200 public void removeAllSetting()
202 this._settingList.clear();
206 * Method removeSetting.
209 * @return true if the object was removed from the collection.
211 public boolean removeSetting(final jalview.binding.Setting vSetting)
213 boolean removed = _settingList.remove(vSetting);
218 * Method removeSettingAt.
221 * @return the element removed from the collection
223 public jalview.binding.Setting removeSettingAt(final int index)
225 java.lang.Object obj = this._settingList.remove(index);
226 return (jalview.binding.Setting) obj;
234 * @throws java.lang.IndexOutOfBoundsException
235 * if the index given is outside the bounds of the collection
237 public void setSetting(final int index,
238 final jalview.binding.Setting vSetting)
239 throws java.lang.IndexOutOfBoundsException
241 // check bounds for index
242 if (index < 0 || index >= this._settingList.size())
244 throw new IndexOutOfBoundsException("setSetting: Index value '"
245 + index + "' not in range [0.."
246 + (this._settingList.size() - 1) + "]");
249 this._settingList.set(index, vSetting);
255 * @param vSettingArray
257 public void setSetting(final jalview.binding.Setting[] vSettingArray)
260 _settingList.clear();
262 for (int i = 0; i < vSettingArray.length; i++)
264 this._settingList.add(vSettingArray[i]);
272 * @throws org.exolab.castor.xml.MarshalException
273 * if object is null or if any SAXException is thrown during
275 * @throws org.exolab.castor.xml.ValidationException
276 * if this object is an invalid instance according to the schema
277 * @return the unmarshaled jalview.binding.FeatureSettings
279 public static jalview.binding.FeatureSettings unmarshal(
280 final java.io.Reader reader)
281 throws org.exolab.castor.xml.MarshalException,
282 org.exolab.castor.xml.ValidationException
284 return (jalview.binding.FeatureSettings) Unmarshaller.unmarshal(
285 jalview.binding.FeatureSettings.class, reader);
291 * @throws org.exolab.castor.xml.ValidationException
292 * if this object is an invalid instance according to the schema
294 public void validate() throws org.exolab.castor.xml.ValidationException
296 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
297 validator.validate(this);