12dc17b7d5cc7b413a6630fab86e0aa1b3908dbc
[vamsas.git] / src / uk / ac / vamsas / objects / core / Provenance.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 Provenance.
19  * 
20  * @version $Revision$ $Date$
21  */
22 public class Provenance extends uk.ac.vamsas.client.Vobject 
23 implements java.io.Serializable
24 {
25
26
27       //--------------------------/
28      //- Class/Member Variables -/
29     //--------------------------/
30
31     /**
32      * Field _entryList.
33      */
34     private java.util.Vector _entryList;
35
36
37       //----------------/
38      //- Constructors -/
39     //----------------/
40
41     public Provenance() {
42         super();
43         this._entryList = new java.util.Vector();
44     }
45
46
47       //-----------/
48      //- Methods -/
49     //-----------/
50
51     /**
52      * 
53      * 
54      * @param vEntry
55      * @throws java.lang.IndexOutOfBoundsException if the index
56      * given is outside the bounds of the collection
57      */
58     public void addEntry(
59             final uk.ac.vamsas.objects.core.Entry vEntry)
60     throws java.lang.IndexOutOfBoundsException {
61         this._entryList.addElement(vEntry);
62     }
63
64     /**
65      * 
66      * 
67      * @param index
68      * @param vEntry
69      * @throws java.lang.IndexOutOfBoundsException if the index
70      * given is outside the bounds of the collection
71      */
72     public void addEntry(
73             final int index,
74             final uk.ac.vamsas.objects.core.Entry vEntry)
75     throws java.lang.IndexOutOfBoundsException {
76         this._entryList.add(index, vEntry);
77     }
78
79     /**
80      * Method enumerateEntry.
81      * 
82      * @return an Enumeration over all
83      * uk.ac.vamsas.objects.core.Entry elements
84      */
85     public java.util.Enumeration enumerateEntry(
86     ) {
87         return this._entryList.elements();
88     }
89
90     /**
91      * Overrides the java.lang.Object.equals method.
92      * 
93      * @param obj
94      * @return true if the objects are equal.
95      */
96     public boolean equals(
97             final java.lang.Object obj) {
98         if ( this == obj )
99             return true;
100         
101         if (super.equals(obj)==false)
102             return false;
103         
104         if (obj instanceof Provenance) {
105         
106             Provenance temp = (Provenance)obj;
107             boolean thcycle;
108             boolean tmcycle;
109             if (this._entryList != null) {
110                 if (temp._entryList == null) return false;
111                 if (this._entryList != temp._entryList) {
112                     thcycle=org.castor.util.CycleBreaker.startingToCycle(this._entryList);
113                     tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._entryList);
114                     if (thcycle!=tmcycle) {
115                         if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList); };
116                         if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList); };
117                         return false;
118                     }
119                     if (!thcycle) {
120                         if (!this._entryList.equals(temp._entryList)) {
121                             org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList);
122                             org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList);
123                             return false;
124                         }
125                         org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList);
126                         org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList);
127                     }
128                 }
129             } else if (temp._entryList != null)
130                 return false;
131             return true;
132         }
133         return false;
134     }
135
136     /**
137      * Method getEntry.
138      * 
139      * @param index
140      * @throws java.lang.IndexOutOfBoundsException if the index
141      * given is outside the bounds of the collection
142      * @return the value of the uk.ac.vamsas.objects.core.Entry at
143      * the given index
144      */
145     public uk.ac.vamsas.objects.core.Entry getEntry(
146             final int index)
147     throws java.lang.IndexOutOfBoundsException {
148         // check bounds for index
149         if (index < 0 || index >= this._entryList.size()) {
150             throw new IndexOutOfBoundsException("getEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]");
151         }
152         
153         return (uk.ac.vamsas.objects.core.Entry) _entryList.get(index);
154     }
155
156     /**
157      * Method getEntry.Returns the contents of the collection in an
158      * Array.  <p>Note:  Just in case the collection contents are
159      * changing in another thread, we pass a 0-length Array of the
160      * correct type into the API call.  This way we <i>know</i>
161      * that the Array returned is of exactly the correct length.
162      * 
163      * @return this collection as an Array
164      */
165     public uk.ac.vamsas.objects.core.Entry[] getEntry(
166     ) {
167         uk.ac.vamsas.objects.core.Entry[] array = new uk.ac.vamsas.objects.core.Entry[0];
168         return (uk.ac.vamsas.objects.core.Entry[]) this._entryList.toArray(array);
169     }
170
171     /**
172      * Method getEntryAsReference.Returns a reference to
173      * '_entryList'. No type checking is performed on any
174      * modifications to the Vector.
175      * 
176      * @return a reference to the Vector backing this class
177      */
178     public java.util.Vector getEntryAsReference(
179     ) {
180         return this._entryList;
181     }
182
183     /**
184      * Method getEntryCount.
185      * 
186      * @return the size of this collection
187      */
188     public int getEntryCount(
189     ) {
190         return this._entryList.size();
191     }
192
193     /**
194      * Overrides the java.lang.Object.hashCode method.
195      * <p>
196      * The following steps came from <b>Effective Java Programming
197      * Language Guide</b> by Joshua Bloch, Chapter 3
198      * 
199      * @return a hash code value for the object.
200      */
201     public int hashCode(
202     ) {
203         int result = super.hashCode();
204         
205         long tmp;
206         if (_entryList != null
207             && !org.castor.util.CycleBreaker.startingToCycle(_entryList)) {
208            result = 37 * result + _entryList.hashCode();
209            org.castor.util.CycleBreaker.releaseCycleHandle(_entryList);
210         }
211         
212         return result;
213     }
214
215     /**
216      * Method isValid.
217      * 
218      * @return true if this object is valid according to the schema
219      */
220     public boolean isValid(
221     ) {
222         try {
223             validate();
224         } catch (org.exolab.castor.xml.ValidationException vex) {
225             return false;
226         }
227         return true;
228     }
229
230     /**
231      * 
232      * 
233      * @param out
234      * @throws org.exolab.castor.xml.MarshalException if object is
235      * null or if any SAXException is thrown during marshaling
236      * @throws org.exolab.castor.xml.ValidationException if this
237      * object is an invalid instance according to the schema
238      */
239     public void marshal(
240             final java.io.Writer out)
241     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
242         Marshaller.marshal(this, out);
243     }
244
245     /**
246      * 
247      * 
248      * @param handler
249      * @throws java.io.IOException if an IOException occurs during
250      * marshaling
251      * @throws org.exolab.castor.xml.ValidationException if this
252      * object is an invalid instance according to the schema
253      * @throws org.exolab.castor.xml.MarshalException if object is
254      * null or if any SAXException is thrown during marshaling
255      */
256     public void marshal(
257             final org.xml.sax.ContentHandler handler)
258     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
259         Marshaller.marshal(this, handler);
260     }
261
262     /**
263      */
264     public void removeAllEntry(
265     ) {
266         this._entryList.clear();
267     }
268
269     /**
270      * Method removeEntry.
271      * 
272      * @param vEntry
273      * @return true if the object was removed from the collection.
274      */
275     public boolean removeEntry(
276             final uk.ac.vamsas.objects.core.Entry vEntry) {
277         boolean removed = _entryList.remove(vEntry);
278         return removed;
279     }
280
281     /**
282      * Method removeEntryAt.
283      * 
284      * @param index
285      * @return the element removed from the collection
286      */
287     public uk.ac.vamsas.objects.core.Entry removeEntryAt(
288             final int index) {
289         java.lang.Object obj = this._entryList.remove(index);
290         return (uk.ac.vamsas.objects.core.Entry) obj;
291     }
292
293     /**
294      * 
295      * 
296      * @param index
297      * @param vEntry
298      * @throws java.lang.IndexOutOfBoundsException if the index
299      * given is outside the bounds of the collection
300      */
301     public void setEntry(
302             final int index,
303             final uk.ac.vamsas.objects.core.Entry vEntry)
304     throws java.lang.IndexOutOfBoundsException {
305         // check bounds for index
306         if (index < 0 || index >= this._entryList.size()) {
307             throw new IndexOutOfBoundsException("setEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]");
308         }
309         
310         this._entryList.set(index, vEntry);
311     }
312
313     /**
314      * 
315      * 
316      * @param vEntryArray
317      */
318     public void setEntry(
319             final uk.ac.vamsas.objects.core.Entry[] vEntryArray) {
320         //-- copy array
321         _entryList.clear();
322         
323         for (int i = 0; i < vEntryArray.length; i++) {
324                 this._entryList.add(vEntryArray[i]);
325         }
326     }
327
328     /**
329      * Sets the value of '_entryList' by copying the given Vector.
330      * All elements will be checked for type safety.
331      * 
332      * @param vEntryList the Vector to copy.
333      */
334     public void setEntry(
335             final java.util.Vector vEntryList) {
336         // copy vector
337         this._entryList.clear();
338         
339         this._entryList.addAll(vEntryList);
340     }
341
342     /**
343      * Sets the value of '_entryList' by setting it to the given
344      * Vector. No type checking is performed.
345      * @deprecated
346      * 
347      * @param entryVector the Vector to set.
348      */
349     public void setEntryAsReference(
350             final java.util.Vector entryVector) {
351         this._entryList = entryVector;
352     }
353
354     /**
355      * Method unmarshal.
356      * 
357      * @param reader
358      * @throws org.exolab.castor.xml.MarshalException if object is
359      * null or if any SAXException is thrown during marshaling
360      * @throws org.exolab.castor.xml.ValidationException if this
361      * object is an invalid instance according to the schema
362      * @return the unmarshaled uk.ac.vamsas.objects.core.Provenance
363      */
364     public static uk.ac.vamsas.objects.core.Provenance unmarshal(
365             final java.io.Reader reader)
366     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
367         return (uk.ac.vamsas.objects.core.Provenance) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Provenance.class, reader);
368     }
369
370     /**
371      * 
372      * 
373      * @throws org.exolab.castor.xml.ValidationException if this
374      * object is an invalid instance according to the schema
375      */
376     public void validate(
377     )
378     throws org.exolab.castor.xml.ValidationException {
379         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
380         validator.validate(this);
381     }
382
383 }