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