jalview 2.0 XML schema versions for backwards compatibility in future castor upgrades
[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      * Field _colourList.
36      */
37     private java.util.Vector _colourList;
38
39
40       //----------------/
41      //- Constructors -/
42     //----------------/
43
44     public JalviewUserColours() {
45         super();
46         this._colourList = new java.util.Vector();
47     }
48
49
50       //-----------/
51      //- Methods -/
52     //-----------/
53
54     /**
55      * 
56      * 
57      * @param vColour
58      * @throws java.lang.IndexOutOfBoundsException if the index
59      * given is outside the bounds of the collection
60      */
61     public void addColour(
62             final Colour vColour)
63     throws java.lang.IndexOutOfBoundsException {
64         this._colourList.addElement(vColour);
65     }
66
67     /**
68      * 
69      * 
70      * @param index
71      * @param vColour
72      * @throws java.lang.IndexOutOfBoundsException if the index
73      * given is outside the bounds of the collection
74      */
75     public void addColour(
76             final int index,
77             final Colour vColour)
78     throws java.lang.IndexOutOfBoundsException {
79         this._colourList.add(index, vColour);
80     }
81
82     /**
83      * Method enumerateColour.
84      * 
85      * @return an Enumeration over all Colour elements
86      */
87     public java.util.Enumeration enumerateColour(
88     ) {
89         return this._colourList.elements();
90     }
91
92     /**
93      * Method getColour.
94      * 
95      * @param index
96      * @throws java.lang.IndexOutOfBoundsException if the index
97      * given is outside the bounds of the collection
98      * @return the value of the Colour at the given index
99      */
100     public Colour getColour(
101             final int index)
102     throws java.lang.IndexOutOfBoundsException {
103         // check bounds for index
104         if (index < 0 || index >= this._colourList.size()) {
105             throw new IndexOutOfBoundsException("getColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
106         }
107         
108         return (Colour) _colourList.get(index);
109     }
110
111     /**
112      * Method getColour.Returns the contents of the collection in
113      * an Array.  <p>Note:  Just in case the collection contents
114      * are changing in another thread, we pass a 0-length Array of
115      * the correct type into the API call.  This way we <i>know</i>
116      * that the Array returned is of exactly the correct length.
117      * 
118      * @return this collection as an Array
119      */
120     public Colour[] getColour(
121     ) {
122         Colour[] array = new Colour[0];
123         return (Colour[]) this._colourList.toArray(array);
124     }
125
126     /**
127      * Method getColourCount.
128      * 
129      * @return the size of this collection
130      */
131     public int getColourCount(
132     ) {
133         return this._colourList.size();
134     }
135
136     /**
137      * Returns the value of field 'schemeName'.
138      * 
139      * @return the value of field 'SchemeName'.
140      */
141     public java.lang.String getSchemeName(
142     ) {
143         return this._schemeName;
144     }
145
146     /**
147      * Method isValid.
148      * 
149      * @return true if this object is valid according to the schema
150      */
151     public boolean isValid(
152     ) {
153         try {
154             validate();
155         } catch (org.exolab.castor.xml.ValidationException vex) {
156             return false;
157         }
158         return true;
159     }
160
161     /**
162      * 
163      * 
164      * @param out
165      * @throws org.exolab.castor.xml.MarshalException if object is
166      * null or if any SAXException is thrown during marshaling
167      * @throws org.exolab.castor.xml.ValidationException if this
168      * object is an invalid instance according to the schema
169      */
170     public void marshal(
171             final java.io.Writer out)
172     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
173         Marshaller.marshal(this, out);
174     }
175
176     /**
177      * 
178      * 
179      * @param handler
180      * @throws java.io.IOException if an IOException occurs during
181      * marshaling
182      * @throws org.exolab.castor.xml.ValidationException if this
183      * object is an invalid instance according to the schema
184      * @throws org.exolab.castor.xml.MarshalException if object is
185      * null or if any SAXException is thrown during marshaling
186      */
187     public void marshal(
188             final org.xml.sax.ContentHandler handler)
189     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
190         Marshaller.marshal(this, handler);
191     }
192
193     /**
194      */
195     public void removeAllColour(
196     ) {
197         this._colourList.clear();
198     }
199
200     /**
201      * Method removeColour.
202      * 
203      * @param vColour
204      * @return true if the object was removed from the collection.
205      */
206     public boolean removeColour(
207             final Colour vColour) {
208         boolean removed = _colourList.remove(vColour);
209         return removed;
210     }
211
212     /**
213      * Method removeColourAt.
214      * 
215      * @param index
216      * @return the element removed from the collection
217      */
218     public Colour removeColourAt(
219             final int index) {
220         java.lang.Object obj = this._colourList.remove(index);
221         return (Colour) obj;
222     }
223
224     /**
225      * 
226      * 
227      * @param index
228      * @param vColour
229      * @throws java.lang.IndexOutOfBoundsException if the index
230      * given is outside the bounds of the collection
231      */
232     public void setColour(
233             final int index,
234             final Colour vColour)
235     throws java.lang.IndexOutOfBoundsException {
236         // check bounds for index
237         if (index < 0 || index >= this._colourList.size()) {
238             throw new IndexOutOfBoundsException("setColour: Index value '" + index + "' not in range [0.." + (this._colourList.size() - 1) + "]");
239         }
240         
241         this._colourList.set(index, vColour);
242     }
243
244     /**
245      * 
246      * 
247      * @param vColourArray
248      */
249     public void setColour(
250             final Colour[] vColourArray) {
251         //-- copy array
252         _colourList.clear();
253         
254         for (int i = 0; i < vColourArray.length; i++) {
255                 this._colourList.add(vColourArray[i]);
256         }
257     }
258
259     /**
260      * Sets the value of field 'schemeName'.
261      * 
262      * @param schemeName the value of field 'schemeName'.
263      */
264     public void setSchemeName(
265             final java.lang.String schemeName) {
266         this._schemeName = schemeName;
267     }
268
269     /**
270      * Method unmarshal.
271      * 
272      * @param reader
273      * @throws org.exolab.castor.xml.MarshalException if object is
274      * null or if any SAXException is thrown during marshaling
275      * @throws org.exolab.castor.xml.ValidationException if this
276      * object is an invalid instance according to the schema
277      * @return the unmarshaled jalview.binding.JalviewUserColours
278      */
279     public static jalview.binding.JalviewUserColours unmarshal(
280             final java.io.Reader reader)
281     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
282         return (jalview.binding.JalviewUserColours) Unmarshaller.unmarshal(jalview.binding.JalviewUserColours.class, reader);
283     }
284
285     /**
286      * 
287      * 
288      * @throws org.exolab.castor.xml.ValidationException if this
289      * object is an invalid instance according to the schema
290      */
291     public void validate(
292     )
293     throws org.exolab.castor.xml.ValidationException {
294         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
295         validator.validate(this);
296     }
297
298 }