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