update author list in license for (JAL-826)
[jalview.git] / src / jalview / binding / Annotation.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.binding;
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 Annotation.
36  * 
37  * @version $Revision$ $Date$
38  */
39 public class Annotation implements java.io.Serializable {
40
41
42       //--------------------------/
43      //- Class/Member Variables -/
44     //--------------------------/
45
46     /**
47      * Field _graph.
48      */
49     private boolean _graph;
50
51     /**
52      * keeps track of state for field: _graph
53      */
54     private boolean _has_graph;
55
56     /**
57      * Field _graphType.
58      */
59     private int _graphType;
60
61     /**
62      * keeps track of state for field: _graphType
63      */
64     private boolean _has_graphType;
65
66     /**
67      * Field _annotationElementList.
68      */
69     private java.util.Vector _annotationElementList;
70
71     /**
72      * Field _label.
73      */
74     private java.lang.String _label;
75
76     /**
77      * Field _description.
78      */
79     private java.lang.String _description;
80
81
82       //----------------/
83      //- Constructors -/
84     //----------------/
85
86     public Annotation() {
87         super();
88         this._annotationElementList = new java.util.Vector();
89     }
90
91
92       //-----------/
93      //- Methods -/
94     //-----------/
95
96     /**
97      * 
98      * 
99      * @param vAnnotationElement
100      * @throws java.lang.IndexOutOfBoundsException if the index
101      * given is outside the bounds of the collection
102      */
103     public void addAnnotationElement(
104             final jalview.binding.AnnotationElement vAnnotationElement)
105     throws java.lang.IndexOutOfBoundsException {
106         this._annotationElementList.addElement(vAnnotationElement);
107     }
108
109     /**
110      * 
111      * 
112      * @param index
113      * @param vAnnotationElement
114      * @throws java.lang.IndexOutOfBoundsException if the index
115      * given is outside the bounds of the collection
116      */
117     public void addAnnotationElement(
118             final int index,
119             final jalview.binding.AnnotationElement vAnnotationElement)
120     throws java.lang.IndexOutOfBoundsException {
121         this._annotationElementList.add(index, vAnnotationElement);
122     }
123
124     /**
125      */
126     public void deleteGraph(
127     ) {
128         this._has_graph= false;
129     }
130
131     /**
132      */
133     public void deleteGraphType(
134     ) {
135         this._has_graphType= false;
136     }
137
138     /**
139      * Method enumerateAnnotationElement.
140      * 
141      * @return an Enumeration over all
142      * jalview.binding.AnnotationElement elements
143      */
144     public java.util.Enumeration enumerateAnnotationElement(
145     ) {
146         return this._annotationElementList.elements();
147     }
148
149     /**
150      * Method getAnnotationElement.
151      * 
152      * @param index
153      * @throws java.lang.IndexOutOfBoundsException if the index
154      * given is outside the bounds of the collection
155      * @return the value of the jalview.binding.AnnotationElement
156      * at the given index
157      */
158     public jalview.binding.AnnotationElement getAnnotationElement(
159             final int index)
160     throws java.lang.IndexOutOfBoundsException {
161         // check bounds for index
162         if (index < 0 || index >= this._annotationElementList.size()) {
163             throw new IndexOutOfBoundsException("getAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]");
164         }
165         
166         return (jalview.binding.AnnotationElement) _annotationElementList.get(index);
167     }
168
169     /**
170      * Method getAnnotationElement.Returns the contents of the
171      * collection in an Array.  <p>Note:  Just in case the
172      * collection contents are changing in another thread, we pass
173      * a 0-length Array of the correct type into the API call. 
174      * This way we <i>know</i> that the Array returned is of
175      * exactly the correct length.
176      * 
177      * @return this collection as an Array
178      */
179     public jalview.binding.AnnotationElement[] getAnnotationElement(
180     ) {
181         jalview.binding.AnnotationElement[] array = new jalview.binding.AnnotationElement[0];
182         return (jalview.binding.AnnotationElement[]) this._annotationElementList.toArray(array);
183     }
184
185     /**
186      * Method getAnnotationElementCount.
187      * 
188      * @return the size of this collection
189      */
190     public int getAnnotationElementCount(
191     ) {
192         return this._annotationElementList.size();
193     }
194
195     /**
196      * Returns the value of field 'description'.
197      * 
198      * @return the value of field 'Description'.
199      */
200     public java.lang.String getDescription(
201     ) {
202         return this._description;
203     }
204
205     /**
206      * Returns the value of field 'graph'.
207      * 
208      * @return the value of field 'Graph'.
209      */
210     public boolean getGraph(
211     ) {
212         return this._graph;
213     }
214
215     /**
216      * Returns the value of field 'graphType'.
217      * 
218      * @return the value of field 'GraphType'.
219      */
220     public int getGraphType(
221     ) {
222         return this._graphType;
223     }
224
225     /**
226      * Returns the value of field 'label'.
227      * 
228      * @return the value of field 'Label'.
229      */
230     public java.lang.String getLabel(
231     ) {
232         return this._label;
233     }
234
235     /**
236      * Method hasGraph.
237      * 
238      * @return true if at least one Graph has been added
239      */
240     public boolean hasGraph(
241     ) {
242         return this._has_graph;
243     }
244
245     /**
246      * Method hasGraphType.
247      * 
248      * @return true if at least one GraphType has been added
249      */
250     public boolean hasGraphType(
251     ) {
252         return this._has_graphType;
253     }
254
255     /**
256      * Returns the value of field 'graph'.
257      * 
258      * @return the value of field 'Graph'.
259      */
260     public boolean isGraph(
261     ) {
262         return this._graph;
263     }
264
265     /**
266      * Method isValid.
267      * 
268      * @return true if this object is valid according to the schema
269      */
270     public boolean isValid(
271     ) {
272         try {
273             validate();
274         } catch (org.exolab.castor.xml.ValidationException vex) {
275             return false;
276         }
277         return true;
278     }
279
280     /**
281      * 
282      * 
283      * @param out
284      * @throws org.exolab.castor.xml.MarshalException if object is
285      * null or if any SAXException is thrown during marshaling
286      * @throws org.exolab.castor.xml.ValidationException if this
287      * object is an invalid instance according to the schema
288      */
289     public void marshal(
290             final java.io.Writer out)
291     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
292         Marshaller.marshal(this, out);
293     }
294
295     /**
296      * 
297      * 
298      * @param handler
299      * @throws java.io.IOException if an IOException occurs during
300      * marshaling
301      * @throws org.exolab.castor.xml.ValidationException if this
302      * object is an invalid instance according to the schema
303      * @throws org.exolab.castor.xml.MarshalException if object is
304      * null or if any SAXException is thrown during marshaling
305      */
306     public void marshal(
307             final org.xml.sax.ContentHandler handler)
308     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
309         Marshaller.marshal(this, handler);
310     }
311
312     /**
313      */
314     public void removeAllAnnotationElement(
315     ) {
316         this._annotationElementList.clear();
317     }
318
319     /**
320      * Method removeAnnotationElement.
321      * 
322      * @param vAnnotationElement
323      * @return true if the object was removed from the collection.
324      */
325     public boolean removeAnnotationElement(
326             final jalview.binding.AnnotationElement vAnnotationElement) {
327         boolean removed = _annotationElementList.remove(vAnnotationElement);
328         return removed;
329     }
330
331     /**
332      * Method removeAnnotationElementAt.
333      * 
334      * @param index
335      * @return the element removed from the collection
336      */
337     public jalview.binding.AnnotationElement removeAnnotationElementAt(
338             final int index) {
339         java.lang.Object obj = this._annotationElementList.remove(index);
340         return (jalview.binding.AnnotationElement) obj;
341     }
342
343     /**
344      * 
345      * 
346      * @param index
347      * @param vAnnotationElement
348      * @throws java.lang.IndexOutOfBoundsException if the index
349      * given is outside the bounds of the collection
350      */
351     public void setAnnotationElement(
352             final int index,
353             final jalview.binding.AnnotationElement vAnnotationElement)
354     throws java.lang.IndexOutOfBoundsException {
355         // check bounds for index
356         if (index < 0 || index >= this._annotationElementList.size()) {
357             throw new IndexOutOfBoundsException("setAnnotationElement: Index value '" + index + "' not in range [0.." + (this._annotationElementList.size() - 1) + "]");
358         }
359         
360         this._annotationElementList.set(index, vAnnotationElement);
361     }
362
363     /**
364      * 
365      * 
366      * @param vAnnotationElementArray
367      */
368     public void setAnnotationElement(
369             final jalview.binding.AnnotationElement[] vAnnotationElementArray) {
370         //-- copy array
371         _annotationElementList.clear();
372         
373         for (int i = 0; i < vAnnotationElementArray.length; i++) {
374                 this._annotationElementList.add(vAnnotationElementArray[i]);
375         }
376     }
377
378     /**
379      * Sets the value of field 'description'.
380      * 
381      * @param description the value of field 'description'.
382      */
383     public void setDescription(
384             final java.lang.String description) {
385         this._description = description;
386     }
387
388     /**
389      * Sets the value of field 'graph'.
390      * 
391      * @param graph the value of field 'graph'.
392      */
393     public void setGraph(
394             final boolean graph) {
395         this._graph = graph;
396         this._has_graph = true;
397     }
398
399     /**
400      * Sets the value of field 'graphType'.
401      * 
402      * @param graphType the value of field 'graphType'.
403      */
404     public void setGraphType(
405             final int graphType) {
406         this._graphType = graphType;
407         this._has_graphType = true;
408     }
409
410     /**
411      * Sets the value of field 'label'.
412      * 
413      * @param label the value of field 'label'.
414      */
415     public void setLabel(
416             final java.lang.String label) {
417         this._label = label;
418     }
419
420     /**
421      * Method unmarshal.
422      * 
423      * @param reader
424      * @throws org.exolab.castor.xml.MarshalException if object is
425      * null or if any SAXException is thrown during marshaling
426      * @throws org.exolab.castor.xml.ValidationException if this
427      * object is an invalid instance according to the schema
428      * @return the unmarshaled jalview.binding.Annotation
429      */
430     public static jalview.binding.Annotation unmarshal(
431             final java.io.Reader reader)
432     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
433         return (jalview.binding.Annotation) Unmarshaller.unmarshal(jalview.binding.Annotation.class, reader);
434     }
435
436     /**
437      * 
438      * 
439      * @throws org.exolab.castor.xml.ValidationException if this
440      * object is an invalid instance according to the schema
441      */
442     public void validate(
443     )
444     throws org.exolab.castor.xml.ValidationException {
445         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
446         validator.validate(this);
447     }
448
449 }