applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / core / Pos.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  * a position within the associated object's coordinate system\r
33  * \r
34  * \r
35  * @version $Revision$ $Date$\r
36  */\r
37 public class Pos extends uk.ac.vamsas.client.Vobject implements\r
38     java.io.Serializable {\r
39 \r
40   // --------------------------/\r
41   // - Class/Member Variables -/\r
42   // --------------------------/\r
43 \r
44   /**\r
45    * Field _i.\r
46    */\r
47   private int _i;\r
48 \r
49   /**\r
50    * keeps track of state for field: _i\r
51    */\r
52   private boolean _has_i;\r
53 \r
54   // ----------------/\r
55   // - Constructors -/\r
56   // ----------------/\r
57 \r
58   public Pos() {\r
59     super();\r
60   }\r
61 \r
62   // -----------/\r
63   // - Methods -/\r
64   // -----------/\r
65 \r
66   /**\r
67      */\r
68   public void deleteI() {\r
69     this._has_i = false;\r
70   }\r
71 \r
72   /**\r
73    * Overrides the java.lang.Object.equals method.\r
74    * \r
75    * @param obj\r
76    * @return true if the objects are equal.\r
77    */\r
78   public boolean equals(final java.lang.Object obj) {\r
79     if (this == obj)\r
80       return true;\r
81 \r
82     if (super.equals(obj) == false)\r
83       return false;\r
84 \r
85     if (obj instanceof Pos) {\r
86 \r
87       Pos temp = (Pos) obj;\r
88       boolean thcycle;\r
89       boolean tmcycle;\r
90       if (this._i != temp._i)\r
91         return false;\r
92       if (this._has_i != temp._has_i)\r
93         return false;\r
94       return true;\r
95     }\r
96     return false;\r
97   }\r
98 \r
99   /**\r
100    * Returns the value of field 'i'.\r
101    * \r
102    * @return the value of field 'I'.\r
103    */\r
104   public int getI() {\r
105     return this._i;\r
106   }\r
107 \r
108   /**\r
109    * Method hasI.\r
110    * \r
111    * @return true if at least one I has been added\r
112    */\r
113   public boolean hasI() {\r
114     return this._has_i;\r
115   }\r
116 \r
117   /**\r
118    * Overrides the java.lang.Object.hashCode method.\r
119    * <p>\r
120    * The following steps came from <b>Effective Java Programming Language\r
121    * Guide</b> by Joshua Bloch, Chapter 3\r
122    * \r
123    * @return a hash code value for the object.\r
124    */\r
125   public int hashCode() {\r
126     int result = super.hashCode();\r
127 \r
128     long tmp;\r
129     result = 37 * result + _i;\r
130 \r
131     return result;\r
132   }\r
133 \r
134   /**\r
135    * Method isValid.\r
136    * \r
137    * @return true if this object is valid according to the schema\r
138    */\r
139   public boolean isValid() {\r
140     try {\r
141       validate();\r
142     } catch (org.exolab.castor.xml.ValidationException vex) {\r
143       return false;\r
144     }\r
145     return true;\r
146   }\r
147 \r
148   /**\r
149    * \r
150    * \r
151    * @param out\r
152    * @throws org.exolab.castor.xml.MarshalException\r
153    *           if object is null or if any SAXException is thrown during\r
154    *           marshaling\r
155    * @throws org.exolab.castor.xml.ValidationException\r
156    *           if this object is an invalid instance according to the schema\r
157    */\r
158   public void marshal(final java.io.Writer out)\r
159       throws org.exolab.castor.xml.MarshalException,\r
160       org.exolab.castor.xml.ValidationException {\r
161     Marshaller.marshal(this, out);\r
162   }\r
163 \r
164   /**\r
165    * \r
166    * \r
167    * @param handler\r
168    * @throws java.io.IOException\r
169    *           if an IOException occurs during marshaling\r
170    * @throws org.exolab.castor.xml.ValidationException\r
171    *           if this object is an invalid instance according to the schema\r
172    * @throws org.exolab.castor.xml.MarshalException\r
173    *           if object is null or if any SAXException is thrown during\r
174    *           marshaling\r
175    */\r
176   public void marshal(final org.xml.sax.ContentHandler handler)\r
177       throws java.io.IOException, org.exolab.castor.xml.MarshalException,\r
178       org.exolab.castor.xml.ValidationException {\r
179     Marshaller.marshal(this, handler);\r
180   }\r
181 \r
182   /**\r
183    * Sets the value of field 'i'.\r
184    * \r
185    * @param i\r
186    *          the value of field 'i'.\r
187    */\r
188   public void setI(final int i) {\r
189     this._i = i;\r
190     this._has_i = true;\r
191   }\r
192 \r
193   /**\r
194    * Method unmarshal.\r
195    * \r
196    * @param reader\r
197    * @throws org.exolab.castor.xml.MarshalException\r
198    *           if object is null or if any SAXException is thrown during\r
199    *           marshaling\r
200    * @throws org.exolab.castor.xml.ValidationException\r
201    *           if this object is an invalid instance according to the schema\r
202    * @return the unmarshaled uk.ac.vamsas.objects.core.Pos\r
203    */\r
204   public static uk.ac.vamsas.objects.core.Pos unmarshal(\r
205       final java.io.Reader reader)\r
206       throws org.exolab.castor.xml.MarshalException,\r
207       org.exolab.castor.xml.ValidationException {\r
208     return (uk.ac.vamsas.objects.core.Pos) Unmarshaller.unmarshal(\r
209         uk.ac.vamsas.objects.core.Pos.class, reader);\r
210   }\r
211 \r
212   /**\r
213    * \r
214    * \r
215    * @throws org.exolab.castor.xml.ValidationException\r
216    *           if this object is an invalid instance according to the schema\r
217    */\r
218   public void validate() throws org.exolab.castor.xml.ValidationException {\r
219     org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
220     validator.validate(this);\r
221   }\r
222 \r
223 }\r