schema changes: provenance-entry-date is now an xmlSchema:dateTime bound directly...
[vamsas.git] / src / uk / ac / vamsas / objects / core / Treenode.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  * node identity and mapping data between tree representations and\r
19  * vamsas document objects\r
20  *  \r
21  * \r
22  * @version $Revision$ $Date$\r
23  */\r
24 public class Treenode extends uk.ac.vamsas.objects.core.NodeType \r
25 implements java.io.Serializable\r
26 {\r
27 \r
28 \r
29       //--------------------------/\r
30      //- Class/Member Variables -/\r
31     //--------------------------/\r
32 \r
33     /**\r
34      * reference to one or more trees containing the node being\r
35      * described.\r
36      *  \r
37      */\r
38     private java.util.Vector _treeId;\r
39 \r
40     /**\r
41      * String uniquely identifying a particular node in the\r
42      * referenced tree according to the format of the tree\r
43      * representation that is referenced.\r
44      *  \r
45      */\r
46     private java.lang.String _nodespec;\r
47 \r
48 \r
49       //----------------/\r
50      //- Constructors -/\r
51     //----------------/\r
52 \r
53     public Treenode() {\r
54         super();\r
55         this._treeId = new java.util.Vector();\r
56     }\r
57 \r
58 \r
59       //-----------/\r
60      //- Methods -/\r
61     //-----------/\r
62 \r
63     /**\r
64      * \r
65      * \r
66      * @param vTreeId\r
67      * @throws java.lang.IndexOutOfBoundsException if the index\r
68      * given is outside the bounds of the collection\r
69      */\r
70     public void addTreeId(\r
71             final java.lang.Object vTreeId)\r
72     throws java.lang.IndexOutOfBoundsException {\r
73         this._treeId.addElement(vTreeId);\r
74     }\r
75 \r
76     /**\r
77      * \r
78      * \r
79      * @param index\r
80      * @param vTreeId\r
81      * @throws java.lang.IndexOutOfBoundsException if the index\r
82      * given is outside the bounds of the collection\r
83      */\r
84     public void addTreeId(\r
85             final int index,\r
86             final java.lang.Object vTreeId)\r
87     throws java.lang.IndexOutOfBoundsException {\r
88         this._treeId.add(index, vTreeId);\r
89     }\r
90 \r
91     /**\r
92      * Method enumerateTreeId.\r
93      * \r
94      * @return an Enumeration over all java.lang.Object elements\r
95      */\r
96     public java.util.Enumeration enumerateTreeId(\r
97     ) {\r
98         return this._treeId.elements();\r
99     }\r
100 \r
101     /**\r
102      * Overrides the java.lang.Object.equals method.\r
103      * \r
104      * @param obj\r
105      * @return true if the objects are equal.\r
106      */\r
107     public boolean equals(\r
108             final java.lang.Object obj) {\r
109         if ( this == obj )\r
110             return true;\r
111         \r
112         if (super.equals(obj)==false)\r
113             return false;\r
114         \r
115         if (obj instanceof Treenode) {\r
116         \r
117             Treenode temp = (Treenode)obj;\r
118             if (this._treeId != null) {\r
119                 if (temp._treeId == null) return false;\r
120                 else if (!(this._treeId.equals(temp._treeId))) \r
121                     return false;\r
122             }\r
123             else if (temp._treeId != null)\r
124                 return false;\r
125             if (this._nodespec != null) {\r
126                 if (temp._nodespec == null) return false;\r
127                 else if (!(this._nodespec.equals(temp._nodespec))) \r
128                     return false;\r
129             }\r
130             else if (temp._nodespec != null)\r
131                 return false;\r
132             return true;\r
133         }\r
134         return false;\r
135     }\r
136 \r
137     /**\r
138      * Returns the value of field 'nodespec'. The field 'nodespec'\r
139      * has the following description: String uniquely identifying a\r
140      * particular node in the referenced tree according to the\r
141      * format of the tree representation that is referenced.\r
142      *  \r
143      * \r
144      * @return the value of field 'Nodespec'.\r
145      */\r
146     public java.lang.String getNodespec(\r
147     ) {\r
148         return this._nodespec;\r
149     }\r
150 \r
151     /**\r
152      * Method getTreeId.\r
153      * \r
154      * @param index\r
155      * @throws java.lang.IndexOutOfBoundsException if the index\r
156      * given is outside the bounds of the collection\r
157      * @return the value of the java.lang.Object at the given index\r
158      */\r
159     public java.lang.Object getTreeId(\r
160             final int index)\r
161     throws java.lang.IndexOutOfBoundsException {\r
162         // check bounds for index\r
163         if (index < 0 || index >= this._treeId.size()) {\r
164             throw new IndexOutOfBoundsException("getTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");\r
165         }\r
166         \r
167         return _treeId.get(index);\r
168     }\r
169 \r
170     /**\r
171      * Method getTreeId.Returns the contents of the collection in\r
172      * an Array.  <p>Note:  Just in case the collection contents\r
173      * are changing in another thread, we pass a 0-length Array of\r
174      * the correct type into the API call.  This way we <i>know</i>\r
175      * that the Array returned is of exactly the correct length.\r
176      * \r
177      * @return this collection as an Array\r
178      */\r
179     public java.lang.Object[] getTreeId(\r
180     ) {\r
181         java.lang.Object[] array = new java.lang.Object[0];\r
182         return (java.lang.Object[]) this._treeId.toArray(array);\r
183     }\r
184 \r
185     /**\r
186      * Method getTreeIdAsReference.Returns a reference to\r
187      * '_treeId'. No type checking is performed on any\r
188      * modifications to the Vector.\r
189      * \r
190      * @return a reference to the Vector backing this class\r
191      */\r
192     public java.util.Vector getTreeIdAsReference(\r
193     ) {\r
194         return this._treeId;\r
195     }\r
196 \r
197     /**\r
198      * Method getTreeIdCount.\r
199      * \r
200      * @return the size of this collection\r
201      */\r
202     public int getTreeIdCount(\r
203     ) {\r
204         return this._treeId.size();\r
205     }\r
206 \r
207     /**\r
208      * Overrides the java.lang.Object.hashCode method.\r
209      * <p>\r
210      * The following steps came from <b>Effective Java Programming\r
211      * Language Guide</b> by Joshua Bloch, Chapter 3\r
212      * \r
213      * @return a hash code value for the object.\r
214      */\r
215     public int hashCode(\r
216     ) {\r
217         int result = super.hashCode();\r
218         \r
219         long tmp;\r
220         if (_treeId != null) {\r
221            result = 37 * result + _treeId.hashCode();\r
222         }\r
223         if (_nodespec != null) {\r
224            result = 37 * result + _nodespec.hashCode();\r
225         }\r
226         \r
227         return result;\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      */\r
279     public void removeAllTreeId(\r
280     ) {\r
281         this._treeId.clear();\r
282     }\r
283 \r
284     /**\r
285      * Method removeTreeId.\r
286      * \r
287      * @param vTreeId\r
288      * @return true if the object was removed from the collection.\r
289      */\r
290     public boolean removeTreeId(\r
291             final java.lang.Object vTreeId) {\r
292         boolean removed = _treeId.remove(vTreeId);\r
293         return removed;\r
294     }\r
295 \r
296     /**\r
297      * Method removeTreeIdAt.\r
298      * \r
299      * @param index\r
300      * @return the element removed from the collection\r
301      */\r
302     public java.lang.Object removeTreeIdAt(\r
303             final int index) {\r
304         java.lang.Object obj = this._treeId.remove(index);\r
305         return obj;\r
306     }\r
307 \r
308     /**\r
309      * Sets the value of field 'nodespec'. The field 'nodespec' has\r
310      * the following description: String uniquely identifying a\r
311      * particular node in the referenced tree according to the\r
312      * format of the tree representation that is referenced.\r
313      *  \r
314      * \r
315      * @param nodespec the value of field 'nodespec'.\r
316      */\r
317     public void setNodespec(\r
318             final java.lang.String nodespec) {\r
319         this._nodespec = nodespec;\r
320     }\r
321 \r
322     /**\r
323      * \r
324      * \r
325      * @param index\r
326      * @param vTreeId\r
327      * @throws java.lang.IndexOutOfBoundsException if the index\r
328      * given is outside the bounds of the collection\r
329      */\r
330     public void setTreeId(\r
331             final int index,\r
332             final java.lang.Object vTreeId)\r
333     throws java.lang.IndexOutOfBoundsException {\r
334         // check bounds for index\r
335         if (index < 0 || index >= this._treeId.size()) {\r
336             throw new IndexOutOfBoundsException("setTreeId: Index value '" + index + "' not in range [0.." + (this._treeId.size() - 1) + "]");\r
337         }\r
338         \r
339         this._treeId.set(index, vTreeId);\r
340     }\r
341 \r
342     /**\r
343      * \r
344      * \r
345      * @param vTreeIdArray\r
346      */\r
347     public void setTreeId(\r
348             final java.lang.Object[] vTreeIdArray) {\r
349         //-- copy array\r
350         _treeId.clear();\r
351         \r
352         for (int i = 0; i < vTreeIdArray.length; i++) {\r
353                 this._treeId.add(vTreeIdArray[i]);\r
354         }\r
355     }\r
356 \r
357     /**\r
358      * Sets the value of '_treeId' by copying the given Vector. All\r
359      * elements will be checked for type safety.\r
360      * \r
361      * @param vTreeIdList the Vector to copy.\r
362      */\r
363     public void setTreeId(\r
364             final java.util.Vector vTreeIdList) {\r
365         // copy vector\r
366         this._treeId.clear();\r
367         \r
368         this._treeId.addAll(vTreeIdList);\r
369     }\r
370 \r
371     /**\r
372      * Sets the value of '_treeId' by setting it to the given\r
373      * Vector. No type checking is performed.\r
374      * @deprecated\r
375      * \r
376      * @param treeIdVector the Vector to set.\r
377      */\r
378     public void setTreeIdAsReference(\r
379             final java.util.Vector treeIdVector) {\r
380         this._treeId = treeIdVector;\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.NodeType\r
392      */\r
393     public static uk.ac.vamsas.objects.core.NodeType 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.NodeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Treenode.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