3c5e52d5c00f66165e327066c977f4340d5ac508
[jalview.git] / src / jalview / binding / AnnotationElement.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3  * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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 package jalview.binding;
19
20 //---------------------------------/
21 //- Imported classes and packages -/
22 //---------------------------------/
23
24 import org.exolab.castor.xml.Marshaller;
25 import org.exolab.castor.xml.Unmarshaller;
26
27 /**
28  * Class AnnotationElement.
29  * 
30  * @version $Revision$ $Date$
31  */
32 public class AnnotationElement implements java.io.Serializable
33 {
34
35   // --------------------------/
36   // - Class/Member Variables -/
37   // --------------------------/
38
39   /**
40    * Field _position.
41    */
42   private int _position;
43
44   /**
45    * keeps track of state for field: _position
46    */
47   private boolean _has_position;
48
49   /**
50    * Field _displayCharacter.
51    */
52   private java.lang.String _displayCharacter;
53
54   /**
55    * Field _description.
56    */
57   private java.lang.String _description;
58
59   /**
60    * Field _secondaryStructure.
61    */
62   private java.lang.String _secondaryStructure;
63
64   /**
65    * Field _value.
66    */
67   private float _value;
68
69   /**
70    * keeps track of state for field: _value
71    */
72   private boolean _has_value;
73
74   // ----------------/
75   // - Constructors -/
76   // ----------------/
77
78   public AnnotationElement()
79   {
80     super();
81   }
82
83   // -----------/
84   // - Methods -/
85   // -----------/
86
87   /**
88      */
89   public void deletePosition()
90   {
91     this._has_position = false;
92   }
93
94   /**
95      */
96   public void deleteValue()
97   {
98     this._has_value = false;
99   }
100
101   /**
102    * Returns the value of field 'description'.
103    * 
104    * @return the value of field 'Description'.
105    */
106   public java.lang.String getDescription()
107   {
108     return this._description;
109   }
110
111   /**
112    * Returns the value of field 'displayCharacter'.
113    * 
114    * @return the value of field 'DisplayCharacter'.
115    */
116   public java.lang.String getDisplayCharacter()
117   {
118     return this._displayCharacter;
119   }
120
121   /**
122    * Returns the value of field 'position'.
123    * 
124    * @return the value of field 'Position'.
125    */
126   public int getPosition()
127   {
128     return this._position;
129   }
130
131   /**
132    * Returns the value of field 'secondaryStructure'.
133    * 
134    * @return the value of field 'SecondaryStructure'.
135    */
136   public java.lang.String getSecondaryStructure()
137   {
138     return this._secondaryStructure;
139   }
140
141   /**
142    * Returns the value of field 'value'.
143    * 
144    * @return the value of field 'Value'.
145    */
146   public float getValue()
147   {
148     return this._value;
149   }
150
151   /**
152    * Method hasPosition.
153    * 
154    * @return true if at least one Position has been added
155    */
156   public boolean hasPosition()
157   {
158     return this._has_position;
159   }
160
161   /**
162    * Method hasValue.
163    * 
164    * @return true if at least one Value has been added
165    */
166   public boolean hasValue()
167   {
168     return this._has_value;
169   }
170
171   /**
172    * Method isValid.
173    * 
174    * @return true if this object is valid according to the schema
175    */
176   public boolean isValid()
177   {
178     try
179     {
180       validate();
181     } catch (org.exolab.castor.xml.ValidationException vex)
182     {
183       return false;
184     }
185     return true;
186   }
187
188   /**
189    * 
190    * 
191    * @param out
192    * @throws org.exolab.castor.xml.MarshalException
193    *           if object is null or if any SAXException is thrown during
194    *           marshaling
195    * @throws org.exolab.castor.xml.ValidationException
196    *           if this object is an invalid instance according to the schema
197    */
198   public void marshal(final java.io.Writer out)
199           throws org.exolab.castor.xml.MarshalException,
200           org.exolab.castor.xml.ValidationException
201   {
202     Marshaller.marshal(this, out);
203   }
204
205   /**
206    * 
207    * 
208    * @param handler
209    * @throws java.io.IOException
210    *           if an IOException occurs during marshaling
211    * @throws org.exolab.castor.xml.ValidationException
212    *           if this object is an invalid instance according to the schema
213    * @throws org.exolab.castor.xml.MarshalException
214    *           if object is null or if any SAXException is thrown during
215    *           marshaling
216    */
217   public void marshal(final org.xml.sax.ContentHandler handler)
218           throws java.io.IOException,
219           org.exolab.castor.xml.MarshalException,
220           org.exolab.castor.xml.ValidationException
221   {
222     Marshaller.marshal(this, handler);
223   }
224
225   /**
226    * Sets the value of field 'description'.
227    * 
228    * @param description
229    *          the value of field 'description'.
230    */
231   public void setDescription(final java.lang.String description)
232   {
233     this._description = description;
234   }
235
236   /**
237    * Sets the value of field 'displayCharacter'.
238    * 
239    * @param displayCharacter
240    *          the value of field 'displayCharacter'
241    */
242   public void setDisplayCharacter(final java.lang.String displayCharacter)
243   {
244     this._displayCharacter = displayCharacter;
245   }
246
247   /**
248    * Sets the value of field 'position'.
249    * 
250    * @param position
251    *          the value of field 'position'.
252    */
253   public void setPosition(final int position)
254   {
255     this._position = position;
256     this._has_position = true;
257   }
258
259   /**
260    * Sets the value of field 'secondaryStructure'.
261    * 
262    * @param secondaryStructure
263    *          the value of field 'secondaryStructure'.
264    */
265   public void setSecondaryStructure(
266           final java.lang.String secondaryStructure)
267   {
268     this._secondaryStructure = secondaryStructure;
269   }
270
271   /**
272    * Sets the value of field 'value'.
273    * 
274    * @param value
275    *          the value of field 'value'.
276    */
277   public void setValue(final float value)
278   {
279     this._value = value;
280     this._has_value = true;
281   }
282
283   /**
284    * Method unmarshal.
285    * 
286    * @param reader
287    * @throws org.exolab.castor.xml.MarshalException
288    *           if object is null or if any SAXException is thrown during
289    *           marshaling
290    * @throws org.exolab.castor.xml.ValidationException
291    *           if this object is an invalid instance according to the schema
292    * @return the unmarshaled jalview.binding.AnnotationElement
293    */
294   public static jalview.binding.AnnotationElement unmarshal(
295           final java.io.Reader reader)
296           throws org.exolab.castor.xml.MarshalException,
297           org.exolab.castor.xml.ValidationException
298   {
299     return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal(
300             jalview.binding.AnnotationElement.class, reader);
301   }
302
303   /**
304    * 
305    * 
306    * @throws org.exolab.castor.xml.ValidationException
307    *           if this object is an invalid instance according to the schema
308    */
309   public void validate() throws org.exolab.castor.xml.ValidationException
310   {
311     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
312     validator.validate(this);
313   }
314
315 }