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