2 * This class was automatically generated with
3 * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
8 package uk.ac.vamsas.objects.core;
10 //---------------------------------/
11 //- Imported classes and packages -/
12 //---------------------------------/
14 import org.exolab.castor.xml.Marshaller;
15 import org.exolab.castor.xml.Unmarshaller;
20 * @version $Revision$ $Date$
22 public class Provenance extends uk.ac.vamsas.client.Vobject
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
34 private java.util.Vector _entryList;
43 this._entryList = new java.util.Vector();
55 * @throws java.lang.IndexOutOfBoundsException if the index
56 * given is outside the bounds of the collection
59 final uk.ac.vamsas.objects.core.Entry vEntry)
60 throws java.lang.IndexOutOfBoundsException {
61 this._entryList.addElement(vEntry);
69 * @throws java.lang.IndexOutOfBoundsException if the index
70 * given is outside the bounds of the collection
74 final uk.ac.vamsas.objects.core.Entry vEntry)
75 throws java.lang.IndexOutOfBoundsException {
76 this._entryList.add(index, vEntry);
80 * Method enumerateEntry.
82 * @return an Enumeration over all
83 * uk.ac.vamsas.objects.core.Entry elements
85 public java.util.Enumeration enumerateEntry(
87 return this._entryList.elements();
91 * Overrides the java.lang.Object.equals method.
94 * @return true if the objects are equal.
96 public boolean equals(
97 final java.lang.Object obj) {
101 if (super.equals(obj)==false)
104 if (obj instanceof Provenance) {
106 Provenance temp = (Provenance)obj;
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); };
120 if (!this._entryList.equals(temp._entryList)) {
121 org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList);
122 org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList);
125 org.castor.util.CycleBreaker.releaseCycleHandle(this._entryList);
126 org.castor.util.CycleBreaker.releaseCycleHandle(temp._entryList);
129 } else if (temp._entryList != null)
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
145 public uk.ac.vamsas.objects.core.Entry getEntry(
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) + "]");
153 return (uk.ac.vamsas.objects.core.Entry) _entryList.get(index);
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.
163 * @return this collection as an Array
165 public uk.ac.vamsas.objects.core.Entry[] getEntry(
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);
172 * Method getEntryAsReference.Returns a reference to
173 * '_entryList'. No type checking is performed on any
174 * modifications to the Vector.
176 * @return a reference to the Vector backing this class
178 public java.util.Vector getEntryAsReference(
180 return this._entryList;
184 * Method getEntryCount.
186 * @return the size of this collection
188 public int getEntryCount(
190 return this._entryList.size();
194 * Overrides the java.lang.Object.hashCode method.
196 * The following steps came from <b>Effective Java Programming
197 * Language Guide</b> by Joshua Bloch, Chapter 3
199 * @return a hash code value for the object.
203 int result = super.hashCode();
206 if (_entryList != null
207 && !org.castor.util.CycleBreaker.startingToCycle(_entryList)) {
208 result = 37 * result + _entryList.hashCode();
209 org.castor.util.CycleBreaker.releaseCycleHandle(_entryList);
218 * @return true if this object is valid according to the schema
220 public boolean isValid(
224 } catch (org.exolab.castor.xml.ValidationException vex) {
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
240 final java.io.Writer out)
241 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
242 Marshaller.marshal(this, out);
249 * @throws java.io.IOException if an IOException occurs during
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
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);
264 public void removeAllEntry(
266 this._entryList.clear();
270 * Method removeEntry.
273 * @return true if the object was removed from the collection.
275 public boolean removeEntry(
276 final uk.ac.vamsas.objects.core.Entry vEntry) {
277 boolean removed = _entryList.remove(vEntry);
282 * Method removeEntryAt.
285 * @return the element removed from the collection
287 public uk.ac.vamsas.objects.core.Entry removeEntryAt(
289 java.lang.Object obj = this._entryList.remove(index);
290 return (uk.ac.vamsas.objects.core.Entry) obj;
298 * @throws java.lang.IndexOutOfBoundsException if the index
299 * given is outside the bounds of the collection
301 public void setEntry(
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) + "]");
310 this._entryList.set(index, vEntry);
318 public void setEntry(
319 final uk.ac.vamsas.objects.core.Entry[] vEntryArray) {
323 for (int i = 0; i < vEntryArray.length; i++) {
324 this._entryList.add(vEntryArray[i]);
329 * Sets the value of '_entryList' by copying the given Vector.
330 * All elements will be checked for type safety.
332 * @param vEntryList the Vector to copy.
334 public void setEntry(
335 final java.util.Vector vEntryList) {
337 this._entryList.clear();
339 this._entryList.addAll(vEntryList);
343 * Sets the value of '_entryList' by setting it to the given
344 * Vector. No type checking is performed.
347 * @param entryVector the Vector to set.
349 public void setEntryAsReference(
350 final java.util.Vector entryVector) {
351 this._entryList = entryVector;
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
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);
373 * @throws org.exolab.castor.xml.ValidationException if this
374 * object is an invalid instance according to the schema
376 public void validate(
378 throws org.exolab.castor.xml.ValidationException {
379 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
380 validator.validate(this);