applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / Range.java
1 /*\r
2  * This file is part of the Vamsas Client version 0.1. \r
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
4  *  Andrew Waterhouse and Dominik Lindner.\r
5  * \r
6  * Earlier versions have also been incorporated into Jalview version 2.4 \r
7  * since 2008, and TOPALi version 2 since 2007.\r
8  * \r
9  * The Vamsas Client is free software: you can redistribute it and/or modify\r
10  * it under the terms of the GNU Lesser General Public License as published by\r
11  * the Free Software Foundation, either version 3 of the License, or\r
12  * (at your option) any later version.\r
13  *  \r
14  * The Vamsas Client is distributed in the hope that it will be useful,\r
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  * GNU Lesser General Public License for more details.\r
18  * \r
19  * You should have received a copy of the GNU Lesser General Public License\r
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.\r
21  */\r
22 package uk.ac.vamsas.objects.core;\r
23 \r
24 //---------------------------------/\r
25 //- Imported classes and packages -/\r
26 //---------------------------------/\r
27 \r
28 import org.exolab.castor.xml.Marshaller;\r
29 import org.exolab.castor.xml.Unmarshaller;\r
30 \r
31 /**\r
32  * Class Range.\r
33  * \r
34  * @version $Revision$ $Date$\r
35  */\r
36 public class Range extends uk.ac.vamsas.client.Vobject implements\r
37     java.io.Serializable {\r
38 \r
39   // --------------------------/\r
40   // - Class/Member Variables -/\r
41   // --------------------------/\r
42 \r
43   /**\r
44    * Field _seqAStart.\r
45    */\r
46   private int _seqAStart;\r
47 \r
48   /**\r
49    * keeps track of state for field: _seqAStart\r
50    */\r
51   private boolean _has_seqAStart;\r
52 \r
53   /**\r
54    * Field _seqAEnd.\r
55    */\r
56   private int _seqAEnd;\r
57 \r
58   /**\r
59    * keeps track of state for field: _seqAEnd\r
60    */\r
61   private boolean _has_seqAEnd;\r
62 \r
63   /**\r
64    * Field _seqBStart.\r
65    */\r
66   private int _seqBStart;\r
67 \r
68   /**\r
69    * keeps track of state for field: _seqBStart\r
70    */\r
71   private boolean _has_seqBStart;\r
72 \r
73   /**\r
74    * Field _seqBEnd.\r
75    */\r
76   private int _seqBEnd;\r
77 \r
78   /**\r
79    * keeps track of state for field: _seqBEnd\r
80    */\r
81   private boolean _has_seqBEnd;\r
82 \r
83   // ----------------/\r
84   // - Constructors -/\r
85   // ----------------/\r
86 \r
87   public Range() {\r
88     super();\r
89   }\r
90 \r
91   // -----------/\r
92   // - Methods -/\r
93   // -----------/\r
94 \r
95   /**\r
96      */\r
97   public void deleteSeqAEnd() {\r
98     this._has_seqAEnd = false;\r
99   }\r
100 \r
101   /**\r
102      */\r
103   public void deleteSeqAStart() {\r
104     this._has_seqAStart = false;\r
105   }\r
106 \r
107   /**\r
108      */\r
109   public void deleteSeqBEnd() {\r
110     this._has_seqBEnd = false;\r
111   }\r
112 \r
113   /**\r
114      */\r
115   public void deleteSeqBStart() {\r
116     this._has_seqBStart = false;\r
117   }\r
118 \r
119   /**\r
120    * Overrides the java.lang.Object.equals method.\r
121    * \r
122    * @param obj\r
123    * @return true if the objects are equal.\r
124    */\r
125   public boolean equals(final java.lang.Object obj) {\r
126     if (this == obj)\r
127       return true;\r
128 \r
129     if (super.equals(obj) == false)\r
130       return false;\r
131 \r
132     if (obj instanceof Range) {\r
133 \r
134       Range temp = (Range) obj;\r
135       if (this._seqAStart != temp._seqAStart)\r
136         return false;\r
137       if (this._has_seqAStart != temp._has_seqAStart)\r
138         return false;\r
139       if (this._seqAEnd != temp._seqAEnd)\r
140         return false;\r
141       if (this._has_seqAEnd != temp._has_seqAEnd)\r
142         return false;\r
143       if (this._seqBStart != temp._seqBStart)\r
144         return false;\r
145       if (this._has_seqBStart != temp._has_seqBStart)\r
146         return false;\r
147       if (this._seqBEnd != temp._seqBEnd)\r
148         return false;\r
149       if (this._has_seqBEnd != temp._has_seqBEnd)\r
150         return false;\r
151       return true;\r
152     }\r
153     return false;\r
154   }\r
155 \r
156   /**\r
157    * Returns the value of field 'seqAEnd'.\r
158    * \r
159    * @return the value of field 'SeqAEnd'.\r
160    */\r
161   public int getSeqAEnd() {\r
162     return this._seqAEnd;\r
163   }\r
164 \r
165   /**\r
166    * Returns the value of field 'seqAStart'.\r
167    * \r
168    * @return the value of field 'SeqAStart'.\r
169    */\r
170   public int getSeqAStart() {\r
171     return this._seqAStart;\r
172   }\r
173 \r
174   /**\r
175    * Returns the value of field 'seqBEnd'.\r
176    * \r
177    * @return the value of field 'SeqBEnd'.\r
178    */\r
179   public int getSeqBEnd() {\r
180     return this._seqBEnd;\r
181   }\r
182 \r
183   /**\r
184    * Returns the value of field 'seqBStart'.\r
185    * \r
186    * @return the value of field 'SeqBStart'.\r
187    */\r
188   public int getSeqBStart() {\r
189     return this._seqBStart;\r
190   }\r
191 \r
192   /**\r
193    * Method hasSeqAEnd.\r
194    * \r
195    * @return true if at least one SeqAEnd has been added\r
196    */\r
197   public boolean hasSeqAEnd() {\r
198     return this._has_seqAEnd;\r
199   }\r
200 \r
201   /**\r
202    * Method hasSeqAStart.\r
203    * \r
204    * @return true if at least one SeqAStart has been added\r
205    */\r
206   public boolean hasSeqAStart() {\r
207     return this._has_seqAStart;\r
208   }\r
209 \r
210   /**\r
211    * Method hasSeqBEnd.\r
212    * \r
213    * @return true if at least one SeqBEnd has been added\r
214    */\r
215   public boolean hasSeqBEnd() {\r
216     return this._has_seqBEnd;\r
217   }\r
218 \r
219   /**\r
220    * Method hasSeqBStart.\r
221    * \r
222    * @return true if at least one SeqBStart has been added\r
223    */\r
224   public boolean hasSeqBStart() {\r
225     return this._has_seqBStart;\r
226   }\r
227 \r
228   /**\r
229    * Overrides the java.lang.Object.hashCode method.\r
230    * <p>\r
231    * The following steps came from <b>Effective Java Programming Language\r
232    * Guide</b> by Joshua Bloch, Chapter 3\r
233    * \r
234    * @return a hash code value for the object.\r
235    */\r
236   public int hashCode() {\r
237     int result = super.hashCode();\r
238 \r
239     long tmp;\r
240     result = 37 * result + _seqAStart;\r
241     result = 37 * result + _seqAEnd;\r
242     result = 37 * result + _seqBStart;\r
243     result = 37 * result + _seqBEnd;\r
244 \r
245     return result;\r
246   }\r
247 \r
248   /**\r
249    * Method isValid.\r
250    * \r
251    * @return true if this object is valid according to the schema\r
252    */\r
253   public boolean isValid() {\r
254     try {\r
255       validate();\r
256     } catch (org.exolab.castor.xml.ValidationException vex) {\r
257       return false;\r
258     }\r
259     return true;\r
260   }\r
261 \r
262   /**\r
263    * \r
264    * \r
265    * @param out\r
266    * @throws org.exolab.castor.xml.MarshalException\r
267    *           if object is null or if any SAXException is thrown during\r
268    *           marshaling\r
269    * @throws org.exolab.castor.xml.ValidationException\r
270    *           if this object is an invalid instance according to the schema\r
271    */\r
272   public void marshal(final java.io.Writer out)\r
273       throws org.exolab.castor.xml.MarshalException,\r
274       org.exolab.castor.xml.ValidationException {\r
275     Marshaller.marshal(this, out);\r
276   }\r
277 \r
278   /**\r
279    * \r
280    * \r
281    * @param handler\r
282    * @throws java.io.IOException\r
283    *           if an IOException occurs during marshaling\r
284    * @throws org.exolab.castor.xml.ValidationException\r
285    *           if this object is an invalid instance according to the schema\r
286    * @throws org.exolab.castor.xml.MarshalException\r
287    *           if object is null or if any SAXException is thrown during\r
288    *           marshaling\r
289    */\r
290   public void marshal(final org.xml.sax.ContentHandler handler)\r
291       throws java.io.IOException, org.exolab.castor.xml.MarshalException,\r
292       org.exolab.castor.xml.ValidationException {\r
293     Marshaller.marshal(this, handler);\r
294   }\r
295 \r
296   /**\r
297    * Sets the value of field 'seqAEnd'.\r
298    * \r
299    * @param seqAEnd\r
300    *          the value of field 'seqAEnd'.\r
301    */\r
302   public void setSeqAEnd(final int seqAEnd) {\r
303     this._seqAEnd = seqAEnd;\r
304     this._has_seqAEnd = true;\r
305   }\r
306 \r
307   /**\r
308    * Sets the value of field 'seqAStart'.\r
309    * \r
310    * @param seqAStart\r
311    *          the value of field 'seqAStart'.\r
312    */\r
313   public void setSeqAStart(final int seqAStart) {\r
314     this._seqAStart = seqAStart;\r
315     this._has_seqAStart = true;\r
316   }\r
317 \r
318   /**\r
319    * Sets the value of field 'seqBEnd'.\r
320    * \r
321    * @param seqBEnd\r
322    *          the value of field 'seqBEnd'.\r
323    */\r
324   public void setSeqBEnd(final int seqBEnd) {\r
325     this._seqBEnd = seqBEnd;\r
326     this._has_seqBEnd = true;\r
327   }\r
328 \r
329   /**\r
330    * Sets the value of field 'seqBStart'.\r
331    * \r
332    * @param seqBStart\r
333    *          the value of field 'seqBStart'.\r
334    */\r
335   public void setSeqBStart(final int seqBStart) {\r
336     this._seqBStart = seqBStart;\r
337     this._has_seqBStart = true;\r
338   }\r
339 \r
340   /**\r
341    * Method unmarshal.\r
342    * \r
343    * @param reader\r
344    * @throws org.exolab.castor.xml.MarshalException\r
345    *           if object is null or if any SAXException is thrown during\r
346    *           marshaling\r
347    * @throws org.exolab.castor.xml.ValidationException\r
348    *           if this object is an invalid instance according to the schema\r
349    * @return the unmarshaled uk.ac.vamsas.objects.core.Range\r
350    */\r
351   public static uk.ac.vamsas.objects.core.Range unmarshal(\r
352       final java.io.Reader reader)\r
353       throws org.exolab.castor.xml.MarshalException,\r
354       org.exolab.castor.xml.ValidationException {\r
355     return (uk.ac.vamsas.objects.core.Range) Unmarshaller.unmarshal(\r
356         uk.ac.vamsas.objects.core.Range.class, reader);\r
357   }\r
358 \r
359   /**\r
360    * \r
361    * \r
362    * @throws org.exolab.castor.xml.ValidationException\r
363    *           if this object is an invalid instance according to the schema\r
364    */\r
365   public void validate() throws org.exolab.castor.xml.ValidationException {\r
366     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
367     validator.validate(this);\r
368   }\r
369 \r
370 }\r