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