applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / MapList.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 MapList.\r
33  * \r
34  * @version $Revision$ $Date$\r
35  */\r
36 public class MapList 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    * Offset to first position in dataset sequence record that start position on\r
45    * 'onto' maps to\r
46    */\r
47   private long _from = 0;\r
48 \r
49   /**\r
50    * keeps track of state for field: _from\r
51    */\r
52   private boolean _has_from;\r
53 \r
54   /**\r
55    * Offset to last position in dataset sequence record that end position on\r
56    * 'onto' maps to\r
57    */\r
58   private long _to = 0;\r
59 \r
60   /**\r
61    * keeps track of state for field: _to\r
62    */\r
63   private boolean _has_to;\r
64 \r
65   /**\r
66    * Offset to first position in database entry that first (or offset) position\r
67    * in sequence maps to\r
68    */\r
69   private long _start;\r
70 \r
71   /**\r
72    * keeps track of state for field: _start\r
73    */\r
74   private boolean _has_start;\r
75 \r
76   /**\r
77    * Offset to last position in database entry that last (offset) position in\r
78    * sequence maps to\r
79    */\r
80   private long _end;\r
81 \r
82   /**\r
83    * keeps track of state for field: _end\r
84    */\r
85   private boolean _has_end;\r
86 \r
87   // ----------------/\r
88   // - Constructors -/\r
89   // ----------------/\r
90 \r
91   public MapList() {\r
92     super();\r
93   }\r
94 \r
95   // -----------/\r
96   // - Methods -/\r
97   // -----------/\r
98 \r
99   /**\r
100      */\r
101   public void deleteEnd() {\r
102     this._has_end = false;\r
103   }\r
104 \r
105   /**\r
106      */\r
107   public void deleteFrom() {\r
108     this._has_from = false;\r
109   }\r
110 \r
111   /**\r
112      */\r
113   public void deleteStart() {\r
114     this._has_start = false;\r
115   }\r
116 \r
117   /**\r
118      */\r
119   public void deleteTo() {\r
120     this._has_to = false;\r
121   }\r
122 \r
123   /**\r
124    * Overrides the java.lang.Object.equals method.\r
125    * \r
126    * @param obj\r
127    * @return true if the objects are equal.\r
128    */\r
129   public boolean equals(final java.lang.Object obj) {\r
130     if (this == obj)\r
131       return true;\r
132 \r
133     if (super.equals(obj) == false)\r
134       return false;\r
135 \r
136     if (obj instanceof MapList) {\r
137 \r
138       MapList temp = (MapList) obj;\r
139       if (this._from != temp._from)\r
140         return false;\r
141       if (this._has_from != temp._has_from)\r
142         return false;\r
143       if (this._to != temp._to)\r
144         return false;\r
145       if (this._has_to != temp._has_to)\r
146         return false;\r
147       if (this._start != temp._start)\r
148         return false;\r
149       if (this._has_start != temp._has_start)\r
150         return false;\r
151       if (this._end != temp._end)\r
152         return false;\r
153       if (this._has_end != temp._has_end)\r
154         return false;\r
155       return true;\r
156     }\r
157     return false;\r
158   }\r
159 \r
160   /**\r
161    * Returns the value of field 'end'. The field 'end' has the following\r
162    * description: Offset to last position in database entry that last (offset)\r
163    * position in sequence maps to\r
164    * \r
165    * @return the value of field 'End'.\r
166    */\r
167   public long getEnd() {\r
168     return this._end;\r
169   }\r
170 \r
171   /**\r
172    * Returns the value of field 'from'. The field 'from' has the following\r
173    * description: Offset to first position in dataset sequence record that start\r
174    * position on 'onto' maps to\r
175    * \r
176    * @return the value of field 'From'.\r
177    */\r
178   public long getFrom() {\r
179     return this._from;\r
180   }\r
181 \r
182   /**\r
183    * Returns the value of field 'start'. The field 'start' has the following\r
184    * description: Offset to first position in database entry that first (or\r
185    * offset) position in sequence maps to\r
186    * \r
187    * @return the value of field 'Start'.\r
188    */\r
189   public long getStart() {\r
190     return this._start;\r
191   }\r
192 \r
193   /**\r
194    * Returns the value of field 'to'. The field 'to' has the following\r
195    * description: Offset to last position in dataset sequence record that end\r
196    * position on 'onto' maps to\r
197    * \r
198    * @return the value of field 'To'.\r
199    */\r
200   public long getTo() {\r
201     return this._to;\r
202   }\r
203 \r
204   /**\r
205    * Method hasEnd.\r
206    * \r
207    * @return true if at least one End has been added\r
208    */\r
209   public boolean hasEnd() {\r
210     return this._has_end;\r
211   }\r
212 \r
213   /**\r
214    * Method hasFrom.\r
215    * \r
216    * @return true if at least one From has been added\r
217    */\r
218   public boolean hasFrom() {\r
219     return this._has_from;\r
220   }\r
221 \r
222   /**\r
223    * Method hasStart.\r
224    * \r
225    * @return true if at least one Start has been added\r
226    */\r
227   public boolean hasStart() {\r
228     return this._has_start;\r
229   }\r
230 \r
231   /**\r
232    * Method hasTo.\r
233    * \r
234    * @return true if at least one To has been added\r
235    */\r
236   public boolean hasTo() {\r
237     return this._has_to;\r
238   }\r
239 \r
240   /**\r
241    * Overrides the java.lang.Object.hashCode method.\r
242    * <p>\r
243    * The following steps came from <b>Effective Java Programming Language\r
244    * Guide</b> by Joshua Bloch, Chapter 3\r
245    * \r
246    * @return a hash code value for the object.\r
247    */\r
248   public int hashCode() {\r
249     int result = super.hashCode();\r
250 \r
251     long tmp;\r
252     result = 37 * result + (int) (_from ^ (_from >>> 32));\r
253     result = 37 * result + (int) (_to ^ (_to >>> 32));\r
254     result = 37 * result + (int) (_start ^ (_start >>> 32));\r
255     result = 37 * result + (int) (_end ^ (_end >>> 32));\r
256 \r
257     return result;\r
258   }\r
259 \r
260   /**\r
261    * Method isValid.\r
262    * \r
263    * @return true if this object is valid according to the schema\r
264    */\r
265   public boolean isValid() {\r
266     try {\r
267       validate();\r
268     } catch (org.exolab.castor.xml.ValidationException vex) {\r
269       return false;\r
270     }\r
271     return true;\r
272   }\r
273 \r
274   /**\r
275    * \r
276    * \r
277    * @param out\r
278    * @throws org.exolab.castor.xml.MarshalException\r
279    *           if object is null or if any SAXException is thrown during\r
280    *           marshaling\r
281    * @throws org.exolab.castor.xml.ValidationException\r
282    *           if this object is an invalid instance according to the schema\r
283    */\r
284   public void marshal(final java.io.Writer out)\r
285       throws org.exolab.castor.xml.MarshalException,\r
286       org.exolab.castor.xml.ValidationException {\r
287     Marshaller.marshal(this, out);\r
288   }\r
289 \r
290   /**\r
291    * \r
292    * \r
293    * @param handler\r
294    * @throws java.io.IOException\r
295    *           if an IOException occurs during marshaling\r
296    * @throws org.exolab.castor.xml.ValidationException\r
297    *           if this object is an invalid instance according to the schema\r
298    * @throws org.exolab.castor.xml.MarshalException\r
299    *           if object is null or if any SAXException is thrown during\r
300    *           marshaling\r
301    */\r
302   public void marshal(final org.xml.sax.ContentHandler handler)\r
303       throws java.io.IOException, org.exolab.castor.xml.MarshalException,\r
304       org.exolab.castor.xml.ValidationException {\r
305     Marshaller.marshal(this, handler);\r
306   }\r
307 \r
308   /**\r
309    * Sets the value of field 'end'. The field 'end' has the following\r
310    * description: Offset to last position in database entry that last (offset)\r
311    * position in sequence maps to\r
312    * \r
313    * @param end\r
314    *          the value of field 'end'.\r
315    */\r
316   public void setEnd(final long end) {\r
317     this._end = end;\r
318     this._has_end = true;\r
319   }\r
320 \r
321   /**\r
322    * Sets the value of field 'from'. The field 'from' has the following\r
323    * description: Offset to first position in dataset sequence record that start\r
324    * position on 'onto' maps to\r
325    * \r
326    * @param from\r
327    *          the value of field 'from'.\r
328    */\r
329   public void setFrom(final long from) {\r
330     this._from = from;\r
331     this._has_from = true;\r
332   }\r
333 \r
334   /**\r
335    * Sets the value of field 'start'. The field 'start' has the following\r
336    * description: Offset to first position in database entry that first (or\r
337    * offset) position in sequence maps to\r
338    * \r
339    * @param start\r
340    *          the value of field 'start'.\r
341    */\r
342   public void setStart(final long start) {\r
343     this._start = start;\r
344     this._has_start = true;\r
345   }\r
346 \r
347   /**\r
348    * Sets the value of field 'to'. The field 'to' has the following description:\r
349    * Offset to last position in dataset sequence record that end position on\r
350    * 'onto' maps to\r
351    * \r
352    * @param to\r
353    *          the value of field 'to'.\r
354    */\r
355   public void setTo(final long to) {\r
356     this._to = to;\r
357     this._has_to = true;\r
358   }\r
359 \r
360   /**\r
361    * Method unmarshal.\r
362    * \r
363    * @param reader\r
364    * @throws org.exolab.castor.xml.MarshalException\r
365    *           if object is null or if any SAXException is thrown during\r
366    *           marshaling\r
367    * @throws org.exolab.castor.xml.ValidationException\r
368    *           if this object is an invalid instance according to the schema\r
369    * @return the unmarshaled uk.ac.vamsas.objects.core.MapList\r
370    */\r
371   public static uk.ac.vamsas.objects.core.MapList unmarshal(\r
372       final java.io.Reader reader)\r
373       throws org.exolab.castor.xml.MarshalException,\r
374       org.exolab.castor.xml.ValidationException {\r
375     return (uk.ac.vamsas.objects.core.MapList) Unmarshaller.unmarshal(\r
376         uk.ac.vamsas.objects.core.MapList.class, reader);\r
377   }\r
378 \r
379   /**\r
380    * \r
381    * \r
382    * @throws org.exolab.castor.xml.ValidationException\r
383    *           if this object is an invalid instance according to the schema\r
384    */\r
385   public void validate() throws org.exolab.castor.xml.ValidationException {\r
386     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
387     validator.validate(this);\r
388   }\r
389 \r
390 }\r