cyclic IDREF patched castor-1.1.1 source
[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             if (this._entryList != null) {
108                 if (temp._entryList == null) return false;
109                 else if (!(this._entryList.equals(temp._entryList))) 
110                     return false;
111             }
112             else if (temp._entryList != null)
113                 return false;
114             return true;
115         }
116         return false;
117     }
118
119     /**
120      * Method getEntry.
121      * 
122      * @param index
123      * @throws java.lang.IndexOutOfBoundsException if the index
124      * given is outside the bounds of the collection
125      * @return the value of the uk.ac.vamsas.objects.core.Entry at
126      * the given index
127      */
128     public uk.ac.vamsas.objects.core.Entry getEntry(
129             final int index)
130     throws java.lang.IndexOutOfBoundsException {
131         // check bounds for index
132         if (index < 0 || index >= this._entryList.size()) {
133             throw new IndexOutOfBoundsException("getEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]");
134         }
135         
136         return (uk.ac.vamsas.objects.core.Entry) _entryList.get(index);
137     }
138
139     /**
140      * Method getEntry.Returns the contents of the collection in an
141      * Array.  <p>Note:  Just in case the collection contents are
142      * changing in another thread, we pass a 0-length Array of the
143      * correct type into the API call.  This way we <i>know</i>
144      * that the Array returned is of exactly the correct length.
145      * 
146      * @return this collection as an Array
147      */
148     public uk.ac.vamsas.objects.core.Entry[] getEntry(
149     ) {
150         uk.ac.vamsas.objects.core.Entry[] array = new uk.ac.vamsas.objects.core.Entry[0];
151         return (uk.ac.vamsas.objects.core.Entry[]) this._entryList.toArray(array);
152     }
153
154     /**
155      * Method getEntryAsReference.Returns a reference to
156      * '_entryList'. No type checking is performed on any
157      * modifications to the Vector.
158      * 
159      * @return a reference to the Vector backing this class
160      */
161     public java.util.Vector getEntryAsReference(
162     ) {
163         return this._entryList;
164     }
165
166     /**
167      * Method getEntryCount.
168      * 
169      * @return the size of this collection
170      */
171     public int getEntryCount(
172     ) {
173         return this._entryList.size();
174     }
175
176     /**
177      * Overrides the java.lang.Object.hashCode method.
178      * <p>
179      * The following steps came from <b>Effective Java Programming
180      * Language Guide</b> by Joshua Bloch, Chapter 3
181      * 
182      * @return a hash code value for the object.
183      */
184     public int hashCode(
185     ) {
186         int result = super.hashCode();
187         
188         long tmp;
189         if (_entryList != null) {
190            result = 37 * result + _entryList.hashCode();
191         }
192         
193         return result;
194     }
195
196     /**
197      * Method isValid.
198      * 
199      * @return true if this object is valid according to the schema
200      */
201     public boolean isValid(
202     ) {
203         try {
204             validate();
205         } catch (org.exolab.castor.xml.ValidationException vex) {
206             return false;
207         }
208         return true;
209     }
210
211     /**
212      * 
213      * 
214      * @param out
215      * @throws org.exolab.castor.xml.MarshalException if object is
216      * null or if any SAXException is thrown during marshaling
217      * @throws org.exolab.castor.xml.ValidationException if this
218      * object is an invalid instance according to the schema
219      */
220     public void marshal(
221             final java.io.Writer out)
222     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
223         Marshaller.marshal(this, out);
224     }
225
226     /**
227      * 
228      * 
229      * @param handler
230      * @throws java.io.IOException if an IOException occurs during
231      * marshaling
232      * @throws org.exolab.castor.xml.ValidationException if this
233      * object is an invalid instance according to the schema
234      * @throws org.exolab.castor.xml.MarshalException if object is
235      * null or if any SAXException is thrown during marshaling
236      */
237     public void marshal(
238             final org.xml.sax.ContentHandler handler)
239     throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
240         Marshaller.marshal(this, handler);
241     }
242
243     /**
244      */
245     public void removeAllEntry(
246     ) {
247         this._entryList.clear();
248     }
249
250     /**
251      * Method removeEntry.
252      * 
253      * @param vEntry
254      * @return true if the object was removed from the collection.
255      */
256     public boolean removeEntry(
257             final uk.ac.vamsas.objects.core.Entry vEntry) {
258         boolean removed = _entryList.remove(vEntry);
259         return removed;
260     }
261
262     /**
263      * Method removeEntryAt.
264      * 
265      * @param index
266      * @return the element removed from the collection
267      */
268     public uk.ac.vamsas.objects.core.Entry removeEntryAt(
269             final int index) {
270         java.lang.Object obj = this._entryList.remove(index);
271         return (uk.ac.vamsas.objects.core.Entry) obj;
272     }
273
274     /**
275      * 
276      * 
277      * @param index
278      * @param vEntry
279      * @throws java.lang.IndexOutOfBoundsException if the index
280      * given is outside the bounds of the collection
281      */
282     public void setEntry(
283             final int index,
284             final uk.ac.vamsas.objects.core.Entry vEntry)
285     throws java.lang.IndexOutOfBoundsException {
286         // check bounds for index
287         if (index < 0 || index >= this._entryList.size()) {
288             throw new IndexOutOfBoundsException("setEntry: Index value '" + index + "' not in range [0.." + (this._entryList.size() - 1) + "]");
289         }
290         
291         this._entryList.set(index, vEntry);
292     }
293
294     /**
295      * 
296      * 
297      * @param vEntryArray
298      */
299     public void setEntry(
300             final uk.ac.vamsas.objects.core.Entry[] vEntryArray) {
301         //-- copy array
302         _entryList.clear();
303         
304         for (int i = 0; i < vEntryArray.length; i++) {
305                 this._entryList.add(vEntryArray[i]);
306         }
307     }
308
309     /**
310      * Sets the value of '_entryList' by copying the given Vector.
311      * All elements will be checked for type safety.
312      * 
313      * @param vEntryList the Vector to copy.
314      */
315     public void setEntry(
316             final java.util.Vector vEntryList) {
317         // copy vector
318         this._entryList.clear();
319         
320         this._entryList.addAll(vEntryList);
321     }
322
323     /**
324      * Sets the value of '_entryList' by setting it to the given
325      * Vector. No type checking is performed.
326      * @deprecated
327      * 
328      * @param entryVector the Vector to set.
329      */
330     public void setEntryAsReference(
331             final java.util.Vector entryVector) {
332         this._entryList = entryVector;
333     }
334
335     /**
336      * Method unmarshal.
337      * 
338      * @param reader
339      * @throws org.exolab.castor.xml.MarshalException if object is
340      * null or if any SAXException is thrown during marshaling
341      * @throws org.exolab.castor.xml.ValidationException if this
342      * object is an invalid instance according to the schema
343      * @return the unmarshaled uk.ac.vamsas.objects.core.Provenance
344      */
345     public static uk.ac.vamsas.objects.core.Provenance unmarshal(
346             final java.io.Reader reader)
347     throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
348         return (uk.ac.vamsas.objects.core.Provenance) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Provenance.class, reader);
349     }
350
351     /**
352      * 
353      * 
354      * @throws org.exolab.castor.xml.ValidationException if this
355      * object is an invalid instance according to the schema
356      */
357     public void validate(
358     )
359     throws org.exolab.castor.xml.ValidationException {
360         org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
361         validator.validate(this);
362     }
363
364 }