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;
18 * Class DataSetAnnotations.
20 * @version $Revision$ $Date$
22 public class DataSetAnnotations extends uk.ac.vamsas.objects.core.RangeAnnotation
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * annotation is associated with a
33 * particular dataset sequence
35 private java.util.Vector _seqRef;
40 private uk.ac.vamsas.objects.core.Provenance _provenance;
47 public DataSetAnnotations() {
49 this._seqRef = new java.util.Vector();
61 * @throws java.lang.IndexOutOfBoundsException if the index
62 * given is outside the bounds of the collection
64 public void addSeqRef(
65 final java.lang.Object vSeqRef)
66 throws java.lang.IndexOutOfBoundsException {
67 this._seqRef.addElement(vSeqRef);
75 * @throws java.lang.IndexOutOfBoundsException if the index
76 * given is outside the bounds of the collection
78 public void addSeqRef(
80 final java.lang.Object vSeqRef)
81 throws java.lang.IndexOutOfBoundsException {
82 this._seqRef.add(index, vSeqRef);
86 * Method enumerateSeqRef.
88 * @return an Enumeration over all java.lang.Object elements
90 public java.util.Enumeration enumerateSeqRef(
92 return this._seqRef.elements();
96 * Overrides the java.lang.Object.equals method.
99 * @return true if the objects are equal.
101 public boolean equals(
102 final java.lang.Object obj) {
106 if (super.equals(obj)==false)
109 if (obj instanceof DataSetAnnotations) {
111 DataSetAnnotations temp = (DataSetAnnotations)obj;
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); };
125 if (!this._seqRef.equals(temp._seqRef)) {
126 org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef);
127 org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef);
130 org.castor.util.CycleBreaker.releaseCycleHandle(this._seqRef);
131 org.castor.util.CycleBreaker.releaseCycleHandle(temp._seqRef);
134 } else if (temp._seqRef != null)
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); };
147 if (!this._provenance.equals(temp._provenance)) {
148 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
149 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
152 org.castor.util.CycleBreaker.releaseCycleHandle(this._provenance);
153 org.castor.util.CycleBreaker.releaseCycleHandle(temp._provenance);
156 } else if (temp._provenance != null)
164 * Returns the value of field 'provenance'.
166 * @return the value of field 'Provenance'.
168 public uk.ac.vamsas.objects.core.Provenance getProvenance(
170 return this._provenance;
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
181 public java.lang.Object getSeqRef(
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) + "]");
189 return _seqRef.get(index);
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.
199 * @return this collection as an Array
201 public java.lang.Object[] getSeqRef(
203 java.lang.Object[] array = new java.lang.Object[0];
204 return (java.lang.Object[]) this._seqRef.toArray(array);
208 * Method getSeqRefAsReference.Returns a reference to
209 * '_seqRef'. No type checking is performed on any
210 * modifications to the Vector.
212 * @return a reference to the Vector backing this class
214 public java.util.Vector getSeqRefAsReference(
220 * Method getSeqRefCount.
222 * @return the size of this collection
224 public int getSeqRefCount(
226 return this._seqRef.size();
230 * Overrides the java.lang.Object.hashCode method.
232 * The following steps came from <b>Effective Java Programming
233 * Language Guide</b> by Joshua Bloch, Chapter 3
235 * @return a hash code value for the object.
239 int result = super.hashCode();
243 && !org.castor.util.CycleBreaker.startingToCycle(_seqRef)) {
244 result = 37 * result + _seqRef.hashCode();
245 org.castor.util.CycleBreaker.releaseCycleHandle(_seqRef);
247 if (_provenance != null
248 && !org.castor.util.CycleBreaker.startingToCycle(_provenance)) {
249 result = 37 * result + _provenance.hashCode();
250 org.castor.util.CycleBreaker.releaseCycleHandle(_provenance);
259 * @return true if this object is valid according to the schema
261 public boolean isValid(
265 } catch (org.exolab.castor.xml.ValidationException vex) {
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
281 final java.io.Writer out)
282 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
283 Marshaller.marshal(this, out);
290 * @throws java.io.IOException if an IOException occurs during
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
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);
305 public void removeAllSeqRef(
307 this._seqRef.clear();
311 * Method removeSeqRef.
314 * @return true if the object was removed from the collection.
316 public boolean removeSeqRef(
317 final java.lang.Object vSeqRef) {
318 boolean removed = _seqRef.remove(vSeqRef);
323 * Method removeSeqRefAt.
326 * @return the element removed from the collection
328 public java.lang.Object removeSeqRefAt(
330 java.lang.Object obj = this._seqRef.remove(index);
335 * Sets the value of field 'provenance'.
337 * @param provenance the value of field 'provenance'.
339 public void setProvenance(
340 final uk.ac.vamsas.objects.core.Provenance provenance) {
341 this._provenance = provenance;
349 * @throws java.lang.IndexOutOfBoundsException if the index
350 * given is outside the bounds of the collection
352 public void setSeqRef(
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) + "]");
361 this._seqRef.set(index, vSeqRef);
367 * @param vSeqRefArray
369 public void setSeqRef(
370 final java.lang.Object[] vSeqRefArray) {
374 for (int i = 0; i < vSeqRefArray.length; i++) {
375 this._seqRef.add(vSeqRefArray[i]);
380 * Sets the value of '_seqRef' by copying the given Vector. All
381 * elements will be checked for type safety.
383 * @param vSeqRefList the Vector to copy.
385 public void setSeqRef(
386 final java.util.Vector vSeqRefList) {
388 this._seqRef.clear();
390 this._seqRef.addAll(vSeqRefList);
394 * Sets the value of '_seqRef' by setting it to the given
395 * Vector. No type checking is performed.
398 * @param seqRefVector the Vector to set.
400 public void setSeqRefAsReference(
401 final java.util.Vector seqRefVector) {
402 this._seqRef = seqRefVector;
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
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);
424 * @throws org.exolab.castor.xml.ValidationException if this
425 * object is an invalid instance according to the schema
427 public void validate(
429 throws org.exolab.castor.xml.ValidationException {
430 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
431 validator.validate(this);