merge from 2_4_Release branch
[jalview.git] / src / jalview / schemabinding / version2 / AnnotationElement.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  * \r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  * \r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  * \r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.schemabinding.version2;\r
20 \r
21 // ---------------------------------/\r
22 // - Imported classes and packages -/\r
23 // ---------------------------------/\r
24 \r
25 import org.exolab.castor.xml.Marshaller;\r
26 import org.exolab.castor.xml.Unmarshaller;\r
27 \r
28 /**\r
29  * Class AnnotationElement.\r
30  * \r
31  * @version $Revision$ $Date$\r
32  */\r
33 public class AnnotationElement implements java.io.Serializable\r
34 {\r
35 \r
36   // --------------------------/\r
37   // - Class/Member Variables -/\r
38   // --------------------------/\r
39 \r
40   /**\r
41    * Field _position.\r
42    */\r
43   private int _position;\r
44 \r
45   /**\r
46    * keeps track of state for field: _position\r
47    */\r
48   private boolean _has_position;\r
49 \r
50   /**\r
51    * Field _colour.\r
52    */\r
53   private int _colour;\r
54 \r
55   /**\r
56    * keeps track of state for field: _colour\r
57    */\r
58   private boolean _has_colour;\r
59 \r
60   /**\r
61    * Field _displayCharacter.\r
62    */\r
63   private java.lang.String _displayCharacter;\r
64 \r
65   /**\r
66    * Field _description.\r
67    */\r
68   private java.lang.String _description;\r
69 \r
70   /**\r
71    * Field _secondaryStructure.\r
72    */\r
73   private java.lang.String _secondaryStructure;\r
74 \r
75   /**\r
76    * Field _value.\r
77    */\r
78   private float _value;\r
79 \r
80   /**\r
81    * keeps track of state for field: _value\r
82    */\r
83   private boolean _has_value;\r
84 \r
85   // ----------------/\r
86   // - Constructors -/\r
87   // ----------------/\r
88 \r
89   public AnnotationElement()\r
90   {\r
91     super();\r
92   }\r
93 \r
94   // -----------/\r
95   // - Methods -/\r
96   // -----------/\r
97 \r
98   /**\r
99    */\r
100   public void deleteColour()\r
101   {\r
102     this._has_colour = false;\r
103   }\r
104 \r
105   /**\r
106    */\r
107   public void deletePosition()\r
108   {\r
109     this._has_position = false;\r
110   }\r
111 \r
112   /**\r
113    */\r
114   public void deleteValue()\r
115   {\r
116     this._has_value = false;\r
117   }\r
118 \r
119   /**\r
120    * Returns the value of field 'colour'.\r
121    * \r
122    * @return the value of field 'Colour'.\r
123    */\r
124   public int getColour()\r
125   {\r
126     return this._colour;\r
127   }\r
128 \r
129   /**\r
130    * Returns the value of field 'description'.\r
131    * \r
132    * @return the value of field 'Description'.\r
133    */\r
134   public java.lang.String getDescription()\r
135   {\r
136     return this._description;\r
137   }\r
138 \r
139   /**\r
140    * Returns the value of field 'displayCharacter'.\r
141    * \r
142    * @return the value of field 'DisplayCharacter'.\r
143    */\r
144   public java.lang.String getDisplayCharacter()\r
145   {\r
146     return this._displayCharacter;\r
147   }\r
148 \r
149   /**\r
150    * Returns the value of field 'position'.\r
151    * \r
152    * @return the value of field 'Position'.\r
153    */\r
154   public int getPosition()\r
155   {\r
156     return this._position;\r
157   }\r
158 \r
159   /**\r
160    * Returns the value of field 'secondaryStructure'.\r
161    * \r
162    * @return the value of field 'SecondaryStructure'.\r
163    */\r
164   public java.lang.String getSecondaryStructure()\r
165   {\r
166     return this._secondaryStructure;\r
167   }\r
168 \r
169   /**\r
170    * Returns the value of field 'value'.\r
171    * \r
172    * @return the value of field 'Value'.\r
173    */\r
174   public float getValue()\r
175   {\r
176     return this._value;\r
177   }\r
178 \r
179   /**\r
180    * Method hasColour.\r
181    * \r
182    * @return true if at least one Colour has been added\r
183    */\r
184   public boolean hasColour()\r
185   {\r
186     return this._has_colour;\r
187   }\r
188 \r
189   /**\r
190    * Method hasPosition.\r
191    * \r
192    * @return true if at least one Position has been added\r
193    */\r
194   public boolean hasPosition()\r
195   {\r
196     return this._has_position;\r
197   }\r
198 \r
199   /**\r
200    * Method hasValue.\r
201    * \r
202    * @return true if at least one Value has been added\r
203    */\r
204   public boolean hasValue()\r
205   {\r
206     return this._has_value;\r
207   }\r
208 \r
209   /**\r
210    * Method isValid.\r
211    * \r
212    * @return true if this object is valid according to the schema\r
213    */\r
214   public boolean isValid()\r
215   {\r
216     try\r
217     {\r
218       validate();\r
219     } catch (org.exolab.castor.xml.ValidationException vex)\r
220     {\r
221       return false;\r
222     }\r
223     return true;\r
224   }\r
225 \r
226   /**\r
227    * \r
228    * \r
229    * @param out\r
230    * @throws org.exolab.castor.xml.MarshalException\r
231    *                 if object is null or if any SAXException is thrown during\r
232    *                 marshaling\r
233    * @throws org.exolab.castor.xml.ValidationException\r
234    *                 if this object is an invalid instance according to the\r
235    *                 schema\r
236    */\r
237   public void marshal(final java.io.Writer out)\r
238           throws org.exolab.castor.xml.MarshalException,\r
239           org.exolab.castor.xml.ValidationException\r
240   {\r
241     Marshaller.marshal(this, out);\r
242   }\r
243 \r
244   /**\r
245    * \r
246    * \r
247    * @param handler\r
248    * @throws java.io.IOException\r
249    *                 if an IOException occurs during marshaling\r
250    * @throws org.exolab.castor.xml.ValidationException\r
251    *                 if this object is an invalid instance according to the\r
252    *                 schema\r
253    * @throws org.exolab.castor.xml.MarshalException\r
254    *                 if object is null or if any SAXException is thrown during\r
255    *                 marshaling\r
256    */\r
257   public void marshal(final org.xml.sax.ContentHandler handler)\r
258           throws java.io.IOException,\r
259           org.exolab.castor.xml.MarshalException,\r
260           org.exolab.castor.xml.ValidationException\r
261   {\r
262     Marshaller.marshal(this, handler);\r
263   }\r
264 \r
265   /**\r
266    * Sets the value of field 'colour'.\r
267    * \r
268    * @param colour\r
269    *                the value of field 'colour'.\r
270    */\r
271   public void setColour(final int colour)\r
272   {\r
273     this._colour = colour;\r
274     this._has_colour = true;\r
275   }\r
276 \r
277   /**\r
278    * Sets the value of field 'description'.\r
279    * \r
280    * @param description\r
281    *                the value of field 'description'.\r
282    */\r
283   public void setDescription(final java.lang.String description)\r
284   {\r
285     this._description = description;\r
286   }\r
287 \r
288   /**\r
289    * Sets the value of field 'displayCharacter'.\r
290    * \r
291    * @param displayCharacter\r
292    *                the value of field 'displayCharacter'\r
293    */\r
294   public void setDisplayCharacter(final java.lang.String displayCharacter)\r
295   {\r
296     this._displayCharacter = displayCharacter;\r
297   }\r
298 \r
299   /**\r
300    * Sets the value of field 'position'.\r
301    * \r
302    * @param position\r
303    *                the value of field 'position'.\r
304    */\r
305   public void setPosition(final int position)\r
306   {\r
307     this._position = position;\r
308     this._has_position = true;\r
309   }\r
310 \r
311   /**\r
312    * Sets the value of field 'secondaryStructure'.\r
313    * \r
314    * @param secondaryStructure\r
315    *                the value of field 'secondaryStructure'.\r
316    */\r
317   public void setSecondaryStructure(\r
318           final java.lang.String secondaryStructure)\r
319   {\r
320     this._secondaryStructure = secondaryStructure;\r
321   }\r
322 \r
323   /**\r
324    * Sets the value of field 'value'.\r
325    * \r
326    * @param value\r
327    *                the value of field 'value'.\r
328    */\r
329   public void setValue(final float value)\r
330   {\r
331     this._value = value;\r
332     this._has_value = true;\r
333   }\r
334 \r
335   /**\r
336    * Method unmarshal.\r
337    * \r
338    * @param reader\r
339    * @throws org.exolab.castor.xml.MarshalException\r
340    *                 if object is null or if any SAXException is thrown during\r
341    *                 marshaling\r
342    * @throws org.exolab.castor.xml.ValidationException\r
343    *                 if this object is an invalid instance according to the\r
344    *                 schema\r
345    * @return the unmarshaled jalview.schemabinding.version2.AnnotationElement\r
346    */\r
347   public static jalview.schemabinding.version2.AnnotationElement unmarshal(\r
348           final java.io.Reader reader)\r
349           throws org.exolab.castor.xml.MarshalException,\r
350           org.exolab.castor.xml.ValidationException\r
351   {\r
352     return (jalview.schemabinding.version2.AnnotationElement) Unmarshaller\r
353             .unmarshal(\r
354                     jalview.schemabinding.version2.AnnotationElement.class,\r
355                     reader);\r
356   }\r
357 \r
358   /**\r
359    * \r
360    * \r
361    * @throws org.exolab.castor.xml.ValidationException\r
362    *                 if this object is an invalid instance according to the\r
363    *                 schema\r
364    */\r
365   public void validate() throws org.exolab.castor.xml.ValidationException\r
366   {\r
367     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
368     validator.validate(this);\r
369   }\r
370 \r
371 }\r