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 Sequence extends uk.ac.vamsas.objects.core.SequenceType
23 implements java.io.Serializable
27 //--------------------------/
28 //- Class/Member Variables -/
29 //--------------------------/
32 * Primary Key for vamsas object referencing
35 private java.lang.String _id;
38 * symbol class for sequence
41 private java.lang.String _dictionary;
44 * Store a list of database references
45 * for this sequence record - with optional mapping
46 * from database sequence to the given sequence record
48 private java.util.Vector _dbRefList;
57 this._dbRefList = new java.util.Vector();
69 * @throws java.lang.IndexOutOfBoundsException if the index
70 * given is outside the bounds of the collection
73 final uk.ac.vamsas.objects.core.DbRef vDbRef)
74 throws java.lang.IndexOutOfBoundsException {
75 this._dbRefList.addElement(vDbRef);
83 * @throws java.lang.IndexOutOfBoundsException if the index
84 * given is outside the bounds of the collection
88 final uk.ac.vamsas.objects.core.DbRef vDbRef)
89 throws java.lang.IndexOutOfBoundsException {
90 this._dbRefList.add(index, vDbRef);
94 * Method enumerateDbRef.
96 * @return an Enumeration over all
97 * uk.ac.vamsas.objects.core.DbRef elements
99 public java.util.Enumeration enumerateDbRef(
101 return this._dbRefList.elements();
105 * Overrides the java.lang.Object.equals method.
108 * @return true if the objects are equal.
110 public boolean equals(
111 final java.lang.Object obj) {
115 if (super.equals(obj)==false)
118 if (obj instanceof Sequence) {
120 Sequence temp = (Sequence)obj;
121 if (this._id != null) {
122 if (temp._id == null) return false;
123 else if (!(this._id.equals(temp._id)))
126 else if (temp._id != null)
128 if (this._dictionary != null) {
129 if (temp._dictionary == null) return false;
130 else if (!(this._dictionary.equals(temp._dictionary)))
133 else if (temp._dictionary != null)
135 if (this._dbRefList != null) {
136 if (temp._dbRefList == null) return false;
137 else if (!(this._dbRefList.equals(temp._dbRefList)))
140 else if (temp._dbRefList != null)
151 * @throws java.lang.IndexOutOfBoundsException if the index
152 * given is outside the bounds of the collection
153 * @return the value of the uk.ac.vamsas.objects.core.DbRef at
156 public uk.ac.vamsas.objects.core.DbRef getDbRef(
158 throws java.lang.IndexOutOfBoundsException {
159 // check bounds for index
160 if (index < 0 || index >= this._dbRefList.size()) {
161 throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
164 return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index);
168 * Method getDbRef.Returns the contents of the collection in an
169 * Array. <p>Note: Just in case the collection contents are
170 * changing in another thread, we pass a 0-length Array of the
171 * correct type into the API call. This way we <i>know</i>
172 * that the Array returned is of exactly the correct length.
174 * @return this collection as an Array
176 public uk.ac.vamsas.objects.core.DbRef[] getDbRef(
178 uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0];
179 return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array);
183 * Method getDbRefAsReference.Returns a reference to
184 * '_dbRefList'. No type checking is performed on any
185 * modifications to the Vector.
187 * @return a reference to the Vector backing this class
189 public java.util.Vector getDbRefAsReference(
191 return this._dbRefList;
195 * Method getDbRefCount.
197 * @return the size of this collection
199 public int getDbRefCount(
201 return this._dbRefList.size();
205 * Returns the value of field 'dictionary'. The field
206 * 'dictionary' has the following description: symbol class for
210 * @return the value of field 'Dictionary'.
212 public java.lang.String getDictionary(
214 return this._dictionary;
218 * Returns the value of field 'id'. The field 'id' has the
219 * following description: Primary Key for vamsas object
223 * @return the value of field 'Id'.
225 public java.lang.String getId(
231 * Overrides the java.lang.Object.hashCode method.
233 * The following steps came from <b>Effective Java Programming
234 * Language Guide</b> by Joshua Bloch, Chapter 3
236 * @return a hash code value for the object.
240 int result = super.hashCode();
244 result = 37 * result + _id.hashCode();
246 if (_dictionary != null) {
247 result = 37 * result + _dictionary.hashCode();
249 if (_dbRefList != null) {
250 result = 37 * result + _dbRefList.hashCode();
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 removeAllDbRef(
307 this._dbRefList.clear();
311 * Method removeDbRef.
314 * @return true if the object was removed from the collection.
316 public boolean removeDbRef(
317 final uk.ac.vamsas.objects.core.DbRef vDbRef) {
318 boolean removed = _dbRefList.remove(vDbRef);
323 * Method removeDbRefAt.
326 * @return the element removed from the collection
328 public uk.ac.vamsas.objects.core.DbRef removeDbRefAt(
330 java.lang.Object obj = this._dbRefList.remove(index);
331 return (uk.ac.vamsas.objects.core.DbRef) obj;
339 * @throws java.lang.IndexOutOfBoundsException if the index
340 * given is outside the bounds of the collection
342 public void setDbRef(
344 final uk.ac.vamsas.objects.core.DbRef vDbRef)
345 throws java.lang.IndexOutOfBoundsException {
346 // check bounds for index
347 if (index < 0 || index >= this._dbRefList.size()) {
348 throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
351 this._dbRefList.set(index, vDbRef);
359 public void setDbRef(
360 final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) {
364 for (int i = 0; i < vDbRefArray.length; i++) {
365 this._dbRefList.add(vDbRefArray[i]);
370 * Sets the value of '_dbRefList' by copying the given Vector.
371 * All elements will be checked for type safety.
373 * @param vDbRefList the Vector to copy.
375 public void setDbRef(
376 final java.util.Vector vDbRefList) {
378 this._dbRefList.clear();
380 this._dbRefList.addAll(vDbRefList);
384 * Sets the value of '_dbRefList' by setting it to the given
385 * Vector. No type checking is performed.
388 * @param dbRefVector the Vector to set.
390 public void setDbRefAsReference(
391 final java.util.Vector dbRefVector) {
392 this._dbRefList = dbRefVector;
396 * Sets the value of field 'dictionary'. The field 'dictionary'
397 * has the following description: symbol class for sequence
400 * @param dictionary the value of field 'dictionary'.
402 public void setDictionary(
403 final java.lang.String dictionary) {
404 this._dictionary = dictionary;
408 * Sets the value of field 'id'. The field 'id' has the
409 * following description: Primary Key for vamsas object
413 * @param id the value of field 'id'.
416 final java.lang.String id) {
424 * @throws org.exolab.castor.xml.MarshalException if object is
425 * null or if any SAXException is thrown during marshaling
426 * @throws org.exolab.castor.xml.ValidationException if this
427 * object is an invalid instance according to the schema
428 * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
430 public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
431 final java.io.Reader reader)
432 throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
433 return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
439 * @throws org.exolab.castor.xml.ValidationException if this
440 * object is an invalid instance according to the schema
442 public void validate(
444 throws org.exolab.castor.xml.ValidationException {
445 org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
446 validator.validate(this);