2 * This class was automatically generated with
\r
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
\r
8 package uk.ac.vamsas.objects.core;
\r
10 //---------------------------------/
\r
11 //- Imported classes and packages -/
\r
12 //---------------------------------/
\r
14 import org.exolab.castor.xml.Marshaller;
\r
15 import org.exolab.castor.xml.Unmarshaller;
\r
20 * @version $Revision$ $Date$
\r
22 public class Attachment extends uk.ac.vamsas.objects.core.AppData
\r
23 implements java.io.Serializable
\r
27 //--------------------------/
\r
28 //- Class/Member Variables -/
\r
29 //--------------------------/
\r
32 * true implies data will be decompresses with Zip
\r
33 * before presenting to application
\r
35 private boolean _compressed = false;
\r
38 * keeps track of state for field: _compressed
\r
40 private boolean _has_compressed;
\r
43 * Type of arbitrary data - TODO: decide format - use
\r
44 * (extended) MIME types ?
\r
46 private java.lang.String _type;
\r
49 * Object the arbitrary data is associated with
\r
52 private java.lang.Object _objectref;
\r
55 * Primary Key for vamsas object referencing
\r
58 private java.lang.String _id;
\r
65 public Attachment() {
\r
76 public void deleteCompressed(
\r
78 this._has_compressed= false;
\r
82 * Overrides the java.lang.Object.equals method.
\r
85 * @return true if the objects are equal.
\r
87 public boolean equals(
\r
88 final java.lang.Object obj) {
\r
92 if (super.equals(obj)==false)
\r
95 if (obj instanceof Attachment) {
\r
97 Attachment temp = (Attachment)obj;
\r
100 if (this._compressed != temp._compressed)
\r
102 if (this._has_compressed != temp._has_compressed)
\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
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
120 org.castor.util.CycleBreaker.releaseCycleHandle(this._type);
\r
121 org.castor.util.CycleBreaker.releaseCycleHandle(temp._type);
\r
124 } else if (temp._type != null)
\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
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
142 org.castor.util.CycleBreaker.releaseCycleHandle(this._objectref);
\r
143 org.castor.util.CycleBreaker.releaseCycleHandle(temp._objectref);
\r
146 } else if (temp._objectref != null)
\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
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
164 org.castor.util.CycleBreaker.releaseCycleHandle(this._id);
\r
165 org.castor.util.CycleBreaker.releaseCycleHandle(temp._id);
\r
168 } else if (temp._id != null)
\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
181 * @return the value of field 'Compressed'.
\r
183 public boolean getCompressed(
\r
185 return this._compressed;
\r
189 * Returns the value of field 'id'. The field 'id' has the
\r
190 * following description: Primary Key for vamsas object
\r
194 * @return the value of field 'Id'.
\r
196 public java.lang.String getId(
\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
207 * @return the value of field 'Objectref'.
\r
209 public java.lang.Object getObjectref(
\r
211 return this._objectref;
\r
215 * Returns the value of field 'type'. The field 'type' has the
\r
216 * following description: Type of arbitrary data - TODO: decide
\r
218 * (extended) MIME types ?
\r
220 * @return the value of field 'Type'.
\r
222 public java.lang.String getType(
\r
228 * Method hasCompressed.
\r
230 * @return true if at least one Compressed has been added
\r
232 public boolean hasCompressed(
\r
234 return this._has_compressed;
\r
238 * Overrides the java.lang.Object.hashCode method.
\r
240 * The following steps came from <b>Effective Java Programming
\r
241 * Language Guide</b> by Joshua Bloch, Chapter 3
\r
243 * @return a hash code value for the object.
\r
245 public int hashCode(
\r
247 int result = super.hashCode();
\r
250 result = 37 * result + (_compressed?0:1);
\r
252 && !org.castor.util.CycleBreaker.startingToCycle(_type)) {
\r
253 result = 37 * result + _type.hashCode();
\r
254 org.castor.util.CycleBreaker.releaseCycleHandle(_type);
\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
262 && !org.castor.util.CycleBreaker.startingToCycle(_id)) {
\r
263 result = 37 * result + _id.hashCode();
\r
264 org.castor.util.CycleBreaker.releaseCycleHandle(_id);
\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
276 * @return the value of field 'Compressed'.
\r
278 public boolean isCompressed(
\r
280 return this._compressed;
\r
286 * @return true if this object is valid according to the schema
\r
288 public boolean isValid(
\r
292 } catch (org.exolab.castor.xml.ValidationException vex) {
\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
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
317 * @throws java.io.IOException if an IOException occurs during
\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
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
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
336 * @param compressed the value of field 'compressed'.
\r
338 public void setCompressed(
\r
339 final boolean compressed) {
\r
340 this._compressed = compressed;
\r
341 this._has_compressed = true;
\r
345 * Sets the value of field 'id'. The field 'id' has the
\r
346 * following description: Primary Key for vamsas object
\r
350 * @param id the value of field 'id'.
\r
353 final java.lang.String id) {
\r
358 * Sets the value of field 'objectref'. The field 'objectref'
\r
359 * has the following description: Object the arbitrary data is
\r
363 * @param objectref the value of field 'objectref'.
\r
365 public void setObjectref(
\r
366 final java.lang.Object objectref) {
\r
367 this._objectref = objectref;
\r
371 * Sets the value of field 'type'. The field 'type' has the
\r
372 * following description: Type of arbitrary data - TODO: decide
\r
374 * (extended) MIME types ?
\r
376 * @param type the value of field 'type'.
\r
378 public void setType(
\r
379 final java.lang.String type) {
\r
384 * Method unmarshal.
\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
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
402 * @throws org.exolab.castor.xml.ValidationException if this
\r
403 * object is an invalid instance according to the schema
\r
405 public void validate(
\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