130f17d778078f70fbf12265813a9700465c8c67
[vamsas.git] / src / uk / ac / vamsas / objects / core / MapType.java
1 /*\r
2  * This class was automatically generated with \r
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML\r
4  * Schema.\r
5  * $Id$\r
6  */\r
7 \r
8 package uk.ac.vamsas.objects.core;\r
9 \r
10   //---------------------------------/\r
11  //- Imported classes and packages -/\r
12 //---------------------------------/\r
13 \r
14 import org.exolab.castor.xml.Marshaller;\r
15 import org.exolab.castor.xml.Unmarshaller;\r
16 \r
17 /**\r
18  * Two sets of ranges defined between objects - usually sequences,\r
19  * indicating which\r
20  *  regions on each are mapped. \r
21  * \r
22  * @version $Revision$ $Date$\r
23  */\r
24 public class MapType extends uk.ac.vamsas.client.Vobject \r
25 implements java.io.Serializable\r
26 {\r
27 \r
28 \r
29       //--------------------------/\r
30      //- Class/Member Variables -/\r
31     //--------------------------/\r
32 \r
33     /**\r
34      */\r
35     private uk.ac.vamsas.objects.core.Local _local;\r
36 \r
37     /**\r
38      */\r
39     private uk.ac.vamsas.objects.core.Mapped _mapped;\r
40 \r
41 \r
42       //----------------/\r
43      //- Constructors -/\r
44     //----------------/\r
45 \r
46     public MapType() {\r
47         super();\r
48     }\r
49 \r
50 \r
51       //-----------/\r
52      //- Methods -/\r
53     //-----------/\r
54 \r
55     /**\r
56      * Overrides the java.lang.Object.equals method.\r
57      * \r
58      * @param obj\r
59      * @return true if the objects are equal.\r
60      */\r
61     public boolean equals(\r
62             final java.lang.Object obj) {\r
63         if ( this == obj )\r
64             return true;\r
65         \r
66         if (super.equals(obj)==false)\r
67             return false;\r
68         \r
69         if (obj instanceof MapType) {\r
70         \r
71             MapType temp = (MapType)obj;\r
72             boolean thcycle;\r
73             boolean tmcycle;\r
74             if (this._local != null) {\r
75                 if (temp._local == null) return false;\r
76                 if (this._local != temp._local) {\r
77                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._local);\r
78                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._local);\r
79                     if (thcycle!=tmcycle) {\r
80                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._local); };\r
81                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._local); };\r
82                         return false;\r
83                     }\r
84                     if (!thcycle) {\r
85                         if (!this._local.equals(temp._local)) {\r
86                             org.castor.util.CycleBreaker.releaseCycleHandle(this._local);\r
87                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._local);\r
88                             return false;\r
89                         }\r
90                         org.castor.util.CycleBreaker.releaseCycleHandle(this._local);\r
91                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._local);\r
92                     }\r
93                 }\r
94             } else if (temp._local != null)\r
95                 return false;\r
96             if (this._mapped != null) {\r
97                 if (temp._mapped == null) return false;\r
98                 if (this._mapped != temp._mapped) {\r
99                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._mapped);\r
100                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._mapped);\r
101                     if (thcycle!=tmcycle) {\r
102                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped); };\r
103                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped); };\r
104                         return false;\r
105                     }\r
106                     if (!thcycle) {\r
107                         if (!this._mapped.equals(temp._mapped)) {\r
108                             org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped);\r
109                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped);\r
110                             return false;\r
111                         }\r
112                         org.castor.util.CycleBreaker.releaseCycleHandle(this._mapped);\r
113                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapped);\r
114                     }\r
115                 }\r
116             } else if (temp._mapped != null)\r
117                 return false;\r
118             return true;\r
119         }\r
120         return false;\r
121     }\r
122 \r
123     /**\r
124      * Returns the value of field 'local'.\r
125      * \r
126      * @return the value of field 'Local'.\r
127      */\r
128     public uk.ac.vamsas.objects.core.Local getLocal(\r
129     ) {\r
130         return this._local;\r
131     }\r
132 \r
133     /**\r
134      * Returns the value of field 'mapped'.\r
135      * \r
136      * @return the value of field 'Mapped'.\r
137      */\r
138     public uk.ac.vamsas.objects.core.Mapped getMapped(\r
139     ) {\r
140         return this._mapped;\r
141     }\r
142 \r
143     /**\r
144      * Overrides the java.lang.Object.hashCode method.\r
145      * <p>\r
146      * The following steps came from <b>Effective Java Programming\r
147      * Language Guide</b> by Joshua Bloch, Chapter 3\r
148      * \r
149      * @return a hash code value for the object.\r
150      */\r
151     public int hashCode(\r
152     ) {\r
153         int result = super.hashCode();\r
154         \r
155         long tmp;\r
156         if (_local != null\r
157             && !org.castor.util.CycleBreaker.startingToCycle(_local)) {\r
158            result = 37 * result + _local.hashCode();\r
159            org.castor.util.CycleBreaker.releaseCycleHandle(_local);\r
160         }\r
161         if (_mapped != null\r
162             && !org.castor.util.CycleBreaker.startingToCycle(_mapped)) {\r
163            result = 37 * result + _mapped.hashCode();\r
164            org.castor.util.CycleBreaker.releaseCycleHandle(_mapped);\r
165         }\r
166         \r
167         return result;\r
168     }\r
169 \r
170     /**\r
171      * Method isValid.\r
172      * \r
173      * @return true if this object is valid according to the schema\r
174      */\r
175     public boolean isValid(\r
176     ) {\r
177         try {\r
178             validate();\r
179         } catch (org.exolab.castor.xml.ValidationException vex) {\r
180             return false;\r
181         }\r
182         return true;\r
183     }\r
184 \r
185     /**\r
186      * \r
187      * \r
188      * @param out\r
189      * @throws org.exolab.castor.xml.MarshalException if object is\r
190      * null or if any SAXException is thrown during marshaling\r
191      * @throws org.exolab.castor.xml.ValidationException if this\r
192      * object is an invalid instance according to the schema\r
193      */\r
194     public void marshal(\r
195             final java.io.Writer out)\r
196     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
197         Marshaller.marshal(this, out);\r
198     }\r
199 \r
200     /**\r
201      * \r
202      * \r
203      * @param handler\r
204      * @throws java.io.IOException if an IOException occurs during\r
205      * marshaling\r
206      * @throws org.exolab.castor.xml.ValidationException if this\r
207      * object is an invalid instance according to the schema\r
208      * @throws org.exolab.castor.xml.MarshalException if object is\r
209      * null or if any SAXException is thrown during marshaling\r
210      */\r
211     public void marshal(\r
212             final org.xml.sax.ContentHandler handler)\r
213     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
214         Marshaller.marshal(this, handler);\r
215     }\r
216 \r
217     /**\r
218      * Sets the value of field 'local'.\r
219      * \r
220      * @param local the value of field 'local'.\r
221      */\r
222     public void setLocal(\r
223             final uk.ac.vamsas.objects.core.Local local) {\r
224         this._local = local;\r
225     }\r
226 \r
227     /**\r
228      * Sets the value of field 'mapped'.\r
229      * \r
230      * @param mapped the value of field 'mapped'.\r
231      */\r
232     public void setMapped(\r
233             final uk.ac.vamsas.objects.core.Mapped mapped) {\r
234         this._mapped = mapped;\r
235     }\r
236 \r
237     /**\r
238      * Method unmarshal.\r
239      * \r
240      * @param reader\r
241      * @throws org.exolab.castor.xml.MarshalException if object is\r
242      * null or if any SAXException is thrown during marshaling\r
243      * @throws org.exolab.castor.xml.ValidationException if this\r
244      * object is an invalid instance according to the schema\r
245      * @return the unmarshaled uk.ac.vamsas.objects.core.MapType\r
246      */\r
247     public static uk.ac.vamsas.objects.core.MapType unmarshal(\r
248             final java.io.Reader reader)\r
249     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
250         return (uk.ac.vamsas.objects.core.MapType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.MapType.class, reader);\r
251     }\r
252 \r
253     /**\r
254      * \r
255      * \r
256      * @throws org.exolab.castor.xml.ValidationException if this\r
257      * object is an invalid instance according to the schema\r
258      */\r
259     public void validate(\r
260     )\r
261     throws org.exolab.castor.xml.ValidationException {\r
262         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
263         validator.validate(this);\r
264     }\r
265 \r
266 }\r