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