log validation errors which cause the 'mergeRoots' call to fail.
[vamsas.git] / src / uk / ac / vamsas / objects / core / Tree.java
1 /*
2  * This class was automatically generated with 
3  * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
4  * Schema.
5  * $Id$
6  */
7
8 package uk.ac.vamsas.objects.core;
9
10   //---------------------------------/
11  //- Imported classes and packages -/
12 //---------------------------------/
13
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
16
17 /**
18  * Class Tree.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class Tree extends uk.ac.vamsas.client.Vobject 
23 implements java.io.Serializable
24 {
25
26
27       //--------------------------/
28      //- Class/Member Variables -/
29     //--------------------------/
30
31     /**
32      * Primary Key for vamsas object referencing 
33      */
34     private java.lang.String _id;
35
36     /**
37      * Field _modifiable.
38      */
39     private java.lang.String _modifiable;
40
41     /**
42      * Field _title.
43      */
44     private java.lang.String _title;
45
46     /**
47      * Field _newickList.
48      */
49     private java.util.Vector _newickList;
50
51     /**
52      * Field _propertyList.
53      */
54     private java.util.Vector _propertyList;
55
56     /**
57      * Field _provenance.
58      */
59     private uk.ac.vamsas.objects.core.Provenance _provenance;
60
61
62       //----------------/
63      //- Constructors -/
64     //----------------/
65
66     public Tree() {
67         super();
68         this._newickList = new java.util.Vector();
69         this._propertyList = new java.util.Vector();
70     }
71
72
73       //-----------/
74      //- Methods -/
75     //-----------/
76
77     /**
78      * 
79      * 
80      * @param vNewick
81      * @throws java.lang.IndexOutOfBoundsException if the index
82      * given is outside the bounds of the collection
83      */
84     public void addNewick(
85             final uk.ac.vamsas.objects.core.Newick vNewick)
86     throws java.lang.IndexOutOfBoundsException {
87         this._newickList.addElement(vNewick);
88     }
89
90     /**
91      * 
92      * 
93      * @param index
94      * @param vNewick
95      * @throws java.lang.IndexOutOfBoundsException if the index
96      * given is outside the bounds of the collection
97      */
98     public void addNewick(
99             final int index,
100             final uk.ac.vamsas.objects.core.Newick vNewick)
101     throws java.lang.IndexOutOfBoundsException {
102         this._newickList.add(index, vNewick);
103     }
104
105     /**
106      * 
107      * 
108      * @param vProperty
109      * @throws java.lang.IndexOutOfBoundsException if the index
110      * given is outside the bounds of the collection
111      */
112     public void addProperty(
113             final uk.ac.vamsas.objects.core.Property vProperty)
114     throws java.lang.IndexOutOfBoundsException {
115         this._propertyList.addElement(vProperty);
116     }
117
118     /**
119      * 
120      * 
121      * @param index
122      * @param vProperty
123      * @throws java.lang.IndexOutOfBoundsException if the index
124      * given is outside the bounds of the collection
125      */
126     public void addProperty(
127             final int index,
128             final uk.ac.vamsas.objects.core.Property vProperty)
129     throws java.lang.IndexOutOfBoundsException {
130         this._propertyList.add(index, vProperty);
131     }
132
133     /**
134      * Method enumerateNewick.
135      * 
136      * @return an Enumeration over all
137      * uk.ac.vamsas.objects.core.Newick elements
138      */
139     public java.util.Enumeration enumerateNewick(
140     ) {
141         return this._newickList.elements();
142     }
143
144     /**
145      * Method enumerateProperty.
146      * 
147      * @return an Enumeration over all
148      * uk.ac.vamsas.objects.core.Property elements
149      */
150     public java.util.Enumeration enumerateProperty(
151     ) {
152         return this._propertyList.elements();
153     }
154
155     /**
156      * Overrides the java.lang.Object.equals method.
157      * 
158      * @param obj
159      * @return true if the objects are equal.
160      */
161     public boolean equals(
162             final java.lang.Object obj) {
163         if ( this == obj )
164             return true;
165         
166         if (super.equals(obj)==false)
167             return false;
168         
169         if (obj instanceof Tree) {
170         
171             Tree temp = (Tree)obj;
172             if (this._id != null) {
173                 if (temp._id == null) return false;
174                 else if (!(this._id.equals(temp._id))) 
175                     return false;
176             }
177             else if (temp._id != null)
178                 return false;
179             if (this._modifiable != null) {
180                 if (temp._modifiable == null) return false;
181                 else if (!(this._modifiable.equals(temp._modifiable))) 
182                     return false;
183             }
184             else if (temp._modifiable != null)
185                 return false;
186             if (this._title != null) {
187                 if (temp._title == null) return false;
188                 else if (!(this._title.equals(temp._title))) 
189                     return false;
190             }
191             else if (temp._title != null)
192                 return false;
193             if (this._newickList != null) {
194                 if (temp._newickList == null) return false;
195                 else if (!(this._newickList.equals(temp._newickList))) 
196                     return false;
197             }
198             else if (temp._newickList != null)
199                 return false;
200             if (this._propertyList != null) {
201                 if (temp._propertyList == null) return false;
202                 else if (!(this._propertyList.equals(temp._propertyList))) 
203                     return false;
204             }
205             else if (temp._propertyList != null)
206                 return false;
207             if (this._provenance != null) {
208                 if (temp._provenance == null) return false;
209                 else if (!(this._provenance.equals(temp._provenance))) 
210                     return false;
211             }
212             else if (temp._provenance != null)
213                 return false;
214             return true;
215         }
216         return false;
217     }
218
219     /**
220      * Returns the value of field 'id'. The field 'id' has the
221      * following description: Primary Key for vamsas object
222      * referencing 
223      * 
224      * @return the value of field 'Id'.
225      */
226     public java.lang.String getId(
227     ) {
228         return this._id;
229     }
230
231     /**
232      * Returns the value of field 'modifiable'.
233      * 
234      * @return the value of field 'Modifiable'.
235      */
236     public java.lang.String getModifiable(
237     ) {
238         return this._modifiable;
239     }
240
241     /**
242      * Method getNewick.
243      * 
244      * @param index
245      * @throws java.lang.IndexOutOfBoundsException if the index
246      * given is outside the bounds of the collection
247      * @return the value of the uk.ac.vamsas.objects.core.Newick at
248      * the given index
249      */
250     public uk.ac.vamsas.objects.core.Newick getNewick(
251             final int index)
252     throws java.lang.IndexOutOfBoundsException {
253         // check bounds for index
254         if (index < 0 || index >= this._newickList.size()) {
255             throw new IndexOutOfBoundsException("getNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]");
256         }
257         
258         return (uk.ac.vamsas.objects.core.Newick) _newickList.get(index);
259     }
260
261     /**
262      * Method getNewick.Returns the contents of the collection in
263      * an Array.  <p>Note:  Just in case the collection contents
264      * are changing in another thread, we pass a 0-length Array of
265      * the correct type into the API call.  This way we <i>know</i>
266      * that the Array returned is of exactly the correct length.
267      * 
268      * @return this collection as an Array
269      */
270     public uk.ac.vamsas.objects.core.Newick[] getNewick(
271     ) {
272         uk.ac.vamsas.objects.core.Newick[] array = new uk.ac.vamsas.objects.core.Newick[0];
273         return (uk.ac.vamsas.objects.core.Newick[]) this._newickList.toArray(array);
274     }
275
276     /**
277      * Method getNewickAsReference.Returns a reference to
278      * '_newickList'. No type checking is performed on any
279      * modifications to the Vector.
280      * 
281      * @return a reference to the Vector backing this class
282      */
283     public java.util.Vector getNewickAsReference(
284     ) {
285         return this._newickList;
286     }
287
288     /**
289      * Method getNewickCount.
290      * 
291      * @return the size of this collection
292      */
293     public int getNewickCount(
294     ) {
295         return this._newickList.size();
296     }
297
298     /**
299      * Method getProperty.
300      * 
301      * @param index
302      * @throws java.lang.IndexOutOfBoundsException if the index
303      * given is outside the bounds of the collection
304      * @return the value of the uk.ac.vamsas.objects.core.Property
305      * at the given index
306      */
307     public uk.ac.vamsas.objects.core.Property getProperty(
308             final int index)
309     throws java.lang.IndexOutOfBoundsException {
310         // check bounds for index
311         if (index < 0 || index >= this._propertyList.size()) {
312             throw new IndexOutOfBoundsException("getProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
313         }
314         
315         return (uk.ac.vamsas.objects.core.Property) _propertyList.get(index);
316     }
317
318     /**
319      * Method getProperty.Returns the contents of the collection in
320      * an Array.  <p>Note:  Just in case the collection contents
321      * are changing in another thread, we pass a 0-length Array of
322      * the correct type into the API call.  This way we <i>know</i>
323      * that the Array returned is of exactly the correct length.
324      * 
325      * @return this collection as an Array
326      */
327     public uk.ac.vamsas.objects.core.Property[] getProperty(
328     ) {
329         uk.ac.vamsas.objects.core.Property[] array = new uk.ac.vamsas.objects.core.Property[0];
330         return (uk.ac.vamsas.objects.core.Property[]) this._propertyList.toArray(array);
331     }
332
333     /**
334      * Method getPropertyAsReference.Returns a reference to
335      * '_propertyList'. No type checking is performed on any
336      * modifications to the Vector.
337      * 
338      * @return a reference to the Vector backing this class
339      */
340     public java.util.Vector getPropertyAsReference(
341     ) {
342         return this._propertyList;
343     }
344
345     /**
346      * Method getPropertyCount.
347      * 
348      * @return the size of this collection
349      */
350     public int getPropertyCount(
351     ) {
352         return this._propertyList.size();
353     }
354
355     /**
356      * Returns the value of field 'provenance'.
357      * 
358      * @return the value of field 'Provenance'.
359      */
360     public uk.ac.vamsas.objects.core.Provenance getProvenance(
361     ) {
362         return this._provenance;
363     }
364
365     /**
366      * Returns the value of field 'title'.
367      * 
368      * @return the value of field 'Title'.
369      */
370     public java.lang.String getTitle(
371     ) {
372         return this._title;
373     }
374
375     /**
376      * Overrides the java.lang.Object.hashCode method.
377      * <p>
378      * The following steps came from <b>Effective Java Programming
379      * Language Guide</b> by Joshua Bloch, Chapter 3
380      * 
381      * @return a hash code value for the object.
382      */
383     public int hashCode(
384     ) {
385         int result = super.hashCode();
386         
387         long tmp;
388         if (_id != null) {
389            result = 37 * result + _id.hashCode();
390         }
391         if (_modifiable != null) {
392            result = 37 * result + _modifiable.hashCode();
393         }
394         if (_title != null) {
395            result = 37 * result + _title.hashCode();
396         }
397         if (_newickList != null) {
398            result = 37 * result + _newickList.hashCode();
399         }
400         if (_propertyList != null) {
401            result = 37 * result + _propertyList.hashCode();
402         }
403         if (_provenance != null) {
404            result = 37 * result + _provenance.hashCode();
405         }
406         
407         return result;
408     }
409
410     /**
411      * Method isValid.
412      * 
413      * @return true if this object is valid according to the schema
414      */
415     public boolean isValid(
416     ) {
417         try {
418             validate();
419         } catch (org.exolab.castor.xml.ValidationException vex) {
420             return false;
421         }
422         return true;
423     }
424
425     /**
426      * 
427      * 
428      * @param out
429      * @throws org.exolab.castor.xml.MarshalException if object is
430      * null or if any SAXException is thrown during marshaling
431      * @throws org.exolab.castor.xml.ValidationException if this
432      * object is an invalid instance according to the schema
433      */
434     public void marshal(
435             final java.io.Writer out)
436     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
437         Marshaller.marshal(this, out);
438     }
439
440     /**
441      * 
442      * 
443      * @param handler
444      * @throws java.io.IOException if an IOException occurs during
445      * marshaling
446      * @throws org.exolab.castor.xml.ValidationException if this
447      * object is an invalid instance according to the schema
448      * @throws org.exolab.castor.xml.MarshalException if object is
449      * null or if any SAXException is thrown during marshaling
450      */
451     public void marshal(
452             final org.xml.sax.ContentHandler handler)
453     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
454         Marshaller.marshal(this, handler);
455     }
456
457     /**
458      */
459     public void removeAllNewick(
460     ) {
461         this._newickList.clear();
462     }
463
464     /**
465      */
466     public void removeAllProperty(
467     ) {
468         this._propertyList.clear();
469     }
470
471     /**
472      * Method removeNewick.
473      * 
474      * @param vNewick
475      * @return true if the object was removed from the collection.
476      */
477     public boolean removeNewick(
478             final uk.ac.vamsas.objects.core.Newick vNewick) {
479         boolean removed = _newickList.remove(vNewick);
480         return removed;
481     }
482
483     /**
484      * Method removeNewickAt.
485      * 
486      * @param index
487      * @return the element removed from the collection
488      */
489     public uk.ac.vamsas.objects.core.Newick removeNewickAt(
490             final int index) {
491         java.lang.Object obj = this._newickList.remove(index);
492         return (uk.ac.vamsas.objects.core.Newick) obj;
493     }
494
495     /**
496      * Method removeProperty.
497      * 
498      * @param vProperty
499      * @return true if the object was removed from the collection.
500      */
501     public boolean removeProperty(
502             final uk.ac.vamsas.objects.core.Property vProperty) {
503         boolean removed = _propertyList.remove(vProperty);
504         return removed;
505     }
506
507     /**
508      * Method removePropertyAt.
509      * 
510      * @param index
511      * @return the element removed from the collection
512      */
513     public uk.ac.vamsas.objects.core.Property removePropertyAt(
514             final int index) {
515         java.lang.Object obj = this._propertyList.remove(index);
516         return (uk.ac.vamsas.objects.core.Property) obj;
517     }
518
519     /**
520      * Sets the value of field 'id'. The field 'id' has the
521      * following description: Primary Key for vamsas object
522      * referencing 
523      * 
524      * @param id the value of field 'id'.
525      */
526     public void setId(
527             final java.lang.String id) {
528         this._id = id;
529     }
530
531     /**
532      * Sets the value of field 'modifiable'.
533      * 
534      * @param modifiable the value of field 'modifiable'.
535      */
536     public void setModifiable(
537             final java.lang.String modifiable) {
538         this._modifiable = modifiable;
539     }
540
541     /**
542      * 
543      * 
544      * @param index
545      * @param vNewick
546      * @throws java.lang.IndexOutOfBoundsException if the index
547      * given is outside the bounds of the collection
548      */
549     public void setNewick(
550             final int index,
551             final uk.ac.vamsas.objects.core.Newick vNewick)
552     throws java.lang.IndexOutOfBoundsException {
553         // check bounds for index
554         if (index < 0 || index >= this._newickList.size()) {
555             throw new IndexOutOfBoundsException("setNewick: Index value '" + index + "' not in range [0.." + (this._newickList.size() - 1) + "]");
556         }
557         
558         this._newickList.set(index, vNewick);
559     }
560
561     /**
562      * 
563      * 
564      * @param vNewickArray
565      */
566     public void setNewick(
567             final uk.ac.vamsas.objects.core.Newick[] vNewickArray) {
568         //-- copy array
569         _newickList.clear();
570         
571         for (int i = 0; i < vNewickArray.length; i++) {
572                 this._newickList.add(vNewickArray[i]);
573         }
574     }
575
576     /**
577      * Sets the value of '_newickList' by copying the given Vector.
578      * All elements will be checked for type safety.
579      * 
580      * @param vNewickList the Vector to copy.
581      */
582     public void setNewick(
583             final java.util.Vector vNewickList) {
584         // copy vector
585         this._newickList.clear();
586         
587         this._newickList.addAll(vNewickList);
588     }
589
590     /**
591      * Sets the value of '_newickList' by setting it to the given
592      * Vector. No type checking is performed.
593      * @deprecated
594      * 
595      * @param newickVector the Vector to set.
596      */
597     public void setNewickAsReference(
598             final java.util.Vector newickVector) {
599         this._newickList = newickVector;
600     }
601
602     /**
603      * 
604      * 
605      * @param index
606      * @param vProperty
607      * @throws java.lang.IndexOutOfBoundsException if the index
608      * given is outside the bounds of the collection
609      */
610     public void setProperty(
611             final int index,
612             final uk.ac.vamsas.objects.core.Property vProperty)
613     throws java.lang.IndexOutOfBoundsException {
614         // check bounds for index
615         if (index < 0 || index >= this._propertyList.size()) {
616             throw new IndexOutOfBoundsException("setProperty: Index value '" + index + "' not in range [0.." + (this._propertyList.size() - 1) + "]");
617         }
618         
619         this._propertyList.set(index, vProperty);
620     }
621
622     /**
623      * 
624      * 
625      * @param vPropertyArray
626      */
627     public void setProperty(
628             final uk.ac.vamsas.objects.core.Property[] vPropertyArray) {
629         //-- copy array
630         _propertyList.clear();
631         
632         for (int i = 0; i < vPropertyArray.length; i++) {
633                 this._propertyList.add(vPropertyArray[i]);
634         }
635     }
636
637     /**
638      * Sets the value of '_propertyList' by copying the given
639      * Vector. All elements will be checked for type safety.
640      * 
641      * @param vPropertyList the Vector to copy.
642      */
643     public void setProperty(
644             final java.util.Vector vPropertyList) {
645         // copy vector
646         this._propertyList.clear();
647         
648         this._propertyList.addAll(vPropertyList);
649     }
650
651     /**
652      * Sets the value of '_propertyList' by setting it to the given
653      * Vector. No type checking is performed.
654      * @deprecated
655      * 
656      * @param propertyVector the Vector to set.
657      */
658     public void setPropertyAsReference(
659             final java.util.Vector propertyVector) {
660         this._propertyList = propertyVector;
661     }
662
663     /**
664      * Sets the value of field 'provenance'.
665      * 
666      * @param provenance the value of field 'provenance'.
667      */
668     public void setProvenance(
669             final uk.ac.vamsas.objects.core.Provenance provenance) {
670         this._provenance = provenance;
671     }
672
673     /**
674      * Sets the value of field 'title'.
675      * 
676      * @param title the value of field 'title'.
677      */
678     public void setTitle(
679             final java.lang.String title) {
680         this._title = title;
681     }
682
683     /**
684      * Method unmarshal.
685      * 
686      * @param reader
687      * @throws org.exolab.castor.xml.MarshalException if object is
688      * null or if any SAXException is thrown during marshaling
689      * @throws org.exolab.castor.xml.ValidationException if this
690      * object is an invalid instance according to the schema
691      * @return the unmarshaled uk.ac.vamsas.objects.core.Tree
692      */
693     public static uk.ac.vamsas.objects.core.Tree unmarshal(
694             final java.io.Reader reader)
695     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
696         return (uk.ac.vamsas.objects.core.Tree) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Tree.class, reader);
697     }
698
699     /**
700      * 
701      * 
702      * @throws org.exolab.castor.xml.ValidationException if this
703      * object is an invalid instance according to the schema
704      */
705     public void validate(
706     )
707     throws org.exolab.castor.xml.ValidationException {
708         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
709         validator.validate(this);
710     }
711
712 }