/* * This class was automatically generated with * Castor 0.9.9M2, using an XML * Schema. * $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 ApplicationData. * * @version $Revision$ $Date$ */ public class ApplicationData extends uk.ac.vamsas.objects.core.AppData implements java.io.Serializable { //--------------------------/ //- Class/Member Variables -/ //--------------------------/ /** * Version string describing the application specific * data storage version used */ private java.lang.String _version; /** * Canonical name of application */ private java.lang.String _name; /** * Field _userList */ private java.util.Vector _userList; /** * Field _common */ private uk.ac.vamsas.objects.core.Common _common; /** * Field _instanceList */ private java.util.Vector _instanceList; //----------------/ //- Constructors -/ //----------------/ public ApplicationData() { super(); _userList = new Vector(); _instanceList = new Vector(); } //-- uk.ac.vamsas.objects.core.ApplicationData() //-----------/ //- Methods -/ //-----------/ /** * Method addInstance * * * * @param vInstance */ 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) /** * Method addInstance * * * * @param index * @param vInstance */ 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) /** * Method addUser * * * * @param vUser */ 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) /** * Method addUser * * * * @param index * @param vUser */ 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) /** * Method enumerateInstance * * * * @return Enumeration */ public java.util.Enumeration enumerateInstance() { return _instanceList.elements(); } //-- java.util.Enumeration enumerateInstance() /** * Method enumerateUser * * * * @return Enumeration */ public java.util.Enumeration enumerateUser() { return _userList.elements(); } //-- java.util.Enumeration enumerateUser() /** * Note: hashCode() has not been overriden * * @param obj * @return boolean */ public boolean equals(java.lang.Object obj) { if ( this == obj ) return true; if (super.equals(obj)==false) return false; if (obj instanceof ApplicationData) { ApplicationData temp = (ApplicationData)obj; if (this._version != null) { if (temp._version == null) return false; else if (!(this._version.equals(temp._version))) return false; } else if (temp._version != null) return false; if (this._name != null) { if (temp._name == null) return false; else if (!(this._name.equals(temp._name))) return false; } else if (temp._name != null) return false; if (this._userList != null) { if (temp._userList == null) return false; else if (!(this._userList.equals(temp._userList))) return false; } else if (temp._userList != null) return false; if (this._common != null) { if (temp._common == null) return false; else if (!(this._common.equals(temp._common))) return false; } else if (temp._common != null) return false; if (this._instanceList != null) { if (temp._instanceList == null) return false; else if (!(this._instanceList.equals(temp._instanceList))) return false; } else if (temp._instanceList != null) return false; return true; } return false; } //-- boolean equals(java.lang.Object) /** * Returns the value of field 'common'. * * @return Common * @return the value of field 'common'. */ public uk.ac.vamsas.objects.core.Common getCommon() { return this._common; } //-- uk.ac.vamsas.objects.core.Common getCommon() /** * 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()+ "]"); } return (uk.ac.vamsas.objects.core.Instance) _instanceList.elementAt(index); } //-- uk.ac.vamsas.objects.core.Instance getInstance(int) /** * Method getInstance * * * * @return Instance */ 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() /** * Method getInstanceCount * * * * @return int */ public int getInstanceCount() { return _instanceList.size(); } //-- int getInstanceCount() /** * 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'. */ public java.lang.String getName() { return this._name; } //-- java.lang.String getName() /** * 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()+ "]"); } return (uk.ac.vamsas.objects.core.User) _userList.elementAt(index); } //-- uk.ac.vamsas.objects.core.User getUser(int) /** * Method getUser * * * * @return User */ 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() /** * Method getUserCount * * * * @return int */ public int getUserCount() { return _userList.size(); } //-- int getUserCount() /** * Returns the value of field 'version'. The field 'version' * has the following description: Version string describing the * application specific * data storage version used * * @return String * @return the value of field 'version'. */ public java.lang.String getVersion() { return this._version; } //-- java.lang.String getVersion() /** * Method isValid * * * * @return boolean */ public boolean isValid() { try { validate(); } 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 { 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 { Marshaller.marshal(this, handler); } //-- void marshal(org.xml.sax.ContentHandler) /** * Method removeAllInstance * */ public void removeAllInstance() { _instanceList.removeAllElements(); } //-- void removeAllInstance() /** * Method removeAllUser * */ public void removeAllUser() { _userList.removeAllElements(); } //-- void removeAllUser() /** * Method removeInstance * * * * @param index * @return Instance */ public uk.ac.vamsas.objects.core.Instance removeInstance(int index) { java.lang.Object obj = _instanceList.elementAt(index); _instanceList.removeElementAt(index); return (uk.ac.vamsas.objects.core.Instance) obj; } //-- uk.ac.vamsas.objects.core.Instance removeInstance(int) /** * Method removeUser * * * * @param index * @return User */ public uk.ac.vamsas.objects.core.User removeUser(int index) { java.lang.Object obj = _userList.elementAt(index); _userList.removeElementAt(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) { 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()+ "]"); } _instanceList.setElementAt(vInstance, index); } //-- void setInstance(int, uk.ac.vamsas.objects.core.Instance) /** * Method setInstance * * * * @param instanceArray */ public void setInstance(uk.ac.vamsas.objects.core.Instance[] instanceArray) { //-- copy array _instanceList.removeAllElements(); for (int i = 0; i < instanceArray.length; i++) { _instanceList.addElement(instanceArray[i]); } } //-- void setInstance(uk.ac.vamsas.objects.core.Instance) /** * Sets the value of field 'name'. The field 'name' has the * following description: Canonical name of application * * @param name the value of field 'name'. */ public void setName(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()+ "]"); } _userList.setElementAt(vUser, index); } //-- void setUser(int, uk.ac.vamsas.objects.core.User) /** * Method setUser * * * * @param userArray */ public void setUser(uk.ac.vamsas.objects.core.User[] userArray) { //-- copy array _userList.removeAllElements(); for (int i = 0; i < userArray.length; i++) { _userList.addElement(userArray[i]); } } //-- void setUser(uk.ac.vamsas.objects.core.User) /** * Sets the value of field 'version'. The field 'version' has * the following description: Version string describing the * application specific * data storage version used * * @param version the value of field 'version'. */ public void setVersion(java.lang.String version) { this._version = version; } //-- void setVersion(java.lang.String) /** * Method unmarshal * * * * @param reader * @return 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) /** * Method validate * */ 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() }