merge from 2_4_Release branch
[jalview.git] / src / jalview / binding / AnnotationElement.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)
3  * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
4  * 
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18  */
19 package jalview.binding;
20
21 // ---------------------------------/
22 // - Imported classes and packages -/
23 // ---------------------------------/
24
25 import org.exolab.castor.xml.Marshaller;
26 import org.exolab.castor.xml.Unmarshaller;
27
28 /**
29  * Class AnnotationElement.
30  * 
31  * @version $Revision$ $Date$
32  */
33 public class AnnotationElement implements java.io.Serializable
34 {
35
36   // --------------------------/
37   // - Class/Member Variables -/
38   // --------------------------/
39
40   /**
41    * Field _position.
42    */
43   private int _position;
44
45   /**
46    * keeps track of state for field: _position
47    */
48   private boolean _has_position;
49
50   /**
51    * Field _displayCharacter.
52    */
53   private java.lang.String _displayCharacter;
54
55   /**
56    * Field _description.
57    */
58   private java.lang.String _description;
59
60   /**
61    * Field _secondaryStructure.
62    */
63   private java.lang.String _secondaryStructure;
64
65   /**
66    * Field _value.
67    */
68   private float _value;
69
70   /**
71    * keeps track of state for field: _value
72    */
73   private boolean _has_value;
74
75   // ----------------/
76   // - Constructors -/
77   // ----------------/
78
79   public AnnotationElement()
80   {
81     super();
82   }
83
84   // -----------/
85   // - Methods -/
86   // -----------/
87
88   /**
89    */
90   public void deletePosition()
91   {
92     this._has_position = false;
93   }
94
95   /**
96    */
97   public void deleteValue()
98   {
99     this._has_value = false;
100   }
101
102   /**
103    * Returns the value of field 'description'.
104    * 
105    * @return the value of field 'Description'.
106    */
107   public java.lang.String getDescription()
108   {
109     return this._description;
110   }
111
112   /**
113    * Returns the value of field 'displayCharacter'.
114    * 
115    * @return the value of field 'DisplayCharacter'.
116    */
117   public java.lang.String getDisplayCharacter()
118   {
119     return this._displayCharacter;
120   }
121
122   /**
123    * Returns the value of field 'position'.
124    * 
125    * @return the value of field 'Position'.
126    */
127   public int getPosition()
128   {
129     return this._position;
130   }
131
132   /**
133    * Returns the value of field 'secondaryStructure'.
134    * 
135    * @return the value of field 'SecondaryStructure'.
136    */
137   public java.lang.String getSecondaryStructure()
138   {
139     return this._secondaryStructure;
140   }
141
142   /**
143    * Returns the value of field 'value'.
144    * 
145    * @return the value of field 'Value'.
146    */
147   public float getValue()
148   {
149     return this._value;
150   }
151
152   /**
153    * Method hasPosition.
154    * 
155    * @return true if at least one Position has been added
156    */
157   public boolean hasPosition()
158   {
159     return this._has_position;
160   }
161
162   /**
163    * Method hasValue.
164    * 
165    * @return true if at least one Value has been added
166    */
167   public boolean hasValue()
168   {
169     return this._has_value;
170   }
171
172   /**
173    * Method isValid.
174    * 
175    * @return true if this object is valid according to the schema
176    */
177   public boolean isValid()
178   {
179     try
180     {
181       validate();
182     } catch (org.exolab.castor.xml.ValidationException vex)
183     {
184       return false;
185     }
186     return true;
187   }
188
189   /**
190    * 
191    * 
192    * @param out
193    * @throws org.exolab.castor.xml.MarshalException
194    *                 if object is null or if any SAXException is thrown during
195    *                 marshaling
196    * @throws org.exolab.castor.xml.ValidationException
197    *                 if this object is an invalid instance according to the
198    *                 schema
199    */
200   public void marshal(final java.io.Writer out)
201           throws org.exolab.castor.xml.MarshalException,
202           org.exolab.castor.xml.ValidationException
203   {
204     Marshaller.marshal(this, out);
205   }
206
207   /**
208    * 
209    * 
210    * @param handler
211    * @throws java.io.IOException
212    *                 if an IOException occurs during marshaling
213    * @throws org.exolab.castor.xml.ValidationException
214    *                 if this object is an invalid instance according to the
215    *                 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
295    *                 schema
296    * @return the unmarshaled jalview.binding.AnnotationElement
297    */
298   public static jalview.binding.AnnotationElement unmarshal(
299           final java.io.Reader reader)
300           throws org.exolab.castor.xml.MarshalException,
301           org.exolab.castor.xml.ValidationException
302   {
303     return (jalview.binding.AnnotationElement) Unmarshaller.unmarshal(
304             jalview.binding.AnnotationElement.class, reader);
305   }
306
307   /**
308    * 
309    * 
310    * @throws org.exolab.castor.xml.ValidationException
311    *                 if this object is an invalid instance according to the
312    *                 schema
313    */
314   public void validate() throws org.exolab.castor.xml.ValidationException
315   {
316     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
317     validator.validate(this);
318   }
319
320 }