d25aea98d9426d61f81dcca293a57ec49684b88d
[vamsas.git] / src / uk / ac / vamsas / objects / core / ReferenceType.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  * base type for citing arbitrary links between vamsas objects\r
19  *  \r
20  *  Optional human readable description of the relationship\r
21  *  \r
22  * \r
23  * @version $Revision$ $Date$\r
24  */\r
25 public class ReferenceType extends uk.ac.vamsas.client.Vobject \r
26 implements java.io.Serializable\r
27 {\r
28 \r
29 \r
30       //--------------------------/\r
31      //- Class/Member Variables -/\r
32     //--------------------------/\r
33 \r
34     /**\r
35      * internal content storage\r
36      */\r
37     private java.lang.String _content = "";\r
38 \r
39     /**\r
40      * Primary Key for vamsas object referencing \r
41      */\r
42     private java.lang.String _id;\r
43 \r
44     /**\r
45      * List of one or more vamsas object references\r
46      */\r
47     private java.util.Vector _refs;\r
48 \r
49 \r
50       //----------------/\r
51      //- Constructors -/\r
52     //----------------/\r
53 \r
54     public ReferenceType() {\r
55         super();\r
56         setContent("");\r
57         this._refs = new java.util.Vector();\r
58     }\r
59 \r
60 \r
61       //-----------/\r
62      //- Methods -/\r
63     //-----------/\r
64 \r
65     /**\r
66      * \r
67      * \r
68      * @param vRefs\r
69      * @throws java.lang.IndexOutOfBoundsException if the index\r
70      * given is outside the bounds of the collection\r
71      */\r
72     public void addRefs(\r
73             final java.lang.Object vRefs)\r
74     throws java.lang.IndexOutOfBoundsException {\r
75         this._refs.addElement(vRefs);\r
76     }\r
77 \r
78     /**\r
79      * \r
80      * \r
81      * @param index\r
82      * @param vRefs\r
83      * @throws java.lang.IndexOutOfBoundsException if the index\r
84      * given is outside the bounds of the collection\r
85      */\r
86     public void addRefs(\r
87             final int index,\r
88             final java.lang.Object vRefs)\r
89     throws java.lang.IndexOutOfBoundsException {\r
90         this._refs.add(index, vRefs);\r
91     }\r
92 \r
93     /**\r
94      * Method enumerateRefs.\r
95      * \r
96      * @return an Enumeration over all java.lang.Object elements\r
97      */\r
98     public java.util.Enumeration enumerateRefs(\r
99     ) {\r
100         return this._refs.elements();\r
101     }\r
102 \r
103     /**\r
104      * Overrides the java.lang.Object.equals method.\r
105      * \r
106      * @param obj\r
107      * @return true if the objects are equal.\r
108      */\r
109     public boolean equals(\r
110             final java.lang.Object obj) {\r
111         if ( this == obj )\r
112             return true;\r
113         \r
114         if (super.equals(obj)==false)\r
115             return false;\r
116         \r
117         if (obj instanceof ReferenceType) {\r
118         \r
119             ReferenceType temp = (ReferenceType)obj;\r
120             if (this._content != null) {\r
121                 if (temp._content == null) return false;\r
122                 else if (!(this._content.equals(temp._content))) \r
123                     return false;\r
124             }\r
125             else if (temp._content != null)\r
126                 return false;\r
127             if (this._id != null) {\r
128                 if (temp._id == null) return false;\r
129                 else if (!(this._id.equals(temp._id))) \r
130                     return false;\r
131             }\r
132             else if (temp._id != null)\r
133                 return false;\r
134             if (this._refs != null) {\r
135                 if (temp._refs == null) return false;\r
136                 else if (!(this._refs.equals(temp._refs))) \r
137                     return false;\r
138             }\r
139             else if (temp._refs != null)\r
140                 return false;\r
141             return true;\r
142         }\r
143         return false;\r
144     }\r
145 \r
146     /**\r
147      * Returns the value of field 'content'. The field 'content'\r
148      * has the following description: internal content storage\r
149      * \r
150      * @return the value of field 'Content'.\r
151      */\r
152     public java.lang.String getContent(\r
153     ) {\r
154         return this._content;\r
155     }\r
156 \r
157     /**\r
158      * Returns the value of field 'id'. The field 'id' has the\r
159      * following description: Primary Key for vamsas object\r
160      * referencing \r
161      * \r
162      * @return the value of field 'Id'.\r
163      */\r
164     public java.lang.String getId(\r
165     ) {\r
166         return this._id;\r
167     }\r
168 \r
169     /**\r
170      * Method getRefs.\r
171      * \r
172      * @param index\r
173      * @throws java.lang.IndexOutOfBoundsException if the index\r
174      * given is outside the bounds of the collection\r
175      * @return the value of the java.lang.Object at the given index\r
176      */\r
177     public java.lang.Object getRefs(\r
178             final int index)\r
179     throws java.lang.IndexOutOfBoundsException {\r
180         // check bounds for index\r
181         if (index < 0 || index >= this._refs.size()) {\r
182             throw new IndexOutOfBoundsException("getRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");\r
183         }\r
184         \r
185         return _refs.get(index);\r
186     }\r
187 \r
188     /**\r
189      * Method getRefs.Returns the contents of the collection in an\r
190      * Array.  <p>Note:  Just in case the collection contents are\r
191      * changing in another thread, we pass a 0-length Array of the\r
192      * correct type into the API call.  This way we <i>know</i>\r
193      * that the Array returned is of exactly the correct length.\r
194      * \r
195      * @return this collection as an Array\r
196      */\r
197     public java.lang.Object[] getRefs(\r
198     ) {\r
199         java.lang.Object[] array = new java.lang.Object[0];\r
200         return (java.lang.Object[]) this._refs.toArray(array);\r
201     }\r
202 \r
203     /**\r
204      * Method getRefsAsReference.Returns a reference to '_refs'. No\r
205      * type checking is performed on any modifications to the\r
206      * Vector.\r
207      * \r
208      * @return a reference to the Vector backing this class\r
209      */\r
210     public java.util.Vector getRefsAsReference(\r
211     ) {\r
212         return this._refs;\r
213     }\r
214 \r
215     /**\r
216      * Method getRefsCount.\r
217      * \r
218      * @return the size of this collection\r
219      */\r
220     public int getRefsCount(\r
221     ) {\r
222         return this._refs.size();\r
223     }\r
224 \r
225     /**\r
226      * Overrides the java.lang.Object.hashCode method.\r
227      * <p>\r
228      * The following steps came from <b>Effective Java Programming\r
229      * Language Guide</b> by Joshua Bloch, Chapter 3\r
230      * \r
231      * @return a hash code value for the object.\r
232      */\r
233     public int hashCode(\r
234     ) {\r
235         int result = super.hashCode();\r
236         \r
237         long tmp;\r
238         if (_content != null) {\r
239            result = 37 * result + _content.hashCode();\r
240         }\r
241         if (_id != null) {\r
242            result = 37 * result + _id.hashCode();\r
243         }\r
244         if (_refs != null) {\r
245            result = 37 * result + _refs.hashCode();\r
246         }\r
247         \r
248         return result;\r
249     }\r
250 \r
251     /**\r
252      * Method isValid.\r
253      * \r
254      * @return true if this object is valid according to the schema\r
255      */\r
256     public boolean isValid(\r
257     ) {\r
258         try {\r
259             validate();\r
260         } catch (org.exolab.castor.xml.ValidationException vex) {\r
261             return false;\r
262         }\r
263         return true;\r
264     }\r
265 \r
266     /**\r
267      * \r
268      * \r
269      * @param out\r
270      * @throws org.exolab.castor.xml.MarshalException if object is\r
271      * null or if any SAXException is thrown during marshaling\r
272      * @throws org.exolab.castor.xml.ValidationException if this\r
273      * object is an invalid instance according to the schema\r
274      */\r
275     public void marshal(\r
276             final java.io.Writer out)\r
277     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
278         Marshaller.marshal(this, out);\r
279     }\r
280 \r
281     /**\r
282      * \r
283      * \r
284      * @param handler\r
285      * @throws java.io.IOException if an IOException occurs during\r
286      * marshaling\r
287      * @throws org.exolab.castor.xml.ValidationException if this\r
288      * object is an invalid instance according to the schema\r
289      * @throws org.exolab.castor.xml.MarshalException if object is\r
290      * null or if any SAXException is thrown during marshaling\r
291      */\r
292     public void marshal(\r
293             final org.xml.sax.ContentHandler handler)\r
294     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
295         Marshaller.marshal(this, handler);\r
296     }\r
297 \r
298     /**\r
299      */\r
300     public void removeAllRefs(\r
301     ) {\r
302         this._refs.clear();\r
303     }\r
304 \r
305     /**\r
306      * Method removeRefs.\r
307      * \r
308      * @param vRefs\r
309      * @return true if the object was removed from the collection.\r
310      */\r
311     public boolean removeRefs(\r
312             final java.lang.Object vRefs) {\r
313         boolean removed = _refs.remove(vRefs);\r
314         return removed;\r
315     }\r
316 \r
317     /**\r
318      * Method removeRefsAt.\r
319      * \r
320      * @param index\r
321      * @return the element removed from the collection\r
322      */\r
323     public java.lang.Object removeRefsAt(\r
324             final int index) {\r
325         java.lang.Object obj = this._refs.remove(index);\r
326         return obj;\r
327     }\r
328 \r
329     /**\r
330      * Sets the value of field 'content'. The field 'content' has\r
331      * the following description: internal content storage\r
332      * \r
333      * @param content the value of field 'content'.\r
334      */\r
335     public void setContent(\r
336             final java.lang.String content) {\r
337         this._content = content;\r
338     }\r
339 \r
340     /**\r
341      * Sets the value of field 'id'. The field 'id' has the\r
342      * following description: Primary Key for vamsas object\r
343      * referencing \r
344      * \r
345      * @param id the value of field 'id'.\r
346      */\r
347     public void setId(\r
348             final java.lang.String id) {\r
349         this._id = id;\r
350     }\r
351 \r
352     /**\r
353      * \r
354      * \r
355      * @param index\r
356      * @param vRefs\r
357      * @throws java.lang.IndexOutOfBoundsException if the index\r
358      * given is outside the bounds of the collection\r
359      */\r
360     public void setRefs(\r
361             final int index,\r
362             final java.lang.Object vRefs)\r
363     throws java.lang.IndexOutOfBoundsException {\r
364         // check bounds for index\r
365         if (index < 0 || index >= this._refs.size()) {\r
366             throw new IndexOutOfBoundsException("setRefs: Index value '" + index + "' not in range [0.." + (this._refs.size() - 1) + "]");\r
367         }\r
368         \r
369         this._refs.set(index, vRefs);\r
370     }\r
371 \r
372     /**\r
373      * \r
374      * \r
375      * @param vRefsArray\r
376      */\r
377     public void setRefs(\r
378             final java.lang.Object[] vRefsArray) {\r
379         //-- copy array\r
380         _refs.clear();\r
381         \r
382         for (int i = 0; i < vRefsArray.length; i++) {\r
383                 this._refs.add(vRefsArray[i]);\r
384         }\r
385     }\r
386 \r
387     /**\r
388      * Sets the value of '_refs' by copying the given Vector. All\r
389      * elements will be checked for type safety.\r
390      * \r
391      * @param vRefsList the Vector to copy.\r
392      */\r
393     public void setRefs(\r
394             final java.util.Vector vRefsList) {\r
395         // copy vector\r
396         this._refs.clear();\r
397         \r
398         this._refs.addAll(vRefsList);\r
399     }\r
400 \r
401     /**\r
402      * Sets the value of '_refs' by setting it to the given Vector.\r
403      * No type checking is performed.\r
404      * @deprecated\r
405      * \r
406      * @param refsVector the Vector to set.\r
407      */\r
408     public void setRefsAsReference(\r
409             final java.util.Vector refsVector) {\r
410         this._refs = refsVector;\r
411     }\r
412 \r
413     /**\r
414      * Method unmarshal.\r
415      * \r
416      * @param reader\r
417      * @throws org.exolab.castor.xml.MarshalException if object is\r
418      * null or if any SAXException is thrown during marshaling\r
419      * @throws org.exolab.castor.xml.ValidationException if this\r
420      * object is an invalid instance according to the schema\r
421      * @return the unmarshaled\r
422      * uk.ac.vamsas.objects.core.ReferenceType\r
423      */\r
424     public static uk.ac.vamsas.objects.core.ReferenceType unmarshal(\r
425             final java.io.Reader reader)\r
426     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {\r
427         return (uk.ac.vamsas.objects.core.ReferenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ReferenceType.class, reader);\r
428     }\r
429 \r
430     /**\r
431      * \r
432      * \r
433      * @throws org.exolab.castor.xml.ValidationException if this\r
434      * object is an invalid instance according to the schema\r
435      */\r
436     public void validate(\r
437     )\r
438     throws org.exolab.castor.xml.ValidationException {\r
439         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();\r
440         validator.validate(this);\r
441     }\r
442 \r
443 }\r