5bd5c283bbf65718283c730a8e5ebc462758c563
[vamsas.git] / src / org / vamsas / objects / core / Tree.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package org.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import java.io.IOException;
15 import java.io.Reader;
16 import java.io.Serializable;
17 import java.io.Writer;
18 import java.util.Enumeration;
19 import java.util.Vector;
20 import org.exolab.castor.xml.MarshalException;
21 import org.exolab.castor.xml.Marshaller;
22 import org.exolab.castor.xml.Unmarshaller;
23 import org.exolab.castor.xml.ValidationException;
24 import org.xml.sax.ContentHandler;
25
26 /**
27  * Class Tree.
28  * 
29  * @version $Revision$ $Date$
30  */
31 public class Tree extends org.vamsas.client.Vobject 
32 implements java.io.Serializable
33 {
34
35
36       //--------------------------/
37      //- Class/Member Variables -/
38     //--------------------------/
39
40     /**
41      * Field _id
42      */
43     private java.lang.String _id;
44
45     /**
46      * Field _title
47      */
48     private java.lang.String _title;
49
50     /**
51      * Field _newickList
52      */
53     private java.util.Vector _newickList;
54
55     /**
56      * Field _provenance
57      */
58     private org.vamsas.objects.core.Provenance _provenance;
59
60
61       //----------------/
62      //- Constructors -/
63     //----------------/
64
65     public Tree() 
66      {
67         super();
68         _newickList = new Vector();
69     } //-- org.vamsas.objects.core.Tree()
70
71
72       //-----------/
73      //- Methods -/
74     //-----------/
75
76     /**
77      * Method addNewick
78      * 
79      * 
80      * 
81      * @param vNewick
82      */
83     public void addNewick(org.vamsas.objects.core.Newick vNewick)
84         throws java.lang.IndexOutOfBoundsException
85     {
86         _newickList.addElement(vNewick);
87     } //-- void addNewick(org.vamsas.objects.core.Newick) 
88
89     /**
90      * Method addNewick
91      * 
92      * 
93      * 
94      * @param index
95      * @param vNewick
96      */
97     public void addNewick(int index, org.vamsas.objects.core.Newick vNewick)
98         throws java.lang.IndexOutOfBoundsException
99     {
100         _newickList.insertElementAt(vNewick, index);
101     } //-- void addNewick(int, org.vamsas.objects.core.Newick) 
102
103     /**
104      * Method enumerateNewick
105      * 
106      * 
107      * 
108      * @return Enumeration
109      */
110     public java.util.Enumeration enumerateNewick()
111     {
112         return _newickList.elements();
113     } //-- java.util.Enumeration enumerateNewick() 
114
115     /**
116      * Note: hashCode() has not been overriden
117      * 
118      * @param obj
119      * @return boolean
120      */
121     public boolean equals(java.lang.Object obj)
122     {
123         if ( this == obj )
124             return true;
125         
126         if (super.equals(obj)==false)
127             return false;
128         
129         if (obj instanceof Tree) {
130         
131             Tree temp = (Tree)obj;
132             if (this._id != null) {
133                 if (temp._id == null) return false;
134                 else if (!(this._id.equals(temp._id))) 
135                     return false;
136             }
137             else if (temp._id != null)
138                 return false;
139             if (this._title != null) {
140                 if (temp._title == null) return false;
141                 else if (!(this._title.equals(temp._title))) 
142                     return false;
143             }
144             else if (temp._title != null)
145                 return false;
146             if (this._newickList != null) {
147                 if (temp._newickList == null) return false;
148                 else if (!(this._newickList.equals(temp._newickList))) 
149                     return false;
150             }
151             else if (temp._newickList != null)
152                 return false;
153             if (this._provenance != null) {
154                 if (temp._provenance == null) return false;
155                 else if (!(this._provenance.equals(temp._provenance))) 
156                     return false;
157             }
158             else if (temp._provenance != null)
159                 return false;
160             return true;
161         }
162         return false;
163     } //-- boolean equals(java.lang.Object) 
164
165     /**
166      * Returns the value of field 'id'.
167      * 
168      * @return String
169      * @return the value of field 'id'.
170      */
171     public java.lang.String getId()
172     {
173         return this._id;
174     } //-- java.lang.String getId() 
175
176     /**
177      * Method getNewick
178      * 
179      * 
180      * 
181      * @param index
182      * @return Newick
183      */
184     public org.vamsas.objects.core.Newick getNewick(int index)
185         throws java.lang.IndexOutOfBoundsException
186     {
187         //-- check bounds for index
188         if ((index < 0) || (index > _newickList.size())) {
189             throw new IndexOutOfBoundsException("getNewick: Index value '"+index+"' not in range [0.."+_newickList.size()+ "]");
190         }
191         
192         return (org.vamsas.objects.core.Newick) _newickList.elementAt(index);
193     } //-- org.vamsas.objects.core.Newick getNewick(int) 
194
195     /**
196      * Method getNewick
197      * 
198      * 
199      * 
200      * @return Newick
201      */
202     public org.vamsas.objects.core.Newick[] getNewick()
203     {
204         int size = _newickList.size();
205         org.vamsas.objects.core.Newick[] mArray = new org.vamsas.objects.core.Newick[size];
206         for (int index = 0; index < size; index++) {
207             mArray[index] = (org.vamsas.objects.core.Newick) _newickList.elementAt(index);
208         }
209         return mArray;
210     } //-- org.vamsas.objects.core.Newick[] getNewick() 
211
212     /**
213      * Method getNewickCount
214      * 
215      * 
216      * 
217      * @return int
218      */
219     public int getNewickCount()
220     {
221         return _newickList.size();
222     } //-- int getNewickCount() 
223
224     /**
225      * Returns the value of field 'provenance'.
226      * 
227      * @return Provenance
228      * @return the value of field 'provenance'.
229      */
230     public org.vamsas.objects.core.Provenance getProvenance()
231     {
232         return this._provenance;
233     } //-- org.vamsas.objects.core.Provenance getProvenance() 
234
235     /**
236      * Returns the value of field 'title'.
237      * 
238      * @return String
239      * @return the value of field 'title'.
240      */
241     public java.lang.String getTitle()
242     {
243         return this._title;
244     } //-- java.lang.String getTitle() 
245
246     /**
247      * Method isValid
248      * 
249      * 
250      * 
251      * @return boolean
252      */
253     public boolean isValid()
254     {
255         try {
256             validate();
257         }
258         catch (org.exolab.castor.xml.ValidationException vex) {
259             return false;
260         }
261         return true;
262     } //-- boolean isValid() 
263
264     /**
265      * Method marshal
266      * 
267      * 
268      * 
269      * @param out
270      */
271     public void marshal(java.io.Writer out)
272         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
273     {
274         
275         Marshaller.marshal(this, out);
276     } //-- void marshal(java.io.Writer) 
277
278     /**
279      * Method marshal
280      * 
281      * 
282      * 
283      * @param handler
284      */
285     public void marshal(org.xml.sax.ContentHandler handler)
286         throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
287     {
288         
289         Marshaller.marshal(this, handler);
290     } //-- void marshal(org.xml.sax.ContentHandler) 
291
292     /**
293      * Method removeAllNewick
294      * 
295      */
296     public void removeAllNewick()
297     {
298         _newickList.removeAllElements();
299     } //-- void removeAllNewick() 
300
301     /**
302      * Method removeNewick
303      * 
304      * 
305      * 
306      * @param index
307      * @return Newick
308      */
309     public org.vamsas.objects.core.Newick removeNewick(int index)
310     {
311         java.lang.Object obj = _newickList.elementAt(index);
312         _newickList.removeElementAt(index);
313         return (org.vamsas.objects.core.Newick) obj;
314     } //-- org.vamsas.objects.core.Newick removeNewick(int) 
315
316     /**
317      * Sets the value of field 'id'.
318      * 
319      * @param id the value of field 'id'.
320      */
321     public void setId(java.lang.String id)
322     {
323         this._id = id;
324     } //-- void setId(java.lang.String) 
325
326     /**
327      * Method setNewick
328      * 
329      * 
330      * 
331      * @param index
332      * @param vNewick
333      */
334     public void setNewick(int index, org.vamsas.objects.core.Newick vNewick)
335         throws java.lang.IndexOutOfBoundsException
336     {
337         //-- check bounds for index
338         if ((index < 0) || (index > _newickList.size())) {
339             throw new IndexOutOfBoundsException("setNewick: Index value '"+index+"' not in range [0.."+_newickList.size()+ "]");
340         }
341         _newickList.setElementAt(vNewick, index);
342     } //-- void setNewick(int, org.vamsas.objects.core.Newick) 
343
344     /**
345      * Method setNewick
346      * 
347      * 
348      * 
349      * @param newickArray
350      */
351     public void setNewick(org.vamsas.objects.core.Newick[] newickArray)
352     {
353         //-- copy array
354         _newickList.removeAllElements();
355         for (int i = 0; i < newickArray.length; i++) {
356             _newickList.addElement(newickArray[i]);
357         }
358     } //-- void setNewick(org.vamsas.objects.core.Newick) 
359
360     /**
361      * Sets the value of field 'provenance'.
362      * 
363      * @param provenance the value of field 'provenance'.
364      */
365     public void setProvenance(org.vamsas.objects.core.Provenance provenance)
366     {
367         this._provenance = provenance;
368     } //-- void setProvenance(org.vamsas.objects.core.Provenance) 
369
370     /**
371      * Sets the value of field 'title'.
372      * 
373      * @param title the value of field 'title'.
374      */
375     public void setTitle(java.lang.String title)
376     {
377         this._title = title;
378     } //-- void setTitle(java.lang.String) 
379
380     /**
381      * Method unmarshal
382      * 
383      * 
384      * 
385      * @param reader
386      * @return Tree
387      */
388     public static org.vamsas.objects.core.Tree unmarshal(java.io.Reader reader)
389         throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
390     {
391         return (org.vamsas.objects.core.Tree) Unmarshaller.unmarshal(org.vamsas.objects.core.Tree.class, reader);
392     } //-- org.vamsas.objects.core.Tree unmarshal(java.io.Reader) 
393
394     /**
395      * Method validate
396      * 
397      */
398     public void validate()
399         throws org.exolab.castor.xml.ValidationException
400     {
401         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
402         validator.validate(this);
403     } //-- void validate() 
404
405 }