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