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