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;
112 if (this._seqRef != null) {
113 if (temp._seqRef == null) return false;
114 else if (!(this._seqRef.equals(temp._seqRef)))
117 else if (temp._seqRef != null)
119 if (this._provenance != null) {
120 if (temp._provenance == null) return false;
121 else if (!(this._provenance.equals(temp._provenance)))
124 else if (temp._provenance != null)
132 * Returns the value of field 'provenance'.
134 * @return the value of field 'Provenance'.
136 public uk.ac.vamsas.objects.core.Provenance getProvenance(
138 return this._provenance;
145 * @throws java.lang.IndexOutOfBoundsException if the index
146 * given is outside the bounds of the collection
147 * @return the value of the java.lang.Object at the given index
149 public java.lang.Object getSeqRef(
151 throws java.lang.IndexOutOfBoundsException {
152 // check bounds for index
153 if (index < 0 || index >= this._seqRef.size()) {
154 throw new IndexOutOfBoundsException("getSeqRef: Index value '" + index + "' not in range [0.." + (this._seqRef.size() - 1) + "]");
157 return _seqRef.get(index);
161 * Method getSeqRef.Returns the contents of the collection in
162 * an Array. <p>Note: Just in case the collection contents
163 * are changing in another thread, we pass a 0-length Array of
164 * the correct type into the API call. This way we <i>know</i>
165 * that the Array returned is of exactly the correct length.
167 * @return this collection as an Array
169 public java.lang.Object[] getSeqRef(
171 java.lang.Object[] array = new java.lang.Object[0];
172 return (java.lang.Object[]) this._seqRef.toArray(array);
176 * Method getSeqRefAsReference.Returns a reference to
177 * '_seqRef'. No type checking is performed on any
178 * modifications to the Vector.
180 * @return a reference to the Vector backing this class
182 public java.util.Vector getSeqRefAsReference(
188 * Method getSeqRefCount.
190 * @return the size of this collection
192 public int getSeqRefCount(
194 return this._seqRef.size();
198 * Overrides the java.lang.Object.hashCode method.
200 * The following steps came from <b>Effective Java Programming
201 * Language Guide</b> by Joshua Bloch, Chapter 3
203 * @return a hash code value for the object.
207 int result = super.hashCode();
210 if (_seqRef != null) {
211 result = 37 * result + _seqRef.hashCode();
213 if (_provenance != null) {
214 result = 37 * result + _provenance.hashCode();
223 * @return true if this object is valid according to the schema
225 public boolean isValid(
229 } catch (org.exolab.castor.xml.ValidationException vex) {
239 * @throws org.exolab.castor.xml.MarshalException if object is
240 * null or if any SAXException is thrown during marshaling
241 * @throws org.exolab.castor.xml.ValidationException if this
242 * object is an invalid instance according to the schema
245 final java.io.Writer out)
246 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
247 Marshaller.marshal(this, out);
254 * @throws java.io.IOException if an IOException occurs during
256 * @throws org.exolab.castor.xml.ValidationException if this
257 * object is an invalid instance according to the schema
258 * @throws org.exolab.castor.xml.MarshalException if object is
259 * null or if any SAXException is thrown during marshaling
262 final org.xml.sax.ContentHandler handler)
263 throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
264 Marshaller.marshal(this, handler);
269 public void removeAllSeqRef(
271 this._seqRef.clear();
275 * Method removeSeqRef.
278 * @return true if the object was removed from the collection.
280 public boolean removeSeqRef(
281 final java.lang.Object vSeqRef) {
282 boolean removed = _seqRef.remove(vSeqRef);
287 * Method removeSeqRefAt.
290 * @return the element removed from the collection
292 public java.lang.Object removeSeqRefAt(
294 java.lang.Object obj = this._seqRef.remove(index);
299 * Sets the value of field 'provenance'.
301 * @param provenance the value of field 'provenance'.
303 public void setProvenance(
304 final uk.ac.vamsas.objects.core.Provenance provenance) {
305 this._provenance = provenance;
313 * @throws java.lang.IndexOutOfBoundsException if the index
314 * given is outside the bounds of the collection
316 public void setSeqRef(
318 final java.lang.Object vSeqRef)
319 throws java.lang.IndexOutOfBoundsException {
320 // check bounds for index
321 if (index < 0 || index >= this._seqRef.size()) {
322 throw new IndexOutOfBoundsException("setSeqRef: Index value '" + index + "' not in range [0.." + (this._seqRef.size() - 1) + "]");
325 this._seqRef.set(index, vSeqRef);
331 * @param vSeqRefArray
333 public void setSeqRef(
334 final java.lang.Object[] vSeqRefArray) {
338 for (int i = 0; i < vSeqRefArray.length; i++) {
339 this._seqRef.add(vSeqRefArray[i]);
344 * Sets the value of '_seqRef' by copying the given Vector. All
345 * elements will be checked for type safety.
347 * @param vSeqRefList the Vector to copy.
349 public void setSeqRef(
350 final java.util.Vector vSeqRefList) {
352 this._seqRef.clear();
354 this._seqRef.addAll(vSeqRefList);
358 * Sets the value of '_seqRef' by setting it to the given
359 * Vector. No type checking is performed.
362 * @param seqRefVector the Vector to set.
364 public void setSeqRefAsReference(
365 final java.util.Vector seqRefVector) {
366 this._seqRef = seqRefVector;
373 * @throws org.exolab.castor.xml.MarshalException if object is
374 * null or if any SAXException is thrown during marshaling
375 * @throws org.exolab.castor.xml.ValidationException if this
376 * object is an invalid instance according to the schema
377 * @return the unmarshaled uk.ac.vamsas.objects.core.RangeType
379 public static uk.ac.vamsas.objects.core.RangeType unmarshal(
380 final java.io.Reader reader)
381 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
382 return (uk.ac.vamsas.objects.core.RangeType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.DataSetAnnotations.class, reader);
388 * @throws org.exolab.castor.xml.ValidationException if this
389 * object is an invalid instance according to the schema
391 public void validate(
393 throws org.exolab.castor.xml.ValidationException {
394 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
395 validator.validate(this);