2719ecd230a46f151e526ebad86f69b3f2eb9ab1
[jalview.git] / src / jalview / schemabinding / version2 / JalviewUserColours.java
1 /*******************************************************************************
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
10  *  
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.
15  * 
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  ******************************************************************************/
20 /*
21  * This class was automatically generated with 
22  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
23  * Schema.
24  * $Id$
25  */
26
27 package jalview.schemabinding.version2;
28
29 //---------------------------------/
30 //- Imported classes and packages -/
31 //---------------------------------/
32
33 import org.exolab.castor.xml.Marshaller;
34 import org.exolab.castor.xml.Unmarshaller;
35
36 /**
37  * Class JalviewUserColours.
38  * 
39  * @version $Revision$ $Date$
40  */
41 public class JalviewUserColours implements java.io.Serializable
42 {
43
44   // --------------------------/
45   // - Class/Member Variables -/
46   // --------------------------/
47
48   /**
49    * Field _schemeName.
50    */
51   private java.lang.String _schemeName;
52
53   /**
54    * Jalview colour scheme document version.
55    * 
56    */
57   private java.lang.String _version;
58
59   /**
60    * Field _colourList.
61    */
62   private java.util.Vector _colourList;
63
64   // ----------------/
65   // - Constructors -/
66   // ----------------/
67
68   public JalviewUserColours()
69   {
70     super();
71     this._colourList = new java.util.Vector();
72   }
73
74   // -----------/
75   // - Methods -/
76   // -----------/
77
78   /**
79    * 
80    * 
81    * @param vColour
82    * @throws java.lang.IndexOutOfBoundsException
83    *           if the index given is outside the bounds of the collection
84    */
85   public void addColour(final Colour vColour)
86           throws java.lang.IndexOutOfBoundsException
87   {
88     this._colourList.addElement(vColour);
89   }
90
91   /**
92    * 
93    * 
94    * @param index
95    * @param vColour
96    * @throws java.lang.IndexOutOfBoundsException
97    *           if the index given is outside the bounds of the collection
98    */
99   public void addColour(final int index, final Colour vColour)
100           throws java.lang.IndexOutOfBoundsException
101   {
102     this._colourList.add(index, vColour);
103   }
104
105   /**
106    * Method enumerateColour.
107    * 
108    * @return an Enumeration over all Colour elements
109    */
110   public java.util.Enumeration enumerateColour()
111   {
112     return this._colourList.elements();
113   }
114
115   /**
116    * Method getColour.
117    * 
118    * @param index
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
122    */
123   public Colour getColour(final int index)
124           throws java.lang.IndexOutOfBoundsException
125   {
126     // check bounds for index
127     if (index < 0 || index >= this._colourList.size())
128     {
129       throw new IndexOutOfBoundsException("getColour: Index value '"
130               + index + "' not in range [0.."
131               + (this._colourList.size() - 1) + "]");
132     }
133
134     return (Colour) _colourList.get(index);
135   }
136
137   /**
138    * Method getColour.Returns the contents of the collection in an Array.
139    * <p>
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.
143    * 
144    * @return this collection as an Array
145    */
146   public Colour[] getColour()
147   {
148     Colour[] array = new Colour[0];
149     return (Colour[]) this._colourList.toArray(array);
150   }
151
152   /**
153    * Method getColourCount.
154    * 
155    * @return the size of this collection
156    */
157   public int getColourCount()
158   {
159     return this._colourList.size();
160   }
161
162   /**
163    * Returns the value of field 'schemeName'.
164    * 
165    * @return the value of field 'SchemeName'.
166    */
167   public java.lang.String getSchemeName()
168   {
169     return this._schemeName;
170   }
171
172   /**
173    * Returns the value of field 'version'. The field 'version' has the following
174    * description: Jalview colour scheme document version.
175    * 
176    * 
177    * @return the value of field 'Version'.
178    */
179   public java.lang.String getVersion()
180   {
181     return this._version;
182   }
183
184   /**
185    * Method isValid.
186    * 
187    * @return true if this object is valid according to the schema
188    */
189   public boolean isValid()
190   {
191     try
192     {
193       validate();
194     } catch (org.exolab.castor.xml.ValidationException vex)
195     {
196       return false;
197     }
198     return true;
199   }
200
201   /**
202    * 
203    * 
204    * @param out
205    * @throws org.exolab.castor.xml.MarshalException
206    *           if object is null or if any SAXException is thrown during
207    *           marshaling
208    * @throws org.exolab.castor.xml.ValidationException
209    *           if this object is an invalid instance according to the schema
210    */
211   public void marshal(final java.io.Writer out)
212           throws org.exolab.castor.xml.MarshalException,
213           org.exolab.castor.xml.ValidationException
214   {
215     Marshaller.marshal(this, out);
216   }
217
218   /**
219    * 
220    * 
221    * @param handler
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
228    *           marshaling
229    */
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
234   {
235     Marshaller.marshal(this, handler);
236   }
237
238   /**
239      */
240   public void removeAllColour()
241   {
242     this._colourList.clear();
243   }
244
245   /**
246    * Method removeColour.
247    * 
248    * @param vColour
249    * @return true if the object was removed from the collection.
250    */
251   public boolean removeColour(final Colour vColour)
252   {
253     boolean removed = _colourList.remove(vColour);
254     return removed;
255   }
256
257   /**
258    * Method removeColourAt.
259    * 
260    * @param index
261    * @return the element removed from the collection
262    */
263   public Colour removeColourAt(final int index)
264   {
265     java.lang.Object obj = this._colourList.remove(index);
266     return (Colour) obj;
267   }
268
269   /**
270    * 
271    * 
272    * @param index
273    * @param vColour
274    * @throws java.lang.IndexOutOfBoundsException
275    *           if the index given is outside the bounds of the collection
276    */
277   public void setColour(final int index, final Colour vColour)
278           throws java.lang.IndexOutOfBoundsException
279   {
280     // check bounds for index
281     if (index < 0 || index >= this._colourList.size())
282     {
283       throw new IndexOutOfBoundsException("setColour: Index value '"
284               + index + "' not in range [0.."
285               + (this._colourList.size() - 1) + "]");
286     }
287
288     this._colourList.set(index, vColour);
289   }
290
291   /**
292    * 
293    * 
294    * @param vColourArray
295    */
296   public void setColour(final Colour[] vColourArray)
297   {
298     // -- copy array
299     _colourList.clear();
300
301     for (int i = 0; i < vColourArray.length; i++)
302     {
303       this._colourList.add(vColourArray[i]);
304     }
305   }
306
307   /**
308    * Sets the value of field 'schemeName'.
309    * 
310    * @param schemeName
311    *          the value of field 'schemeName'.
312    */
313   public void setSchemeName(final java.lang.String schemeName)
314   {
315     this._schemeName = schemeName;
316   }
317
318   /**
319    * Sets the value of field 'version'. The field 'version' has the following
320    * description: Jalview colour scheme document version.
321    * 
322    * 
323    * @param version
324    *          the value of field 'version'.
325    */
326   public void setVersion(final java.lang.String version)
327   {
328     this._version = version;
329   }
330
331   /**
332    * Method unmarshal.
333    * 
334    * @param reader
335    * @throws org.exolab.castor.xml.MarshalException
336    *           if object is null or if any SAXException is thrown during
337    *           marshaling
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
341    */
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
346   {
347     return (jalview.schemabinding.version2.JalviewUserColours) Unmarshaller
348             .unmarshal(
349                     jalview.schemabinding.version2.JalviewUserColours.class,
350                     reader);
351   }
352
353   /**
354    * 
355    * 
356    * @throws org.exolab.castor.xml.ValidationException
357    *           if this object is an invalid instance according to the schema
358    */
359   public void validate() throws org.exolab.castor.xml.ValidationException
360   {
361     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
362     validator.validate(this);
363   }
364
365 }