X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuk%2Fac%2Fvamsas%2Fobjects%2Fcore%2FApplicationData.java;h=ff0b5d04e73b2efa2b870a304f24c2e8e7304f3c;hb=e4bdd840d03dfca1ebc51818eb9c15400b06fd58;hp=1e204e6f4d011095cf6ab0f9816d878eb0490c80;hpb=a06295cc0912455e0bc53b26cb4e0134e6759d0f;p=vamsas.git diff --git a/src/uk/ac/vamsas/objects/core/ApplicationData.java b/src/uk/ac/vamsas/objects/core/ApplicationData.java index 1e204e6..ff0b5d0 100644 --- a/src/uk/ac/vamsas/objects/core/ApplicationData.java +++ b/src/uk/ac/vamsas/objects/core/ApplicationData.java @@ -1,8 +1,8 @@ /* * This class was automatically generated with - * Castor 0.9.9M2, using an XML + * Castor 1.1, using an XML * Schema. - * $Id:ApplicationData.java 264 2006-12-14 17:42:54Z JimP $ + * $Id$ */ package uk.ac.vamsas.objects.core; @@ -11,22 +11,13 @@ 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 ApplicationData. * - * @version $Revision:264 $ $Date:2006-12-14 17:42:54 +0000 (Thu, 14 Dec 2006) $ + * @version $Revision$ $Date$ */ public class ApplicationData extends uk.ac.vamsas.objects.core.AppData implements java.io.Serializable @@ -49,17 +40,17 @@ implements java.io.Serializable private java.lang.String _name; /** - * Field _userList + * Field _userList. */ private java.util.Vector _userList; /** - * Field _common + * Field _common. */ private uk.ac.vamsas.objects.core.Common _common; /** - * Field _instanceList + * Field _instanceList. */ private java.util.Vector _instanceList; @@ -68,12 +59,11 @@ implements java.io.Serializable //- Constructors -/ //----------------/ - public ApplicationData() - { + public ApplicationData() { super(); - _userList = new Vector(); - _instanceList = new Vector(); - } //-- uk.ac.vamsas.objects.core.ApplicationData() + this._userList = new java.util.Vector(); + this._instanceList = new java.util.Vector(); + } //-----------/ @@ -81,91 +71,91 @@ implements java.io.Serializable //-----------/ /** - * Method addInstance - * * * * @param vInstance + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addInstance(uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException - { - _instanceList.addElement(vInstance); - } //-- void addInstance(uk.ac.vamsas.objects.core.Instance) + public void addInstance( + final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + this._instanceList.addElement(vInstance); + } /** - * Method addInstance - * * * * @param index * @param vInstance + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addInstance(int index, uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException - { - _instanceList.insertElementAt(vInstance, index); - } //-- void addInstance(int, uk.ac.vamsas.objects.core.Instance) + public void addInstance( + final int index, + final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + this._instanceList.add(index, vInstance); + } /** - * Method addUser - * * * * @param vUser + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addUser(uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException - { - _userList.addElement(vUser); - } //-- void addUser(uk.ac.vamsas.objects.core.User) + public void addUser( + final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + this._userList.addElement(vUser); + } /** - * Method addUser - * * * * @param index * @param vUser + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection */ - public void addUser(int index, uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException - { - _userList.insertElementAt(vUser, index); - } //-- void addUser(int, uk.ac.vamsas.objects.core.User) + public void addUser( + final int index, + final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + this._userList.add(index, vUser); + } /** - * Method enumerateInstance - * - * + * Method enumerateInstance. * - * @return Enumeration + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.Instance elements */ - public java.util.Enumeration enumerateInstance() - { - return _instanceList.elements(); - } //-- java.util.Enumeration enumerateInstance() + public java.util.Enumeration enumerateInstance( + ) { + return this._instanceList.elements(); + } /** - * Method enumerateUser + * Method enumerateUser. * - * - * - * @return Enumeration + * @return an Enumeration over all + * uk.ac.vamsas.objects.core.User elements */ - public java.util.Enumeration enumerateUser() - { - return _userList.elements(); - } //-- java.util.Enumeration enumerateUser() + public java.util.Enumeration enumerateUser( + ) { + return this._userList.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; @@ -213,126 +203,142 @@ implements java.io.Serializable return true; } return false; - } //-- boolean equals(java.lang.Object) + } /** * Returns the value of field 'common'. * - * @return Common - * @return the value of field 'common'. + * @return the value of field 'Common'. */ - public uk.ac.vamsas.objects.core.Common getCommon() - { + public uk.ac.vamsas.objects.core.Common getCommon( + ) { return this._common; - } //-- uk.ac.vamsas.objects.core.Common getCommon() + } /** - * Method getInstance - * - * + * Method getInstance. * * @param index - * @return Instance - */ - public uk.ac.vamsas.objects.core.Instance getInstance(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _instanceList.size())) { - throw new IndexOutOfBoundsException("getInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]"); + * @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.Instance + * at the given index + */ + public uk.ac.vamsas.objects.core.Instance getInstance( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._instanceList.size()) { + throw new IndexOutOfBoundsException("getInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); } - return (uk.ac.vamsas.objects.core.Instance) _instanceList.elementAt(index); - } //-- uk.ac.vamsas.objects.core.Instance getInstance(int) + return (uk.ac.vamsas.objects.core.Instance) _instanceList.get(index); + } /** - * Method getInstance - * + * Method getInstance.Returns the contents of the collection in + * an Array.
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 know + * that the Array returned is of exactly the correct length. * - * - * @return Instance + * @return this collection as an Array */ - public uk.ac.vamsas.objects.core.Instance[] getInstance() - { - int size = _instanceList.size(); - uk.ac.vamsas.objects.core.Instance[] mArray = new uk.ac.vamsas.objects.core.Instance[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (uk.ac.vamsas.objects.core.Instance) _instanceList.elementAt(index); - } - return mArray; - } //-- uk.ac.vamsas.objects.core.Instance[] getInstance() + public uk.ac.vamsas.objects.core.Instance[] getInstance( + ) { + uk.ac.vamsas.objects.core.Instance[] array = new uk.ac.vamsas.objects.core.Instance[0]; + return (uk.ac.vamsas.objects.core.Instance[]) this._instanceList.toArray(array); + } /** - * Method getInstanceCount - * + * Method getInstanceAsReference.Returns a reference to + * '_instanceList'. No type checking is performed on any + * modifications to the Vector. * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getInstanceAsReference( + ) { + return this._instanceList; + } + + /** + * Method getInstanceCount. * - * @return int + * @return the size of this collection */ - public int getInstanceCount() - { - return _instanceList.size(); - } //-- int getInstanceCount() + public int getInstanceCount( + ) { + return this._instanceList.size(); + } /** * Returns the value of field 'name'. The field 'name' has the * following description: Canonical name of application * - * @return String - * @return the value of field 'name'. + * @return the value of field 'Name'. */ - public java.lang.String getName() - { + public java.lang.String getName( + ) { return this._name; - } //-- java.lang.String getName() + } /** - * Method getUser - * - * + * Method getUser. * * @param index - * @return User - */ - public uk.ac.vamsas.objects.core.User getUser(int index) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _userList.size())) { - throw new IndexOutOfBoundsException("getUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]"); + * @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.User at + * the given index + */ + public uk.ac.vamsas.objects.core.User getUser( + final int index) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._userList.size()) { + throw new IndexOutOfBoundsException("getUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]"); } - return (uk.ac.vamsas.objects.core.User) _userList.elementAt(index); - } //-- uk.ac.vamsas.objects.core.User getUser(int) + return (uk.ac.vamsas.objects.core.User) _userList.get(index); + } /** - * Method getUser - * + * Method getUser.Returns the contents of the collection in an + * Array.
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 know + * that the Array returned is of exactly the correct length. * - * - * @return User + * @return this collection as an Array */ - public uk.ac.vamsas.objects.core.User[] getUser() - { - int size = _userList.size(); - uk.ac.vamsas.objects.core.User[] mArray = new uk.ac.vamsas.objects.core.User[size]; - for (int index = 0; index < size; index++) { - mArray[index] = (uk.ac.vamsas.objects.core.User) _userList.elementAt(index); - } - return mArray; - } //-- uk.ac.vamsas.objects.core.User[] getUser() + public uk.ac.vamsas.objects.core.User[] getUser( + ) { + uk.ac.vamsas.objects.core.User[] array = new uk.ac.vamsas.objects.core.User[0]; + return (uk.ac.vamsas.objects.core.User[]) this._userList.toArray(array); + } /** - * Method getUserCount - * + * Method getUserAsReference.Returns a reference to + * '_userList'. No type checking is performed on any + * modifications to the Vector. * + * @return a reference to the Vector backing this class + */ + public java.util.Vector getUserAsReference( + ) { + return this._userList; + } + + /** + * Method getUserCount. * - * @return int + * @return the size of this collection */ - public int getUserCount() - { - return _userList.size(); - } //-- int getUserCount() + public int getUserCount( + ) { + return this._userList.size(); + } /** * Returns the value of field 'version'. The field 'version' @@ -340,151 +346,224 @@ implements java.io.Serializable * application specific * data storage version used * - * @return String - * @return the value of field 'version'. + * @return the value of field 'Version'. */ - public java.lang.String getVersion() - { + public java.lang.String getVersion( + ) { return this._version; - } //-- java.lang.String getVersion() + } /** - * Method isValid - * + * Overrides the java.lang.Object.hashCode method. + *
+ * The following steps came from Effective Java Programming + * Language Guide by Joshua Bloch, Chapter 3 * + * @return a hash code value for the object. + */ + public int hashCode( + ) { + int result = super.hashCode(); + + long tmp; + if (_version != null) { + result = 37 * result + _version.hashCode(); + } + if (_name != null) { + result = 37 * result + _name.hashCode(); + } + if (_userList != null) { + result = 37 * result + _userList.hashCode(); + } + if (_common != null) { + result = 37 * result + _common.hashCode(); + } + if (_instanceList != null) { + result = 37 * result + _instanceList.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 - */ - public void marshal(java.io.Writer out) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + * @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( + 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 - */ - public void marshal(org.xml.sax.ContentHandler handler) - throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - + * @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( + 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 removeAllInstance - * */ - public void removeAllInstance() - { - _instanceList.removeAllElements(); - } //-- void removeAllInstance() + public void removeAllInstance( + ) { + this._instanceList.clear(); + } /** - * Method removeAllUser - * */ - public void removeAllUser() - { - _userList.removeAllElements(); - } //-- void removeAllUser() + public void removeAllUser( + ) { + this._userList.clear(); + } /** - * Method removeInstance - * + * Method removeInstance. * + * @param vInstance + * @return true if the object was removed from the collection. + */ + public boolean removeInstance( + final uk.ac.vamsas.objects.core.Instance vInstance) { + boolean removed = _instanceList.remove(vInstance); + return removed; + } + + /** + * Method removeInstanceAt. * * @param index - * @return Instance + * @return the element removed from the collection */ - public uk.ac.vamsas.objects.core.Instance removeInstance(int index) - { - java.lang.Object obj = _instanceList.elementAt(index); - _instanceList.removeElementAt(index); + public uk.ac.vamsas.objects.core.Instance removeInstanceAt( + final int index) { + java.lang.Object obj = this._instanceList.remove(index); return (uk.ac.vamsas.objects.core.Instance) obj; - } //-- uk.ac.vamsas.objects.core.Instance removeInstance(int) + } /** - * Method removeUser - * + * Method removeUser. * + * @param vUser + * @return true if the object was removed from the collection. + */ + public boolean removeUser( + final uk.ac.vamsas.objects.core.User vUser) { + boolean removed = _userList.remove(vUser); + return removed; + } + + /** + * Method removeUserAt. * * @param index - * @return User + * @return the element removed from the collection */ - public uk.ac.vamsas.objects.core.User removeUser(int index) - { - java.lang.Object obj = _userList.elementAt(index); - _userList.removeElementAt(index); + public uk.ac.vamsas.objects.core.User removeUserAt( + final int index) { + java.lang.Object obj = this._userList.remove(index); return (uk.ac.vamsas.objects.core.User) obj; - } //-- uk.ac.vamsas.objects.core.User removeUser(int) + } /** * Sets the value of field 'common'. * * @param common the value of field 'common'. */ - public void setCommon(uk.ac.vamsas.objects.core.Common common) - { + public void setCommon( + final uk.ac.vamsas.objects.core.Common common) { this._common = common; - } //-- void setCommon(uk.ac.vamsas.objects.core.Common) + } /** - * Method setInstance - * * * * @param index * @param vInstance - */ - public void setInstance(int index, uk.ac.vamsas.objects.core.Instance vInstance) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _instanceList.size())) { - throw new IndexOutOfBoundsException("setInstance: Index value '"+index+"' not in range [0.."+_instanceList.size()+ "]"); + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setInstance( + final int index, + final uk.ac.vamsas.objects.core.Instance vInstance) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._instanceList.size()) { + throw new IndexOutOfBoundsException("setInstance: Index value '" + index + "' not in range [0.." + (this._instanceList.size() - 1) + "]"); } - _instanceList.setElementAt(vInstance, index); - } //-- void setInstance(int, uk.ac.vamsas.objects.core.Instance) + + this._instanceList.set(index, vInstance); + } /** - * Method setInstance - * * * - * @param instanceArray + * @param vInstanceArray */ - public void setInstance(uk.ac.vamsas.objects.core.Instance[] instanceArray) - { + public void setInstance( + final uk.ac.vamsas.objects.core.Instance[] vInstanceArray) { //-- copy array - _instanceList.removeAllElements(); - for (int i = 0; i < instanceArray.length; i++) { - _instanceList.addElement(instanceArray[i]); + _instanceList.clear(); + + for (int i = 0; i < vInstanceArray.length; i++) { + this._instanceList.add(vInstanceArray[i]); } - } //-- void setInstance(uk.ac.vamsas.objects.core.Instance) + } + + /** + * Sets the value of '_instanceList' by copying the given + * Vector. All elements will be checked for type safety. + * + * @param vInstanceList the Vector to copy. + */ + public void setInstance( + final java.util.Vector vInstanceList) { + // copy vector + this._instanceList.clear(); + + this._instanceList.addAll(vInstanceList); + } + + /** + * Sets the value of '_instanceList' by setting it to the given + * Vector. No type checking is performed. + * @deprecated + * + * @param instanceVector the Vector to set. + */ + public void setInstanceAsReference( + final java.util.Vector instanceVector) { + this._instanceList = instanceVector; + } /** * Sets the value of field 'name'. The field 'name' has the @@ -492,44 +571,71 @@ implements java.io.Serializable * * @param name the value of field 'name'. */ - public void setName(java.lang.String name) - { + public void setName( + final java.lang.String name) { this._name = name; - } //-- void setName(java.lang.String) + } /** - * Method setUser - * * * * @param index * @param vUser - */ - public void setUser(int index, uk.ac.vamsas.objects.core.User vUser) - throws java.lang.IndexOutOfBoundsException - { - //-- check bounds for index - if ((index < 0) || (index > _userList.size())) { - throw new IndexOutOfBoundsException("setUser: Index value '"+index+"' not in range [0.."+_userList.size()+ "]"); + * @throws java.lang.IndexOutOfBoundsException if the index + * given is outside the bounds of the collection + */ + public void setUser( + final int index, + final uk.ac.vamsas.objects.core.User vUser) + throws java.lang.IndexOutOfBoundsException { + // check bounds for index + if (index < 0 || index >= this._userList.size()) { + throw new IndexOutOfBoundsException("setUser: Index value '" + index + "' not in range [0.." + (this._userList.size() - 1) + "]"); } - _userList.setElementAt(vUser, index); - } //-- void setUser(int, uk.ac.vamsas.objects.core.User) + + this._userList.set(index, vUser); + } /** - * Method setUser - * * * - * @param userArray + * @param vUserArray */ - public void setUser(uk.ac.vamsas.objects.core.User[] userArray) - { + public void setUser( + final uk.ac.vamsas.objects.core.User[] vUserArray) { //-- copy array - _userList.removeAllElements(); - for (int i = 0; i < userArray.length; i++) { - _userList.addElement(userArray[i]); + _userList.clear(); + + for (int i = 0; i < vUserArray.length; i++) { + this._userList.add(vUserArray[i]); } - } //-- void setUser(uk.ac.vamsas.objects.core.User) + } + + /** + * Sets the value of '_userList' by copying the given Vector. + * All elements will be checked for type safety. + * + * @param vUserList the Vector to copy. + */ + public void setUser( + final java.util.Vector vUserList) { + // copy vector + this._userList.clear(); + + this._userList.addAll(vUserList); + } + + /** + * Sets the value of '_userList' by setting it to the given + * Vector. No type checking is performed. + * @deprecated + * + * @param userVector the Vector to set. + */ + public void setUserAsReference( + final java.util.Vector userVector) { + this._userList = userVector; + } /** * Sets the value of field 'version'. The field 'version' has @@ -539,34 +645,38 @@ implements java.io.Serializable * * @param version the value of field 'version'. */ - public void setVersion(java.lang.String version) - { + public void setVersion( + final java.lang.String version) { this._version = version; - } //-- void setVersion(java.lang.String) + } /** - * Method unmarshal - * - * + * Method unmarshal. * * @param reader - * @return AppData + * @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.AppData */ - public static uk.ac.vamsas.objects.core.AppData unmarshal(java.io.Reader reader) - throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException - { - return (uk.ac.vamsas.objects.core.ApplicationData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ApplicationData.class, reader); - } //-- uk.ac.vamsas.objects.core.AppData unmarshal(java.io.Reader) + public static uk.ac.vamsas.objects.core.AppData unmarshal( + final java.io.Reader reader) + throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException { + return (uk.ac.vamsas.objects.core.AppData) Unmarshaller.unmarshal(uk.ac.vamsas.objects.core.ApplicationData.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() + } }