rebult for castor-1.1(vamsas version)
[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             if (this._compressed != temp._compressed)\r
99                 return false;\r
100             if (this._has_compressed != temp._has_compressed)\r
101                 return false;\r
102             if (this._type != null) {\r
103                 if (temp._type == null) return false;\r
104                 else if (!(this._type.equals(temp._type))) \r
105                     return false;\r
106             }\r
107             else if (temp._type != null)\r
108                 return false;\r
109             if (this._objectref != null) {\r
110                 if (temp._objectref == null) return false;\r
111                 else if (!(this._objectref.equals(temp._objectref))) \r
112                     return false;\r
113             }\r
114             else if (temp._objectref != null)\r
115                 return false;\r
116             if (this._id != null) {\r
117                 if (temp._id == null) return false;\r
118                 else if (!(this._id.equals(temp._id))) \r
119                     return false;\r
120             }\r
121             else if (temp._id != null)\r
122                 return false;\r
123             return true;\r
124         }\r
125         return false;\r
126     }\r
127 \r
128     /**\r
129      * Returns the value of field 'compressed'. The field\r
130      * 'compressed' has the following description: true implies\r
131      * data will be decompresses with Zip\r
132      *  before presenting to application \r
133      * \r
134      * @return the value of field 'Compressed'.\r
135      */\r
136     public boolean getCompressed(\r
137     ) {\r
138         return this._compressed;\r
139     }\r
140 \r
141     /**\r
142      * Returns the value of field 'id'. The field 'id' has the\r
143      * following description: Primary Key for vamsas object\r
144      * referencing\r
145      *  \r
146      * \r
147      * @return the value of field 'Id'.\r
148      */\r
149     public java.lang.String getId(\r
150     ) {\r
151         return this._id;\r
152     }\r
153 \r
154     /**\r
155      * Returns the value of field 'objectref'. The field\r
156      * 'objectref' has the following description: Object the\r
157      * arbitrary data is associated with\r
158      *  \r
159      * \r
160      * @return the value of field 'Objectref'.\r
161      */\r
162     public java.lang.Object getObjectref(\r
163     ) {\r
164         return this._objectref;\r
165     }\r
166 \r
167     /**\r
168      * Returns the value of field 'type'. The field 'type' has the\r
169      * following description: Type of arbitrary data - TODO: decide\r
170      * format - use\r
171      *  (extended) MIME types ? \r
172      * \r
173      * @return the value of field 'Type'.\r
174      */\r
175     public java.lang.String getType(\r
176     ) {\r
177         return this._type;\r
178     }\r
179 \r
180     /**\r
181      * Method hasCompressed.\r
182      * \r
183      * @return true if at least one Compressed has been added\r
184      */\r
185     public boolean hasCompressed(\r
186     ) {\r
187         return this._has_compressed;\r
188     }\r
189 \r
190     /**\r
191      * Overrides the java.lang.Object.hashCode method.\r
192      * <p>\r
193      * The following steps came from <b>Effective Java Programming\r
194      * Language Guide</b> by Joshua Bloch, Chapter 3\r
195      * \r
196      * @return a hash code value for the object.\r
197      */\r
198     public int hashCode(\r
199     ) {\r
200         int result = super.hashCode();\r
201         \r
202         long tmp;\r
203         result = 37 * result + (_compressed?0:1);\r
204         if (_type != null) {\r
205            result = 37 * result + _type.hashCode();\r
206         }\r
207         if (_objectref != null) {\r
208            result = 37 * result + _objectref.hashCode();\r
209         }\r
210         if (_id != null) {\r
211            result = 37 * result + _id.hashCode();\r
212         }\r
213         \r
214         return result;\r
215     }\r
216 \r
217     /**\r
218      * Returns the value of field 'compressed'. The field\r
219      * 'compressed' has the following description: true implies\r
220      * data will be decompresses with Zip\r
221      *  before presenting to application \r
222      * \r
223      * @return the value of field 'Compressed'.\r
224      */\r
225     public boolean isCompressed(\r
226     ) {\r
227         return this._compressed;\r
228     }\r
229 \r
230     /**\r
231      * Method isValid.\r
232      * \r
233      * @return true if this object is valid according to the schema\r
234      */\r
235     public boolean isValid(\r
236     ) {\r
237         try {\r
238             validate();\r
239         } catch (org.exolab.castor.xml.ValidationException vex) {\r
240             return false;\r
241         }\r
242         return true;\r
243     }\r
244 \r
245     /**\r
246      * \r
247      * \r
248      * @param out\r
249      * @throws org.exolab.castor.xml.MarshalException if object is\r
250      * null or if any SAXException is thrown during marshaling\r
251      * @throws org.exolab.castor.xml.ValidationException if this\r
252      * object is an invalid instance according to the schema\r
253      */\r
254     public void marshal(\r
255             final java.io.Writer out)\r
256     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
257         Marshaller.marshal(this, out);\r
258     }\r
259 \r
260     /**\r
261      * \r
262      * \r
263      * @param handler\r
264      * @throws java.io.IOException if an IOException occurs during\r
265      * marshaling\r
266      * @throws org.exolab.castor.xml.ValidationException if this\r
267      * object is an invalid instance according to the schema\r
268      * @throws org.exolab.castor.xml.MarshalException if object is\r
269      * null or if any SAXException is thrown during marshaling\r
270      */\r
271     public void marshal(\r
272             final org.xml.sax.ContentHandler handler)\r
273     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
274         Marshaller.marshal(this, handler);\r
275     }\r
276 \r
277     /**\r
278      * Sets the value of field 'compressed'. The field 'compressed'\r
279      * has the following description: true implies data will be\r
280      * decompresses with Zip\r
281      *  before presenting to application \r
282      * \r
283      * @param compressed the value of field 'compressed'.\r
284      */\r
285     public void setCompressed(\r
286             final boolean compressed) {\r
287         this._compressed = compressed;\r
288         this._has_compressed = true;\r
289     }\r
290 \r
291     /**\r
292      * Sets the value of field 'id'. The field 'id' has the\r
293      * following description: Primary Key for vamsas object\r
294      * referencing\r
295      *  \r
296      * \r
297      * @param id the value of field 'id'.\r
298      */\r
299     public void setId(\r
300             final java.lang.String id) {\r
301         this._id = id;\r
302     }\r
303 \r
304     /**\r
305      * Sets the value of field 'objectref'. The field 'objectref'\r
306      * has the following description: Object the arbitrary data is\r
307      * associated with\r
308      *  \r
309      * \r
310      * @param objectref the value of field 'objectref'.\r
311      */\r
312     public void setObjectref(\r
313             final java.lang.Object objectref) {\r
314         this._objectref = objectref;\r
315     }\r
316 \r
317     /**\r
318      * Sets the value of field 'type'. The field 'type' has the\r
319      * following description: Type of arbitrary data - TODO: decide\r
320      * format - use\r
321      *  (extended) MIME types ? \r
322      * \r
323      * @param type the value of field 'type'.\r
324      */\r
325     public void setType(\r
326             final java.lang.String type) {\r
327         this._type = type;\r
328     }\r
329 \r
330     /**\r
331      * Method unmarshal.\r
332      * \r
333      * @param reader\r
334      * @throws org.exolab.castor.xml.MarshalException if object is\r
335      * null or if any SAXException is thrown during marshaling\r
336      * @throws org.exolab.castor.xml.ValidationException if this\r
337      * object is an invalid instance according to the schema\r
338      * @return the unmarshaled uk.ac.vamsas.objects.core.AppData\r
339      */\r
340     public static uk.ac.vamsas.objects.core.AppData unmarshal(\r
341             final java.io.Reader reader)\r
342     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
343         return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Attachment.class, reader);\r
344     }\r
345 \r
346     /**\r
347      * \r
348      * \r
349      * @throws org.exolab.castor.xml.ValidationException if this\r
350      * object is an invalid instance according to the schema\r
351      */\r
352     public void validate(\r
353     )\r
354     throws org.exolab.castor.xml.ValidationException {\r
355         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
356         validator.validate(this);\r
357     }\r
358 \r
359 }\r