Formatted source
[jalview.git] / src / jalview / binding / Annotation.java
1 /*\r
2  * This class was automatically generated with\r
3  * <a href="http://www.castor.org">Castor 0.9.6</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 /*\r
8 * Jalview - A Sequence Alignment Editor and Viewer\r
9 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
10 *\r
11 * This program is free software; you can redistribute it and/or\r
12 * modify it under the terms of the GNU General Public License\r
13 * as published by the Free Software Foundation; either version 2\r
14 * of the License, or (at your option) any later version.\r
15 *\r
16 * This program is distributed in the hope that it will be useful,\r
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
19 * GNU General Public License for more details.\r
20 *\r
21 * You should have received a copy of the GNU General Public License\r
22 * along with this program; if not, write to the Free Software\r
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
24 */\r
25 package jalview.binding;\r
26 \r
27 import org.exolab.castor.xml.MarshalException;\r
28 import org.exolab.castor.xml.Marshaller;\r
29 import org.exolab.castor.xml.Unmarshaller;\r
30 import org.exolab.castor.xml.ValidationException;\r
31 \r
32 import org.xml.sax.ContentHandler;\r
33 \r
34 //---------------------------------/\r
35 //- Imported classes and packages -/\r
36 //---------------------------------/\r
37 import java.io.IOException;\r
38 import java.io.Reader;\r
39 import java.io.Serializable;\r
40 import java.io.Writer;\r
41 \r
42 import java.util.Enumeration;\r
43 import java.util.Vector;\r
44 \r
45 \r
46 /**\r
47  * Class Annotation.\r
48  *\r
49  * @version $Revision$ $Date$\r
50  */\r
51 public class Annotation implements java.io.Serializable {\r
52     //--------------------------/\r
53     //- Class/Member Variables -/\r
54     //--------------------------/\r
55 \r
56     /**\r
57      * Field _graph\r
58      */\r
59     private boolean _graph;\r
60 \r
61     /**\r
62      * keeps track of state for field: _graph\r
63      */\r
64     private boolean _has_graph;\r
65 \r
66     /**\r
67      * Field _annotationElementList\r
68      */\r
69     private java.util.Vector _annotationElementList;\r
70 \r
71     /**\r
72      * Field _label\r
73      */\r
74     private java.lang.String _label;\r
75 \r
76     /**\r
77      * Field _description\r
78      */\r
79     private java.lang.String _description;\r
80 \r
81     //----------------/\r
82     //- Constructors -/\r
83     //----------------/\r
84     public Annotation() {\r
85         super();\r
86         _annotationElementList = new Vector();\r
87     }\r
88      //-- jalview.binding.Annotation()\r
89  //-----------/\r
90 \r
91     public void addAnnotationElement(\r
92         jalview.binding.AnnotationElement vAnnotationElement)\r
93         throws java.lang.IndexOutOfBoundsException {\r
94         _annotationElementList.addElement(vAnnotationElement);\r
95     }\r
96      //-- void addAnnotationElement(jalview.binding.AnnotationElement)\r
97 \r
98     /**\r
99      * Method addAnnotationElement\r
100      *\r
101      *\r
102      *\r
103      * @param index\r
104      * @param vAnnotationElement\r
105      */\r
106     public void addAnnotationElement(int index,\r
107         jalview.binding.AnnotationElement vAnnotationElement)\r
108         throws java.lang.IndexOutOfBoundsException {\r
109         _annotationElementList.insertElementAt(vAnnotationElement, index);\r
110     }\r
111      //-- void addAnnotationElement(int, jalview.binding.AnnotationElement)\r
112 \r
113     /**\r
114      * Method deleteGraph\r
115      *\r
116      */\r
117     public void deleteGraph() {\r
118         this._has_graph = false;\r
119     }\r
120      //-- void deleteGraph()\r
121 \r
122     /**\r
123      * Method enumerateAnnotationElement\r
124      *\r
125      *\r
126      *\r
127      * @return Enumeration\r
128      */\r
129     public java.util.Enumeration enumerateAnnotationElement() {\r
130         return _annotationElementList.elements();\r
131     }\r
132      //-- java.util.Enumeration enumerateAnnotationElement()\r
133 \r
134     /**\r
135      * Method getAnnotationElement\r
136      *\r
137      *\r
138      *\r
139      * @param index\r
140      * @return AnnotationElement\r
141      */\r
142     public jalview.binding.AnnotationElement getAnnotationElement(int index)\r
143         throws java.lang.IndexOutOfBoundsException {\r
144         //-- check bounds for index\r
145         if ((index < 0) || (index > _annotationElementList.size())) {\r
146             throw new IndexOutOfBoundsException();\r
147         }\r
148 \r
149         return (jalview.binding.AnnotationElement) _annotationElementList.elementAt(index);\r
150     }\r
151      //-- jalview.binding.AnnotationElement getAnnotationElement(int)\r
152 \r
153     /**\r
154      * Method getAnnotationElement\r
155      *\r
156      *\r
157      *\r
158      * @return AnnotationElement\r
159      */\r
160     public jalview.binding.AnnotationElement[] getAnnotationElement() {\r
161         int size = _annotationElementList.size();\r
162         jalview.binding.AnnotationElement[] mArray = new jalview.binding.AnnotationElement[size];\r
163 \r
164         for (int index = 0; index < size; index++) {\r
165             mArray[index] = (jalview.binding.AnnotationElement) _annotationElementList.elementAt(index);\r
166         }\r
167 \r
168         return mArray;\r
169     }\r
170      //-- jalview.binding.AnnotationElement[] getAnnotationElement()\r
171 \r
172     /**\r
173      * Method getAnnotationElementCount\r
174      *\r
175      *\r
176      *\r
177      * @return int\r
178      */\r
179     public int getAnnotationElementCount() {\r
180         return _annotationElementList.size();\r
181     }\r
182      //-- int getAnnotationElementCount()\r
183 \r
184     /**\r
185      * Returns the value of field 'description'.\r
186      *\r
187      * @return String\r
188      * @return the value of field 'description'.\r
189      */\r
190     public java.lang.String getDescription() {\r
191         return this._description;\r
192     }\r
193      //-- java.lang.String getDescription()\r
194 \r
195     /**\r
196      * Returns the value of field 'graph'.\r
197      *\r
198      * @return boolean\r
199      * @return the value of field 'graph'.\r
200      */\r
201     public boolean getGraph() {\r
202         return this._graph;\r
203     }\r
204      //-- boolean getGraph()\r
205 \r
206     /**\r
207      * Returns the value of field 'label'.\r
208      *\r
209      * @return String\r
210      * @return the value of field 'label'.\r
211      */\r
212     public java.lang.String getLabel() {\r
213         return this._label;\r
214     }\r
215      //-- java.lang.String getLabel()\r
216 \r
217     /**\r
218      * Method hasGraph\r
219      *\r
220      *\r
221      *\r
222      * @return boolean\r
223      */\r
224     public boolean hasGraph() {\r
225         return this._has_graph;\r
226     }\r
227      //-- boolean hasGraph()\r
228 \r
229     /**\r
230      * Method isValid\r
231      *\r
232      *\r
233      *\r
234      * @return boolean\r
235      */\r
236     public boolean isValid() {\r
237         try {\r
238             validate();\r
239         } catch (org.exolab.castor.xml.ValidationException vex) {\r
240             return false;\r
241         }\r
242 \r
243         return true;\r
244     }\r
245      //-- boolean isValid()\r
246 \r
247     /**\r
248      * Method marshal\r
249      *\r
250      *\r
251      *\r
252      * @param out\r
253      */\r
254     public void marshal(java.io.Writer out)\r
255         throws org.exolab.castor.xml.MarshalException, \r
256             org.exolab.castor.xml.ValidationException {\r
257         Marshaller.marshal(this, out);\r
258     }\r
259      //-- void marshal(java.io.Writer)\r
260 \r
261     /**\r
262      * Method marshal\r
263      *\r
264      *\r
265      *\r
266      * @param handler\r
267      */\r
268     public void marshal(org.xml.sax.ContentHandler handler)\r
269         throws java.io.IOException, org.exolab.castor.xml.MarshalException, \r
270             org.exolab.castor.xml.ValidationException {\r
271         Marshaller.marshal(this, handler);\r
272     }\r
273      //-- void marshal(org.xml.sax.ContentHandler)\r
274 \r
275     /**\r
276      * Method removeAllAnnotationElement\r
277      *\r
278      */\r
279     public void removeAllAnnotationElement() {\r
280         _annotationElementList.removeAllElements();\r
281     }\r
282      //-- void removeAllAnnotationElement()\r
283 \r
284     /**\r
285      * Method removeAnnotationElement\r
286      *\r
287      *\r
288      *\r
289      * @param index\r
290      * @return AnnotationElement\r
291      */\r
292     public jalview.binding.AnnotationElement removeAnnotationElement(int index) {\r
293         java.lang.Object obj = _annotationElementList.elementAt(index);\r
294         _annotationElementList.removeElementAt(index);\r
295 \r
296         return (jalview.binding.AnnotationElement) obj;\r
297     }\r
298      //-- jalview.binding.AnnotationElement removeAnnotationElement(int)\r
299 \r
300     /**\r
301      * Method setAnnotationElement\r
302      *\r
303      *\r
304      *\r
305      * @param index\r
306      * @param vAnnotationElement\r
307      */\r
308     public void setAnnotationElement(int index,\r
309         jalview.binding.AnnotationElement vAnnotationElement)\r
310         throws java.lang.IndexOutOfBoundsException {\r
311         //-- check bounds for index\r
312         if ((index < 0) || (index > _annotationElementList.size())) {\r
313             throw new IndexOutOfBoundsException();\r
314         }\r
315 \r
316         _annotationElementList.setElementAt(vAnnotationElement, index);\r
317     }\r
318      //-- void setAnnotationElement(int, jalview.binding.AnnotationElement)\r
319 \r
320     /**\r
321      * Method setAnnotationElement\r
322      *\r
323      *\r
324      *\r
325      * @param annotationElementArray\r
326      */\r
327     public void setAnnotationElement(\r
328         jalview.binding.AnnotationElement[] annotationElementArray) {\r
329         //-- copy array\r
330         _annotationElementList.removeAllElements();\r
331 \r
332         for (int i = 0; i < annotationElementArray.length; i++) {\r
333             _annotationElementList.addElement(annotationElementArray[i]);\r
334         }\r
335     }\r
336      //-- void setAnnotationElement(jalview.binding.AnnotationElement)\r
337 \r
338     /**\r
339      * Sets the value of field 'description'.\r
340      *\r
341      * @param description the value of field 'description'.\r
342      */\r
343     public void setDescription(java.lang.String description) {\r
344         this._description = description;\r
345     }\r
346      //-- void setDescription(java.lang.String)\r
347 \r
348     /**\r
349      * Sets the value of field 'graph'.\r
350      *\r
351      * @param graph the value of field 'graph'.\r
352      */\r
353     public void setGraph(boolean graph) {\r
354         this._graph = graph;\r
355         this._has_graph = true;\r
356     }\r
357      //-- void setGraph(boolean)\r
358 \r
359     /**\r
360      * Sets the value of field 'label'.\r
361      *\r
362      * @param label the value of field 'label'.\r
363      */\r
364     public void setLabel(java.lang.String label) {\r
365         this._label = label;\r
366     }\r
367      //-- void setLabel(java.lang.String)\r
368 \r
369     /**\r
370      * Method unmarshal\r
371      *\r
372      *\r
373      *\r
374      * @param reader\r
375      * @return Object\r
376      */\r
377     public static java.lang.Object unmarshal(java.io.Reader reader)\r
378         throws org.exolab.castor.xml.MarshalException, \r
379             org.exolab.castor.xml.ValidationException {\r
380         return (jalview.binding.Annotation) Unmarshaller.unmarshal(jalview.binding.Annotation.class,\r
381             reader);\r
382     }\r
383      //-- java.lang.Object unmarshal(java.io.Reader)\r
384 \r
385     /**\r
386      * Method validate\r
387      *\r
388      */\r
389     public void validate() throws org.exolab.castor.xml.ValidationException {\r
390         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
391         validator.validate(this);\r
392     }\r
393      //-- void validate()\r
394 }\r