e96b4fd20389c21941b29ec380c95a66ba871fd3
[vamsas.git] / src / uk / ac / vamsas / objects / core / Glyph.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  * Discrete symbol - possibly graphically represented\r
19  *  \r
20  * \r
21  * @version $Revision$ $Date$\r
22  */\r
23 public class Glyph extends uk.ac.vamsas.client.Vobject \r
24 implements java.io.Serializable\r
25 {\r
26 \r
27 \r
28       //--------------------------/\r
29      //- Class/Member Variables -/\r
30     //--------------------------/\r
31 \r
32     /**\r
33      * internal content storage\r
34      */\r
35     private java.lang.String _content = "";\r
36 \r
37     /**\r
38      * specifies the symbol dictionary for this\r
39      *  glyph - eg utf8 (the default), aasecstr_3 or\r
40      *  kd_hydrophobicity - the content is not validated so\r
41      *  applications must ensure they gracefully deal with\r
42      *  invalid entries here \r
43      */\r
44     private java.lang.String _dict = "utf8";\r
45 \r
46 \r
47       //----------------/\r
48      //- Constructors -/\r
49     //----------------/\r
50 \r
51     public Glyph() {\r
52         super();\r
53         setContent("");\r
54         setDict("utf8");\r
55     }\r
56 \r
57 \r
58       //-----------/\r
59      //- Methods -/\r
60     //-----------/\r
61 \r
62     /**\r
63      * Overrides the java.lang.Object.equals method.\r
64      * \r
65      * @param obj\r
66      * @return true if the objects are equal.\r
67      */\r
68     public boolean equals(\r
69             final java.lang.Object obj) {\r
70         if ( this == obj )\r
71             return true;\r
72         \r
73         if (super.equals(obj)==false)\r
74             return false;\r
75         \r
76         if (obj instanceof Glyph) {\r
77         \r
78             Glyph temp = (Glyph)obj;\r
79             boolean thcycle;\r
80             boolean tmcycle;\r
81             if (this._content != null) {\r
82                 if (temp._content == null) return false;\r
83                 if (this._content != temp._content) {\r
84                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._content);\r
85                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._content);\r
86                     if (thcycle!=tmcycle) {\r
87                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._content); };\r
88                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._content); };\r
89                         return false;\r
90                     }\r
91                     if (!thcycle) {\r
92                         if (!this._content.equals(temp._content)) {\r
93                             org.castor.util.CycleBreaker.releaseCycleHandle(this._content);\r
94                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);\r
95                             return false;\r
96                         }\r
97                         org.castor.util.CycleBreaker.releaseCycleHandle(this._content);\r
98                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._content);\r
99                     }\r
100                 }\r
101             } else if (temp._content != null)\r
102                 return false;\r
103             if (this._dict != null) {\r
104                 if (temp._dict == null) return false;\r
105                 if (this._dict != temp._dict) {\r
106                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._dict);\r
107                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._dict);\r
108                     if (thcycle!=tmcycle) {\r
109                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._dict); };\r
110                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict); };\r
111                         return false;\r
112                     }\r
113                     if (!thcycle) {\r
114                         if (!this._dict.equals(temp._dict)) {\r
115                             org.castor.util.CycleBreaker.releaseCycleHandle(this._dict);\r
116                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict);\r
117                             return false;\r
118                         }\r
119                         org.castor.util.CycleBreaker.releaseCycleHandle(this._dict);\r
120                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._dict);\r
121                     }\r
122                 }\r
123             } else if (temp._dict != null)\r
124                 return false;\r
125             return true;\r
126         }\r
127         return false;\r
128     }\r
129 \r
130     /**\r
131      * Returns the value of field 'content'. The field 'content'\r
132      * has the following description: internal content storage\r
133      * \r
134      * @return the value of field 'Content'.\r
135      */\r
136     public java.lang.String getContent(\r
137     ) {\r
138         return this._content;\r
139     }\r
140 \r
141     /**\r
142      * Returns the value of field 'dict'. The field 'dict' has the\r
143      * following description: specifies the symbol dictionary for\r
144      * this\r
145      *  glyph - eg utf8 (the default), aasecstr_3 or\r
146      *  kd_hydrophobicity - the content is not validated so\r
147      *  applications must ensure they gracefully deal with\r
148      *  invalid entries here \r
149      * \r
150      * @return the value of field 'Dict'.\r
151      */\r
152     public java.lang.String getDict(\r
153     ) {\r
154         return this._dict;\r
155     }\r
156 \r
157     /**\r
158      * Overrides the java.lang.Object.hashCode method.\r
159      * <p>\r
160      * The following steps came from <b>Effective Java Programming\r
161      * Language Guide</b> by Joshua Bloch, Chapter 3\r
162      * \r
163      * @return a hash code value for the object.\r
164      */\r
165     public int hashCode(\r
166     ) {\r
167         int result = super.hashCode();\r
168         \r
169         long tmp;\r
170         if (_content != null\r
171             && !org.castor.util.CycleBreaker.startingToCycle(_content)) {\r
172            result = 37 * result + _content.hashCode();\r
173            org.castor.util.CycleBreaker.releaseCycleHandle(_content);\r
174         }\r
175         if (_dict != null\r
176             && !org.castor.util.CycleBreaker.startingToCycle(_dict)) {\r
177            result = 37 * result + _dict.hashCode();\r
178            org.castor.util.CycleBreaker.releaseCycleHandle(_dict);\r
179         }\r
180         \r
181         return result;\r
182     }\r
183 \r
184     /**\r
185      * Method isValid.\r
186      * \r
187      * @return true if this object is valid according to the schema\r
188      */\r
189     public boolean isValid(\r
190     ) {\r
191         try {\r
192             validate();\r
193         } catch (org.exolab.castor.xml.ValidationException vex) {\r
194             return false;\r
195         }\r
196         return true;\r
197     }\r
198 \r
199     /**\r
200      * \r
201      * \r
202      * @param out\r
203      * @throws org.exolab.castor.xml.MarshalException if object is\r
204      * null or if any SAXException is thrown during marshaling\r
205      * @throws org.exolab.castor.xml.ValidationException if this\r
206      * object is an invalid instance according to the schema\r
207      */\r
208     public void marshal(\r
209             final java.io.Writer out)\r
210     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
211         Marshaller.marshal(this, out);\r
212     }\r
213 \r
214     /**\r
215      * \r
216      * \r
217      * @param handler\r
218      * @throws java.io.IOException if an IOException occurs during\r
219      * marshaling\r
220      * @throws org.exolab.castor.xml.ValidationException if this\r
221      * object is an invalid instance according to the schema\r
222      * @throws org.exolab.castor.xml.MarshalException if object is\r
223      * null or if any SAXException is thrown during marshaling\r
224      */\r
225     public void marshal(\r
226             final org.xml.sax.ContentHandler handler)\r
227     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
228         Marshaller.marshal(this, handler);\r
229     }\r
230 \r
231     /**\r
232      * Sets the value of field 'content'. The field 'content' has\r
233      * the following description: internal content storage\r
234      * \r
235      * @param content the value of field 'content'.\r
236      */\r
237     public void setContent(\r
238             final java.lang.String content) {\r
239         this._content = content;\r
240     }\r
241 \r
242     /**\r
243      * Sets the value of field 'dict'. The field 'dict' has the\r
244      * following description: specifies the symbol dictionary for\r
245      * this\r
246      *  glyph - eg utf8 (the default), aasecstr_3 or\r
247      *  kd_hydrophobicity - the content is not validated so\r
248      *  applications must ensure they gracefully deal with\r
249      *  invalid entries here \r
250      * \r
251      * @param dict the value of field 'dict'.\r
252      */\r
253     public void setDict(\r
254             final java.lang.String dict) {\r
255         this._dict = dict;\r
256     }\r
257 \r
258     /**\r
259      * Method unmarshal.\r
260      * \r
261      * @param reader\r
262      * @throws org.exolab.castor.xml.MarshalException if object is\r
263      * null or if any SAXException is thrown during marshaling\r
264      * @throws org.exolab.castor.xml.ValidationException if this\r
265      * object is an invalid instance according to the schema\r
266      * @return the unmarshaled uk.ac.vamsas.objects.core.Glyph\r
267      */\r
268     public static uk.ac.vamsas.objects.core.Glyph unmarshal(\r
269             final java.io.Reader reader)\r
270     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
271         return (uk.ac.vamsas.objects.core.Glyph) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Glyph.class, reader);\r
272     }\r
273 \r
274     /**\r
275      * \r
276      * \r
277      * @throws org.exolab.castor.xml.ValidationException if this\r
278      * object is an invalid instance according to the schema\r
279      */\r
280     public void validate(\r
281     )\r
282     throws org.exolab.castor.xml.ValidationException {\r
283         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
284         validator.validate(this);\r
285     }\r
286 \r
287 }\r