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