7494819c25fc7146c6a10454793fda74fb29637a
[vamsas.git] / src / uk / ac / vamsas / objects / core / AlignmentSequenceAnnotation.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  * Class AlignmentSequenceAnnotation.\r
19  * \r
20  * @version $Revision$ $Date$\r
21  */\r
22 public class AlignmentSequenceAnnotation extends uk.ac.vamsas.objects.core.RangeAnnotation \r
23 implements java.io.Serializable\r
24 {\r
25 \r
26 \r
27       //--------------------------/\r
28      //- Class/Member Variables -/\r
29     //--------------------------/\r
30 \r
31     /**\r
32      * TODO:\r
33      *  decide if this flag is\r
34      *  redundant - when true it\r
35      *  would suggest that the\r
36      *  annotationElement values\r
37      *  together form a graph\r
38      *  \r
39      */\r
40     private boolean _graph;\r
41 \r
42     /**\r
43      * keeps track of state for field: _graph\r
44      */\r
45     private boolean _has_graph;\r
46 \r
47     /**\r
48      * Field _provenance.\r
49      */\r
50     private uk.ac.vamsas.objects.core.Provenance _provenance;\r
51 \r
52 \r
53       //----------------/\r
54      //- Constructors -/\r
55     //----------------/\r
56 \r
57     public AlignmentSequenceAnnotation() {\r
58         super();\r
59     }\r
60 \r
61 \r
62       //-----------/\r
63      //- Methods -/\r
64     //-----------/\r
65 \r
66     /**\r
67      */\r
68     public void deleteGraph(\r
69     ) {\r
70         this._has_graph= false;\r
71     }\r
72 \r
73     /**\r
74      * Overrides the java.lang.Object.equals method.\r
75      * \r
76      * @param obj\r
77      * @return true if the objects are equal.\r
78      */\r
79     public boolean equals(\r
80             final java.lang.Object obj) {\r
81         if ( this == obj )\r
82             return true;\r
83         \r
84         if (super.equals(obj)==false)\r
85             return false;\r
86         \r
87         if (obj instanceof AlignmentSequenceAnnotation) {\r
88         \r
89             AlignmentSequenceAnnotation temp = (AlignmentSequenceAnnotation)obj;\r
90             boolean thcycle;\r
91             boolean tmcycle;\r
92             if (this._graph != temp._graph)\r
93                 return false;\r
94             if (this._has_graph != temp._has_graph)\r
95                 return false;\r
96             if (this._provenance != null) {\r
97                 if (temp._provenance == null) return false;\r
98                 if (this._provenance != temp._provenance) {\r
99                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._provenance);\r
100                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._provenance);\r
101                     if (thcycle!=tmcycle) {\r
102                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance); };\r
103                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance); };\r
104                         return false;\r
105                     }\r
106                     if (!thcycle) {\r
107                         if (!this._provenance.equals(temp._provenance)) {\r
108                             org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);\r
109                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);\r
110                             return false;\r
111                         }\r
112                         org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);\r
113                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);\r
114                     }\r
115                 }\r
116             } else if (temp._provenance != 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 'graph'. The field 'graph' has\r
125      * the following description: TODO:\r
126      *  decide if this flag is\r
127      *  redundant - when true it\r
128      *  would suggest that the\r
129      *  annotationElement values\r
130      *  together form a graph\r
131      *  \r
132      * \r
133      * @return the value of field 'Graph'.\r
134      */\r
135     public boolean getGraph(\r
136     ) {\r
137         return this._graph;\r
138     }\r
139 \r
140     /**\r
141      * Returns the value of field 'provenance'.\r
142      * \r
143      * @return the value of field 'Provenance'.\r
144      */\r
145     public uk.ac.vamsas.objects.core.Provenance getProvenance(\r
146     ) {\r
147         return this._provenance;\r
148     }\r
149 \r
150     /**\r
151      * Method hasGraph.\r
152      * \r
153      * @return true if at least one Graph has been added\r
154      */\r
155     public boolean hasGraph(\r
156     ) {\r
157         return this._has_graph;\r
158     }\r
159 \r
160     /**\r
161      * Overrides the java.lang.Object.hashCode method.\r
162      * <p>\r
163      * The following steps came from <b>Effective Java Programming\r
164      * Language Guide</b> by Joshua Bloch, Chapter 3\r
165      * \r
166      * @return a hash code value for the object.\r
167      */\r
168     public int hashCode(\r
169     ) {\r
170         int result = super.hashCode();\r
171         \r
172         long tmp;\r
173         result = 37 * result + (_graph?0:1);\r
174         if (_provenance != null\r
175             && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {\r
176            result = 37 * result + _provenance.hashCode();\r
177            org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);\r
178         }\r
179         \r
180         return result;\r
181     }\r
182 \r
183     /**\r
184      * Returns the value of field 'graph'. The field 'graph' has\r
185      * the following description: TODO:\r
186      *  decide if this flag is\r
187      *  redundant - when true it\r
188      *  would suggest that the\r
189      *  annotationElement values\r
190      *  together form a graph\r
191      *  \r
192      * \r
193      * @return the value of field 'Graph'.\r
194      */\r
195     public boolean isGraph(\r
196     ) {\r
197         return this._graph;\r
198     }\r
199 \r
200     /**\r
201      * Method isValid.\r
202      * \r
203      * @return true if this object is valid according to the schema\r
204      */\r
205     public boolean isValid(\r
206     ) {\r
207         try {\r
208             validate();\r
209         } catch (org.exolab.castor.xml.ValidationException vex) {\r
210             return false;\r
211         }\r
212         return true;\r
213     }\r
214 \r
215     /**\r
216      * \r
217      * \r
218      * @param out\r
219      * @throws org.exolab.castor.xml.MarshalException if object is\r
220      * null or if any SAXException is thrown during marshaling\r
221      * @throws org.exolab.castor.xml.ValidationException if this\r
222      * object is an invalid instance according to the schema\r
223      */\r
224     public void marshal(\r
225             final java.io.Writer out)\r
226     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
227         Marshaller.marshal(this, out);\r
228     }\r
229 \r
230     /**\r
231      * \r
232      * \r
233      * @param handler\r
234      * @throws java.io.IOException if an IOException occurs during\r
235      * marshaling\r
236      * @throws org.exolab.castor.xml.ValidationException if this\r
237      * object is an invalid instance according to the schema\r
238      * @throws org.exolab.castor.xml.MarshalException if object is\r
239      * null or if any SAXException is thrown during marshaling\r
240      */\r
241     public void marshal(\r
242             final org.xml.sax.ContentHandler handler)\r
243     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
244         Marshaller.marshal(this, handler);\r
245     }\r
246 \r
247     /**\r
248      * Sets the value of field 'graph'. The field 'graph' has the\r
249      * following description: TODO:\r
250      *  decide if this flag is\r
251      *  redundant - when true it\r
252      *  would suggest that the\r
253      *  annotationElement values\r
254      *  together form a graph\r
255      *  \r
256      * \r
257      * @param graph the value of field 'graph'.\r
258      */\r
259     public void setGraph(\r
260             final boolean graph) {\r
261         this._graph = graph;\r
262         this._has_graph = true;\r
263     }\r
264 \r
265     /**\r
266      * Sets the value of field 'provenance'.\r
267      * \r
268      * @param provenance the value of field 'provenance'.\r
269      */\r
270     public void setProvenance(\r
271             final uk.ac.vamsas.objects.core.Provenance provenance) {\r
272         this._provenance = provenance;\r
273     }\r
274 \r
275     /**\r
276      * Method unmarshal.\r
277      * \r
278      * @param reader\r
279      * @throws org.exolab.castor.xml.MarshalException if object is\r
280      * null or if any SAXException is thrown during marshaling\r
281      * @throws org.exolab.castor.xml.ValidationException if this\r
282      * object is an invalid instance according to the schema\r
283      * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType\r
284      */\r
285     public static uk.ac.vamsas.objects.core.RangeType unmarshal(\r
286             final java.io.Reader reader)\r
287     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
288         return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.AlignmentSequenceAnnotation.class, reader);\r
289     }\r
290 \r
291     /**\r
292      * \r
293      * \r
294      * @throws org.exolab.castor.xml.ValidationException if this\r
295      * object is an invalid instance according to the schema\r
296      */\r
297     public void validate(\r
298     )\r
299     throws org.exolab.castor.xml.ValidationException {\r
300         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
301         validator.validate(this);\r
302     }\r
303 \r
304 }\r