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