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