/*
* This class was automatically generated with
- * <a href="http://www.castor.org">Castor 0.9.9M2</a>, using an XML
+ * <a href="http://www.castor.org">Castor 1.1</a>, using an XML
* Schema.
- * $Id:Sequence.java 264 2006-12-14 17:42:54Z JimP $
+ * $Id$
*/
package uk.ac.vamsas.objects.core;
//- Imported classes and packages -/
//---------------------------------/
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.Writer;
-import java.util.Enumeration;
-import java.util.Vector;
-import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
-import org.exolab.castor.xml.ValidationException;
-import org.xml.sax.ContentHandler;
/**
* Class Sequence.
*
- * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $
+ * @version $Revision$ $Date$
*/
public class Sequence extends uk.ac.vamsas.objects.core.SequenceType
implements java.io.Serializable
//- Constructors -/
//----------------/
- public Sequence()
- {
+ public Sequence() {
super();
- _dbRefList = new Vector();
- } //-- uk.ac.vamsas.objects.core.Sequence()
+ this._dbRefList = new java.util.Vector();
+ }
//-----------/
//-----------/
/**
- * Method addDbRef
- *
*
*
* @param vDbRef
+ * @throws java.lang.IndexOutOfBoundsException if the index
+ * given is outside the bounds of the collection
*/
- public void addDbRef(uk.ac.vamsas.objects.core.DbRef vDbRef)
- throws java.lang.IndexOutOfBoundsException
- {
- _dbRefList.addElement(vDbRef);
- } //-- void addDbRef(uk.ac.vamsas.objects.core.DbRef)
+ public void addDbRef(
+ final uk.ac.vamsas.objects.core.DbRef vDbRef)
+ throws java.lang.IndexOutOfBoundsException {
+ this._dbRefList.addElement(vDbRef);
+ }
/**
- * Method addDbRef
- *
*
*
* @param index
* @param vDbRef
+ * @throws java.lang.IndexOutOfBoundsException if the index
+ * given is outside the bounds of the collection
*/
- public void addDbRef(int index, uk.ac.vamsas.objects.core.DbRef vDbRef)
- throws java.lang.IndexOutOfBoundsException
- {
- _dbRefList.insertElementAt(vDbRef, index);
- } //-- void addDbRef(int, uk.ac.vamsas.objects.core.DbRef)
+ public void addDbRef(
+ final int index,
+ final uk.ac.vamsas.objects.core.DbRef vDbRef)
+ throws java.lang.IndexOutOfBoundsException {
+ this._dbRefList.add(index, vDbRef);
+ }
/**
- * Method enumerateDbRef
- *
- *
+ * Method enumerateDbRef.
*
- * @return Enumeration
+ * @return an Enumeration over all
+ * uk.ac.vamsas.objects.core.DbRef elements
*/
- public java.util.Enumeration enumerateDbRef()
- {
- return _dbRefList.elements();
- } //-- java.util.Enumeration enumerateDbRef()
+ public java.util.Enumeration enumerateDbRef(
+ ) {
+ return this._dbRefList.elements();
+ }
/**
- * Note: hashCode() has not been overriden
+ * Overrides the java.lang.Object.equals method.
*
* @param obj
- * @return boolean
+ * @return true if the objects are equal.
*/
- public boolean equals(java.lang.Object obj)
- {
+ public boolean equals(
+ final java.lang.Object obj) {
if ( this == obj )
return true;
return true;
}
return false;
- } //-- boolean equals(java.lang.Object)
+ }
/**
- * Method getDbRef
- *
- *
+ * Method getDbRef.
*
* @param index
- * @return DbRef
+ * @throws java.lang.IndexOutOfBoundsException if the index
+ * given is outside the bounds of the collection
+ * @return the value of the uk.ac.vamsas.objects.core.DbRef at
+ * the given index
*/
- public uk.ac.vamsas.objects.core.DbRef getDbRef(int index)
- throws java.lang.IndexOutOfBoundsException
- {
- //-- check bounds for index
- if ((index < 0) || (index > _dbRefList.size())) {
- throw new IndexOutOfBoundsException("getDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]");
+ public uk.ac.vamsas.objects.core.DbRef getDbRef(
+ final int index)
+ throws java.lang.IndexOutOfBoundsException {
+ // check bounds for index
+ if (index < 0 || index >= this._dbRefList.size()) {
+ throw new IndexOutOfBoundsException("getDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
}
- return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.elementAt(index);
- } //-- uk.ac.vamsas.objects.core.DbRef getDbRef(int)
+ return (uk.ac.vamsas.objects.core.DbRef) _dbRefList.get(index);
+ }
/**
- * Method getDbRef
- *
+ * Method getDbRef.Returns the contents of the collection in an
+ * Array. <p>Note: Just in case the collection contents are
+ * changing in another thread, we pass a 0-length Array of the
+ * correct type into the API call. This way we <i>know</i>
+ * that the Array returned is of exactly the correct length.
*
- *
- * @return DbRef
+ * @return this collection as an Array
*/
- public uk.ac.vamsas.objects.core.DbRef[] getDbRef()
- {
- int size = _dbRefList.size();
- uk.ac.vamsas.objects.core.DbRef[] mArray = new uk.ac.vamsas.objects.core.DbRef[size];
- for (int index = 0; index < size; index++) {
- mArray[index] = (uk.ac.vamsas.objects.core.DbRef) _dbRefList.elementAt(index);
- }
- return mArray;
- } //-- uk.ac.vamsas.objects.core.DbRef[] getDbRef()
+ public uk.ac.vamsas.objects.core.DbRef[] getDbRef(
+ ) {
+ uk.ac.vamsas.objects.core.DbRef[] array = new uk.ac.vamsas.objects.core.DbRef[0];
+ return (uk.ac.vamsas.objects.core.DbRef[]) this._dbRefList.toArray(array);
+ }
/**
- * Method getDbRefCount
- *
+ * Method getDbRefAsReference.Returns a reference to
+ * '_dbRefList'. No type checking is performed on any
+ * modifications to the Vector.
*
+ * @return a reference to the Vector backing this class
+ */
+ public java.util.Vector getDbRefAsReference(
+ ) {
+ return this._dbRefList;
+ }
+
+ /**
+ * Method getDbRefCount.
*
- * @return int
+ * @return the size of this collection
*/
- public int getDbRefCount()
- {
- return _dbRefList.size();
- } //-- int getDbRefCount()
+ public int getDbRefCount(
+ ) {
+ return this._dbRefList.size();
+ }
/**
* Returns the value of field 'dictionary'. The field
* sequence
*
*
- * @return String
- * @return the value of field 'dictionary'.
+ * @return the value of field 'Dictionary'.
*/
- public java.lang.String getDictionary()
- {
+ public java.lang.String getDictionary(
+ ) {
return this._dictionary;
- } //-- java.lang.String getDictionary()
+ }
/**
* Returns the value of field 'id'. The field 'id' has the
* referencing
*
*
- * @return String
- * @return the value of field 'id'.
+ * @return the value of field 'Id'.
*/
- public java.lang.String getId()
- {
+ public java.lang.String getId(
+ ) {
return this._id;
- } //-- java.lang.String getId()
+ }
/**
- * Method isValid
- *
+ * Overrides the java.lang.Object.hashCode method.
+ * <p>
+ * The following steps came from <b>Effective Java Programming
+ * Language Guide</b> by Joshua Bloch, Chapter 3
*
+ * @return a hash code value for the object.
+ */
+ public int hashCode(
+ ) {
+ int result = super.hashCode();
+
+ long tmp;
+ if (_id != null) {
+ result = 37 * result + _id.hashCode();
+ }
+ if (_dictionary != null) {
+ result = 37 * result + _dictionary.hashCode();
+ }
+ if (_dbRefList != null) {
+ result = 37 * result + _dbRefList.hashCode();
+ }
+
+ return result;
+ }
+
+ /**
+ * Method isValid.
*
- * @return boolean
+ * @return true if this object is valid according to the schema
*/
- public boolean isValid()
- {
+ public boolean isValid(
+ ) {
try {
validate();
- }
- catch (org.exolab.castor.xml.ValidationException vex) {
+ } catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
- } //-- boolean isValid()
+ }
/**
- * Method marshal
- *
*
*
* @param out
+ * @throws org.exolab.castor.xml.MarshalException if object is
+ * null or if any SAXException is thrown during marshaling
+ * @throws org.exolab.castor.xml.ValidationException if this
+ * object is an invalid instance according to the schema
*/
- public void marshal(java.io.Writer out)
- throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
- {
-
+ public void marshal(
+ final java.io.Writer out)
+ throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
Marshaller.marshal(this, out);
- } //-- void marshal(java.io.Writer)
+ }
/**
- * Method marshal
- *
*
*
* @param handler
+ * @throws java.io.IOException if an IOException occurs during
+ * marshaling
+ * @throws org.exolab.castor.xml.ValidationException if this
+ * object is an invalid instance according to the schema
+ * @throws org.exolab.castor.xml.MarshalException if object is
+ * null or if any SAXException is thrown during marshaling
*/
- public void marshal(org.xml.sax.ContentHandler handler)
- throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
- {
-
+ public void marshal(
+ final org.xml.sax.ContentHandler handler)
+ throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
Marshaller.marshal(this, handler);
- } //-- void marshal(org.xml.sax.ContentHandler)
+ }
/**
- * Method removeAllDbRef
- *
*/
- public void removeAllDbRef()
- {
- _dbRefList.removeAllElements();
- } //-- void removeAllDbRef()
+ public void removeAllDbRef(
+ ) {
+ this._dbRefList.clear();
+ }
/**
- * Method removeDbRef
- *
+ * Method removeDbRef.
*
+ * @param vDbRef
+ * @return true if the object was removed from the collection.
+ */
+ public boolean removeDbRef(
+ final uk.ac.vamsas.objects.core.DbRef vDbRef) {
+ boolean removed = _dbRefList.remove(vDbRef);
+ return removed;
+ }
+
+ /**
+ * Method removeDbRefAt.
*
* @param index
- * @return DbRef
+ * @return the element removed from the collection
*/
- public uk.ac.vamsas.objects.core.DbRef removeDbRef(int index)
- {
- java.lang.Object obj = _dbRefList.elementAt(index);
- _dbRefList.removeElementAt(index);
+ public uk.ac.vamsas.objects.core.DbRef removeDbRefAt(
+ final int index) {
+ java.lang.Object obj = this._dbRefList.remove(index);
return (uk.ac.vamsas.objects.core.DbRef) obj;
- } //-- uk.ac.vamsas.objects.core.DbRef removeDbRef(int)
+ }
/**
- * Method setDbRef
- *
*
*
* @param index
* @param vDbRef
+ * @throws java.lang.IndexOutOfBoundsException if the index
+ * given is outside the bounds of the collection
*/
- public void setDbRef(int index, uk.ac.vamsas.objects.core.DbRef vDbRef)
- throws java.lang.IndexOutOfBoundsException
- {
- //-- check bounds for index
- if ((index < 0) || (index > _dbRefList.size())) {
- throw new IndexOutOfBoundsException("setDbRef: Index value '"+index+"' not in range [0.."+_dbRefList.size()+ "]");
+ public void setDbRef(
+ final int index,
+ final uk.ac.vamsas.objects.core.DbRef vDbRef)
+ throws java.lang.IndexOutOfBoundsException {
+ // check bounds for index
+ if (index < 0 || index >= this._dbRefList.size()) {
+ throw new IndexOutOfBoundsException("setDbRef: Index value '" + index + "' not in range [0.." + (this._dbRefList.size() - 1) + "]");
}
- _dbRefList.setElementAt(vDbRef, index);
- } //-- void setDbRef(int, uk.ac.vamsas.objects.core.DbRef)
+
+ this._dbRefList.set(index, vDbRef);
+ }
/**
- * Method setDbRef
- *
*
*
- * @param dbRefArray
+ * @param vDbRefArray
*/
- public void setDbRef(uk.ac.vamsas.objects.core.DbRef[] dbRefArray)
- {
+ public void setDbRef(
+ final uk.ac.vamsas.objects.core.DbRef[] vDbRefArray) {
//-- copy array
- _dbRefList.removeAllElements();
- for (int i = 0; i < dbRefArray.length; i++) {
- _dbRefList.addElement(dbRefArray[i]);
+ _dbRefList.clear();
+
+ for (int i = 0; i < vDbRefArray.length; i++) {
+ this._dbRefList.add(vDbRefArray[i]);
}
- } //-- void setDbRef(uk.ac.vamsas.objects.core.DbRef)
+ }
+
+ /**
+ * Sets the value of '_dbRefList' by copying the given Vector.
+ * All elements will be checked for type safety.
+ *
+ * @param vDbRefList the Vector to copy.
+ */
+ public void setDbRef(
+ final java.util.Vector vDbRefList) {
+ // copy vector
+ this._dbRefList.clear();
+
+ this._dbRefList.addAll(vDbRefList);
+ }
+
+ /**
+ * Sets the value of '_dbRefList' by setting it to the given
+ * Vector. No type checking is performed.
+ * @deprecated
+ *
+ * @param dbRefVector the Vector to set.
+ */
+ public void setDbRefAsReference(
+ final java.util.Vector dbRefVector) {
+ this._dbRefList = dbRefVector;
+ }
/**
* Sets the value of field 'dictionary'. The field 'dictionary'
*
* @param dictionary the value of field 'dictionary'.
*/
- public void setDictionary(java.lang.String dictionary)
- {
+ public void setDictionary(
+ final java.lang.String dictionary) {
this._dictionary = dictionary;
- } //-- void setDictionary(java.lang.String)
+ }
/**
* Sets the value of field 'id'. The field 'id' has the
*
* @param id the value of field 'id'.
*/
- public void setId(java.lang.String id)
- {
+ public void setId(
+ final java.lang.String id) {
this._id = id;
- } //-- void setId(java.lang.String)
+ }
/**
- * Method unmarshal
- *
- *
+ * Method unmarshal.
*
* @param reader
- * @return SequenceType
+ * @throws org.exolab.castor.xml.MarshalException if object is
+ * null or if any SAXException is thrown during marshaling
+ * @throws org.exolab.castor.xml.ValidationException if this
+ * object is an invalid instance according to the schema
+ * @return the unmarshaled uk.ac.vamsas.objects.core.SequenceTyp
*/
- public static uk.ac.vamsas.objects.core.SequenceType unmarshal(java.io.Reader reader)
- throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
- {
- return (uk.ac.vamsas.objects.core.Sequence) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
- } //-- uk.ac.vamsas.objects.core.SequenceType unmarshal(java.io.Reader)
+ public static uk.ac.vamsas.objects.core.SequenceType unmarshal(
+ final java.io.Reader reader)
+ throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException {
+ return (uk.ac.vamsas.objects.core.SequenceType) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.Sequence.class, reader);
+ }
/**
- * Method validate
*
+ *
+ * @throws org.exolab.castor.xml.ValidationException if this
+ * object is an invalid instance according to the schema
*/
- public void validate()
- throws org.exolab.castor.xml.ValidationException
- {
+ public void validate(
+ )
+ throws org.exolab.castor.xml.ValidationException {
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
- } //-- void validate()
+ }
}