b7c741f7a24f8d4bc101d44bacfe6c601f87fcbf
[vamsas.git] / src / uk / ac / vamsas / objects / core / Attachment.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 Attachment.\r
19  * \r
20  * @version $Revision$ $Date$\r
21  */\r
22 public class Attachment extends uk.ac.vamsas.objects.core.AppData \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      * true implies data will be decompresses with Zip\r
33      *  before presenting to application \r
34      */\r
35     private boolean _compressed = false;\r
36 \r
37     /**\r
38      * keeps track of state for field: _compressed\r
39      */\r
40     private boolean _has_compressed;\r
41 \r
42     /**\r
43      * Type of arbitrary data - TODO: decide format - use\r
44      *  (extended) MIME types ? \r
45      */\r
46     private java.lang.String _type;\r
47 \r
48     /**\r
49      * Object the arbitrary data is associated with\r
50      *  \r
51      */\r
52     private java.lang.Object _objectref;\r
53 \r
54     /**\r
55      * Primary Key for vamsas object referencing\r
56      *  \r
57      */\r
58     private java.lang.String _id;\r
59 \r
60 \r
61       //----------------/\r
62      //- Constructors -/\r
63     //----------------/\r
64 \r
65     public Attachment() {\r
66         super();\r
67     }\r
68 \r
69 \r
70       //-----------/\r
71      //- Methods -/\r
72     //-----------/\r
73 \r
74     /**\r
75      */\r
76     public void deleteCompressed(\r
77     ) {\r
78         this._has_compressed= false;\r
79     }\r
80 \r
81     /**\r
82      * Overrides the java.lang.Object.equals method.\r
83      * \r
84      * @param obj\r
85      * @return true if the objects are equal.\r
86      */\r
87     public boolean equals(\r
88             final java.lang.Object obj) {\r
89         if ( this == obj )\r
90             return true;\r
91         \r
92         if (super.equals(obj)==false)\r
93             return false;\r
94         \r
95         if (obj instanceof Attachment) {\r
96         \r
97             Attachment temp = (Attachment)obj;\r
98             boolean thcycle;\r
99             boolean tmcycle;\r
100             if (this._compressed != temp._compressed)\r
101                 return false;\r
102             if (this._has_compressed != temp._has_compressed)\r
103                 return false;\r
104             if (this._type != null) {\r
105                 if (temp._type == null) return false;\r
106                 if (this._type != temp._type) {\r
107                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._type);\r
108                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._type);\r
109                     if (thcycle!=tmcycle) {\r
110                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._type); };\r
111                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._type); };\r
112                         return false;\r
113                     }\r
114                     if (!thcycle) {\r
115                         if (!this._type.equals(temp._type)) {\r
116                             org.castor.util.CycleBreaker.releaseCycleHandle(this._type);\r
117                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);\r
118                             return false;\r
119                         }\r
120                         org.castor.util.CycleBreaker.releaseCycleHandle(this._type);\r
121                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);\r
122                     }\r
123                 }\r
124             } else if (temp._type != null)\r
125                 return false;\r
126             if (this._objectref != null) {\r
127                 if (temp._objectref == null) return false;\r
128                 if (this._objectref != temp._objectref) {\r
129                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._objectref);\r
130                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._objectref);\r
131                     if (thcycle!=tmcycle) {\r
132                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref); };\r
133                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref); };\r
134                         return false;\r
135                     }\r
136                     if (!thcycle) {\r
137                         if (!this._objectref.equals(temp._objectref)) {\r
138                             org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref);\r
139                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref);\r
140                             return false;\r
141                         }\r
142                         org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref);\r
143                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref);\r
144                     }\r
145                 }\r
146             } else if (temp._objectref != null)\r
147                 return false;\r
148             if (this._id != null) {\r
149                 if (temp._id == null) return false;\r
150                 if (this._id != temp._id) {\r
151                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._id);\r
152                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._id);\r
153                     if (thcycle!=tmcycle) {\r
154                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._id); };\r
155                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._id); };\r
156                         return false;\r
157                     }\r
158                     if (!thcycle) {\r
159                         if (!this._id.equals(temp._id)) {\r
160                             org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
161                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
162                             return false;\r
163                         }\r
164                         org.castor.util.CycleBreaker.releaseCycleHandle(this._id);\r
165                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);\r
166                     }\r
167                 }\r
168             } else if (temp._id != null)\r
169                 return false;\r
170             return true;\r
171         }\r
172         return false;\r
173     }\r
174 \r
175     /**\r
176      * Returns the value of field 'compressed'. The field\r
177      * 'compressed' has the following description: true implies\r
178      * data will be decompresses with Zip\r
179      *  before presenting to application \r
180      * \r
181      * @return the value of field 'Compressed'.\r
182      */\r
183     public boolean getCompressed(\r
184     ) {\r
185         return this._compressed;\r
186     }\r
187 \r
188     /**\r
189      * Returns the value of field 'id'. The field 'id' has the\r
190      * following description: Primary Key for vamsas object\r
191      * referencing\r
192      *  \r
193      * \r
194      * @return the value of field 'Id'.\r
195      */\r
196     public java.lang.String getId(\r
197     ) {\r
198         return this._id;\r
199     }\r
200 \r
201     /**\r
202      * Returns the value of field 'objectref'. The field\r
203      * 'objectref' has the following description: Object the\r
204      * arbitrary data is associated with\r
205      *  \r
206      * \r
207      * @return the value of field 'Objectref'.\r
208      */\r
209     public java.lang.Object getObjectref(\r
210     ) {\r
211         return this._objectref;\r
212     }\r
213 \r
214     /**\r
215      * Returns the value of field 'type'. The field 'type' has the\r
216      * following description: Type of arbitrary data - TODO: decide\r
217      * format - use\r
218      *  (extended) MIME types ? \r
219      * \r
220      * @return the value of field 'Type'.\r
221      */\r
222     public java.lang.String getType(\r
223     ) {\r
224         return this._type;\r
225     }\r
226 \r
227     /**\r
228      * Method hasCompressed.\r
229      * \r
230      * @return true if at least one Compressed has been added\r
231      */\r
232     public boolean hasCompressed(\r
233     ) {\r
234         return this._has_compressed;\r
235     }\r
236 \r
237     /**\r
238      * Overrides the java.lang.Object.hashCode method.\r
239      * <p>\r
240      * The following steps came from <b>Effective Java Programming\r
241      * Language Guide</b> by Joshua Bloch, Chapter 3\r
242      * \r
243      * @return a hash code value for the object.\r
244      */\r
245     public int hashCode(\r
246     ) {\r
247         int result = super.hashCode();\r
248         \r
249         long tmp;\r
250         result = 37 * result + (_compressed?0:1);\r
251         if (_type != null\r
252             && !org.castor.util.CycleBreaker.startingToCycle(_type)) {\r
253            result = 37 * result + _type.hashCode();\r
254            org.castor.util.CycleBreaker.releaseCycleHandle(_type);\r
255         }\r
256         if (_objectref != null\r
257             && !org.castor.util.CycleBreaker.startingToCycle(_objectref)) {\r
258            result = 37 * result + _objectref.hashCode();\r
259            org.castor.util.CycleBreaker.releaseCycleHandle(_objectref);\r
260         }\r
261         if (_id != null\r
262             && !org.castor.util.CycleBreaker.startingToCycle(_id)) {\r
263            result = 37 * result + _id.hashCode();\r
264            org.castor.util.CycleBreaker.releaseCycleHandle(_id);\r
265         }\r
266         \r
267         return result;\r
268     }\r
269 \r
270     /**\r
271      * Returns the value of field 'compressed'. The field\r
272      * 'compressed' has the following description: true implies\r
273      * data will be decompresses with Zip\r
274      *  before presenting to application \r
275      * \r
276      * @return the value of field 'Compressed'.\r
277      */\r
278     public boolean isCompressed(\r
279     ) {\r
280         return this._compressed;\r
281     }\r
282 \r
283     /**\r
284      * Method isValid.\r
285      * \r
286      * @return true if this object is valid according to the schema\r
287      */\r
288     public boolean isValid(\r
289     ) {\r
290         try {\r
291             validate();\r
292         } catch (org.exolab.castor.xml.ValidationException vex) {\r
293             return false;\r
294         }\r
295         return true;\r
296     }\r
297 \r
298     /**\r
299      * \r
300      * \r
301      * @param out\r
302      * @throws org.exolab.castor.xml.MarshalException if object is\r
303      * null or if any SAXException is thrown during marshaling\r
304      * @throws org.exolab.castor.xml.ValidationException if this\r
305      * object is an invalid instance according to the schema\r
306      */\r
307     public void marshal(\r
308             final java.io.Writer out)\r
309     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
310         Marshaller.marshal(this, out);\r
311     }\r
312 \r
313     /**\r
314      * \r
315      * \r
316      * @param handler\r
317      * @throws java.io.IOException if an IOException occurs during\r
318      * marshaling\r
319      * @throws org.exolab.castor.xml.ValidationException if this\r
320      * object is an invalid instance according to the schema\r
321      * @throws org.exolab.castor.xml.MarshalException if object is\r
322      * null or if any SAXException is thrown during marshaling\r
323      */\r
324     public void marshal(\r
325             final org.xml.sax.ContentHandler handler)\r
326     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
327         Marshaller.marshal(this, handler);\r
328     }\r
329 \r
330     /**\r
331      * Sets the value of field 'compressed'. The field 'compressed'\r
332      * has the following description: true implies data will be\r
333      * decompresses with Zip\r
334      *  before presenting to application \r
335      * \r
336      * @param compressed the value of field 'compressed'.\r
337      */\r
338     public void setCompressed(\r
339             final boolean compressed) {\r
340         this._compressed = compressed;\r
341         this._has_compressed = true;\r
342     }\r
343 \r
344     /**\r
345      * Sets the value of field 'id'. The field 'id' has the\r
346      * following description: Primary Key for vamsas object\r
347      * referencing\r
348      *  \r
349      * \r
350      * @param id the value of field 'id'.\r
351      */\r
352     public void setId(\r
353             final java.lang.String id) {\r
354         this._id = id;\r
355     }\r
356 \r
357     /**\r
358      * Sets the value of field 'objectref'. The field 'objectref'\r
359      * has the following description: Object the arbitrary data is\r
360      * associated with\r
361      *  \r
362      * \r
363      * @param objectref the value of field 'objectref'.\r
364      */\r
365     public void setObjectref(\r
366             final java.lang.Object objectref) {\r
367         this._objectref = objectref;\r
368     }\r
369 \r
370     /**\r
371      * Sets the value of field 'type'. The field 'type' has the\r
372      * following description: Type of arbitrary data - TODO: decide\r
373      * format - use\r
374      *  (extended) MIME types ? \r
375      * \r
376      * @param type the value of field 'type'.\r
377      */\r
378     public void setType(\r
379             final java.lang.String type) {\r
380         this._type = type;\r
381     }\r
382 \r
383     /**\r
384      * Method unmarshal.\r
385      * \r
386      * @param reader\r
387      * @throws org.exolab.castor.xml.MarshalException if object is\r
388      * null or if any SAXException is thrown during marshaling\r
389      * @throws org.exolab.castor.xml.ValidationException if this\r
390      * object is an invalid instance according to the schema\r
391      * @return the unmarshaled uk.ac.vamsas.objects.core.AppData\r
392      */\r
393     public static uk.ac.vamsas.objects.core.AppData unmarshal(\r
394             final java.io.Reader reader)\r
395     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
396         return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Attachment.class, reader);\r
397     }\r
398 \r
399     /**\r
400      * \r
401      * \r
402      * @throws org.exolab.castor.xml.ValidationException if this\r
403      * object is an invalid instance according to the schema\r
404      */\r
405     public void validate(\r
406     )\r
407     throws org.exolab.castor.xml.ValidationException {\r
408         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
409         validator.validate(this);\r
410     }\r
411 \r
412 }\r