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