1 /*******************************************************************************
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.
17 * If not, see <http://www.gnu.org/licenses/>.
18 * The Jalview Authors are detailed in the 'AUTHORS' file.
19 ******************************************************************************/
21 * This class was automatically generated with
22 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
27 package jalview.schemabinding.version2;
29 //---------------------------------/
30 //- Imported classes and packages -/
31 //---------------------------------/
33 import org.exolab.castor.xml.Marshaller;
34 import org.exolab.castor.xml.Unmarshaller;
37 * Class JalviewUserColours.
39 * @version $Revision$ $Date$
41 public class JalviewUserColours implements java.io.Serializable
44 // --------------------------/
45 // - Class/Member Variables -/
46 // --------------------------/
51 private java.lang.String _schemeName;
54 * Jalview colour scheme document version.
57 private java.lang.String _version;
62 private java.util.Vector _colourList;
68 public JalviewUserColours()
71 this._colourList = new java.util.Vector();
82 * @throws java.lang.IndexOutOfBoundsException
83 * if the index given is outside the bounds of the collection
85 public void addColour(final Colour vColour)
86 throws java.lang.IndexOutOfBoundsException
88 this._colourList.addElement(vColour);
96 * @throws java.lang.IndexOutOfBoundsException
97 * if the index given is outside the bounds of the collection
99 public void addColour(final int index, final Colour vColour)
100 throws java.lang.IndexOutOfBoundsException
102 this._colourList.add(index, vColour);
106 * Method enumerateColour.
108 * @return an Enumeration over all Colour elements
110 public java.util.Enumeration enumerateColour()
112 return this._colourList.elements();
119 * @throws java.lang.IndexOutOfBoundsException
120 * if the index given is outside the bounds of the collection
121 * @return the value of the Colour at the given index
123 public Colour getColour(final int index)
124 throws java.lang.IndexOutOfBoundsException
126 // check bounds for index
127 if (index < 0 || index >= this._colourList.size())
129 throw new IndexOutOfBoundsException("getColour: Index value '"
130 + index + "' not in range [0.."
131 + (this._colourList.size() - 1) + "]");
134 return (Colour) _colourList.get(index);
138 * Method getColour.Returns the contents of the collection in an Array.
140 * Note: Just in case the collection contents are changing in another thread,
141 * we pass a 0-length Array of the correct type into the API call. This way we
142 * <i>know</i> that the Array returned is of exactly the correct length.
144 * @return this collection as an Array
146 public Colour[] getColour()
148 Colour[] array = new Colour[0];
149 return (Colour[]) this._colourList.toArray(array);
153 * Method getColourCount.
155 * @return the size of this collection
157 public int getColourCount()
159 return this._colourList.size();
163 * Returns the value of field 'schemeName'.
165 * @return the value of field 'SchemeName'.
167 public java.lang.String getSchemeName()
169 return this._schemeName;
173 * Returns the value of field 'version'. The field 'version' has the following
174 * description: Jalview colour scheme document version.
177 * @return the value of field 'Version'.
179 public java.lang.String getVersion()
181 return this._version;
187 * @return true if this object is valid according to the schema
189 public boolean isValid()
194 } catch (org.exolab.castor.xml.ValidationException vex)
205 * @throws org.exolab.castor.xml.MarshalException
206 * if object is null or if any SAXException is thrown during
208 * @throws org.exolab.castor.xml.ValidationException
209 * if this object is an invalid instance according to the schema
211 public void marshal(final java.io.Writer out)
212 throws org.exolab.castor.xml.MarshalException,
213 org.exolab.castor.xml.ValidationException
215 Marshaller.marshal(this, out);
222 * @throws java.io.IOException
223 * if an IOException occurs during marshaling
224 * @throws org.exolab.castor.xml.ValidationException
225 * if this object is an invalid instance according to the schema
226 * @throws org.exolab.castor.xml.MarshalException
227 * if object is null or if any SAXException is thrown during
230 public void marshal(final org.xml.sax.ContentHandler handler)
231 throws java.io.IOException,
232 org.exolab.castor.xml.MarshalException,
233 org.exolab.castor.xml.ValidationException
235 Marshaller.marshal(this, handler);
240 public void removeAllColour()
242 this._colourList.clear();
246 * Method removeColour.
249 * @return true if the object was removed from the collection.
251 public boolean removeColour(final Colour vColour)
253 boolean removed = _colourList.remove(vColour);
258 * Method removeColourAt.
261 * @return the element removed from the collection
263 public Colour removeColourAt(final int index)
265 java.lang.Object obj = this._colourList.remove(index);
274 * @throws java.lang.IndexOutOfBoundsException
275 * if the index given is outside the bounds of the collection
277 public void setColour(final int index, final Colour vColour)
278 throws java.lang.IndexOutOfBoundsException
280 // check bounds for index
281 if (index < 0 || index >= this._colourList.size())
283 throw new IndexOutOfBoundsException("setColour: Index value '"
284 + index + "' not in range [0.."
285 + (this._colourList.size() - 1) + "]");
288 this._colourList.set(index, vColour);
294 * @param vColourArray
296 public void setColour(final Colour[] vColourArray)
301 for (int i = 0; i < vColourArray.length; i++)
303 this._colourList.add(vColourArray[i]);
308 * Sets the value of field 'schemeName'.
311 * the value of field 'schemeName'.
313 public void setSchemeName(final java.lang.String schemeName)
315 this._schemeName = schemeName;
319 * Sets the value of field 'version'. The field 'version' has the following
320 * description: Jalview colour scheme document version.
324 * the value of field 'version'.
326 public void setVersion(final java.lang.String version)
328 this._version = version;
335 * @throws org.exolab.castor.xml.MarshalException
336 * if object is null or if any SAXException is thrown during
338 * @throws org.exolab.castor.xml.ValidationException
339 * if this object is an invalid instance according to the schema
340 * @return the unmarshaled jalview.schemabinding.version2.JalviewUserColours
342 public static jalview.schemabinding.version2.JalviewUserColours unmarshal(
343 final java.io.Reader reader)
344 throws org.exolab.castor.xml.MarshalException,
345 org.exolab.castor.xml.ValidationException
347 return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller
349 jalview.schemabinding.version2.JalviewUserColours.class,
356 * @throws org.exolab.castor.xml.ValidationException
357 * if this object is an invalid instance according to the schema
359 public void validate() throws org.exolab.castor.xml.ValidationException
361 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
362 validator.validate(this);