X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Forg%2Fvamsas%2Fobjects%2Fcore%2FDbRef.java;h=bf5541d69c73ee1b28d8b06a37578d4d8229bf06;hb=127eed38a79f4e1b56457a3cd5c5de12c9c7d4a2;hp=8666d7187adf0a9266995bdc8a009e4be1572a3f;hpb=b0e8ba054e5c3d3cd256f78d3a7310e6e263630e;p=vamsas.git diff --git a/src/org/vamsas/objects/core/DbRef.java b/src/org/vamsas/objects/core/DbRef.java index 8666d71..bf5541d 100644 --- a/src/org/vamsas/objects/core/DbRef.java +++ b/src/org/vamsas/objects/core/DbRef.java @@ -15,6 +15,8 @@ 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; @@ -22,7 +24,13 @@ import org.exolab.castor.xml.ValidationException; import org.xml.sax.ContentHandler; /** - * Class DbRef. + * Store a list of database + * references for this + * sequence record - with + * optional mapping from + * database sequence to the + * given sequence record + * * * @version $Revision$ $Date$ */ @@ -36,25 +44,65 @@ implements java.io.Serializable //--------------------------/ /** - * Field _source + * TODO Database + * Naming + * Convention: + * either start + * using LSID (so + * change type to + * URI) or leave + * this as an + * uncontrolled/unspecified + * string ID + * */ private java.lang.String _source; /** - * Field _version + * Version must be + * specified - + * */ private java.lang.String _version; /** - * Field _accessionId + * TODO: make some + * specification of + * the database + * field from which + * this accessionId + * is taken from - + * should that be a + * special property + * of the dbRef + * object ? + * */ private java.lang.String _accessionId; /** - * Field _id + * Primary Key for + * vamsas object + * referencing + * */ private java.lang.String _id; + /** + * Field _mapList + */ + private java.util.Vector _mapList; + + /** + * Field _linkList + */ + private java.util.Vector _linkList; + + /** + * Field _propertyList + */ + private java.util.Vector _propertyList; + //----------------/ //- Constructors -/ @@ -63,6 +111,9 @@ implements java.io.Serializable public DbRef() { super(); + _mapList = new Vector(); + _linkList = new Vector(); + _propertyList = new Vector(); } //-- org.vamsas.objects.core.DbRef() @@ -71,6 +122,123 @@ implements java.io.Serializable //-----------/ /** + * Method addLink + * + * + * + * @param vLink + */ + public void addLink(org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.addElement(vLink); + } //-- void addLink(org.vamsas.objects.core.Link) + + /** + * Method addLink + * + * + * + * @param index + * @param vLink + */ + public void addLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + _linkList.insertElementAt(vLink, index); + } //-- void addLink(int, org.vamsas.objects.core.Link) + + /** + * Method addMap + * + * + * + * @param vMap + */ + public void addMap(org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + _mapList.addElement(vMap); + } //-- void addMap(org.vamsas.objects.core.Map) + + /** + * Method addMap + * + * + * + * @param index + * @param vMap + */ + public void addMap(int index, org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + _mapList.insertElementAt(vMap, index); + } //-- void addMap(int, org.vamsas.objects.core.Map) + + /** + * Method addProperty + * + * + * + * @param vProperty + */ + public void addProperty(org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.addElement(vProperty); + } //-- void addProperty(org.vamsas.objects.core.Property) + + /** + * Method addProperty + * + * + * + * @param index + * @param vProperty + */ + public void addProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + _propertyList.insertElementAt(vProperty, index); + } //-- void addProperty(int, org.vamsas.objects.core.Property) + + /** + * Method enumerateLink + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateLink() + { + return _linkList.elements(); + } //-- java.util.Enumeration enumerateLink() + + /** + * Method enumerateMap + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateMap() + { + return _mapList.elements(); + } //-- java.util.Enumeration enumerateMap() + + /** + * Method enumerateProperty + * + * + * + * @return Enumeration + */ + public java.util.Enumeration enumerateProperty() + { + return _propertyList.elements(); + } //-- java.util.Enumeration enumerateProperty() + + /** * Note: hashCode() has not been overriden * * @param obj @@ -115,13 +283,45 @@ implements java.io.Serializable } else if (temp._id != null) return false; + if (this._mapList != null) { + if (temp._mapList == null) return false; + else if (!(this._mapList.equals(temp._mapList))) + return false; + } + else if (temp._mapList != null) + return false; + if (this._linkList != null) { + if (temp._linkList == null) return false; + else if (!(this._linkList.equals(temp._linkList))) + return false; + } + else if (temp._linkList != null) + return false; + if (this._propertyList != null) { + if (temp._propertyList == null) return false; + else if (!(this._propertyList.equals(temp._propertyList))) + return false; + } + else if (temp._propertyList != null) + return false; return true; } return false; } //-- boolean equals(java.lang.Object) /** - * Returns the value of field 'accessionId'. + * Returns the value of field 'accessionId'. The field + * 'accessionId' has the following description: TODO: make some + * specification of + * the database + * field from which + * this accessionId + * is taken from - + * should that be a + * special property + * of the dbRef + * object ? + * * * @return String * @return the value of field 'accessionId'. @@ -132,7 +332,11 @@ implements java.io.Serializable } //-- java.lang.String getAccessionId() /** - * Returns the value of field 'id'. + * Returns the value of field 'id'. The field 'id' has the + * following description: Primary Key for + * vamsas object + * referencing + * * * @return String * @return the value of field 'id'. @@ -143,7 +347,162 @@ implements java.io.Serializable } //-- java.lang.String getId() /** - * Returns the value of field 'source'. + * Method getLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link getLink(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("getLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + + return (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } //-- org.vamsas.objects.core.Link getLink(int) + + /** + * Method getLink + * + * + * + * @return Link + */ + public org.vamsas.objects.core.Link[] getLink() + { + int size = _linkList.size(); + org.vamsas.objects.core.Link[] mArray = new org.vamsas.objects.core.Link[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Link) _linkList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Link[] getLink() + + /** + * Method getLinkCount + * + * + * + * @return int + */ + public int getLinkCount() + { + return _linkList.size(); + } //-- int getLinkCount() + + /** + * Method getMap + * + * + * + * @param index + * @return Map + */ + public org.vamsas.objects.core.Map getMap(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mapList.size())) { + throw new IndexOutOfBoundsException("getMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]"); + } + + return (org.vamsas.objects.core.Map) _mapList.elementAt(index); + } //-- org.vamsas.objects.core.Map getMap(int) + + /** + * Method getMap + * + * + * + * @return Map + */ + public org.vamsas.objects.core.Map[] getMap() + { + int size = _mapList.size(); + org.vamsas.objects.core.Map[] mArray = new org.vamsas.objects.core.Map[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Map) _mapList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Map[] getMap() + + /** + * Method getMapCount + * + * + * + * @return int + */ + public int getMapCount() + { + return _mapList.size(); + } //-- int getMapCount() + + /** + * Method getProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property getProperty(int index) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("getProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + + return (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } //-- org.vamsas.objects.core.Property getProperty(int) + + /** + * Method getProperty + * + * + * + * @return Property + */ + public org.vamsas.objects.core.Property[] getProperty() + { + int size = _propertyList.size(); + org.vamsas.objects.core.Property[] mArray = new org.vamsas.objects.core.Property[size]; + for (int index = 0; index < size; index++) { + mArray[index] = (org.vamsas.objects.core.Property) _propertyList.elementAt(index); + } + return mArray; + } //-- org.vamsas.objects.core.Property[] getProperty() + + /** + * Method getPropertyCount + * + * + * + * @return int + */ + public int getPropertyCount() + { + return _propertyList.size(); + } //-- int getPropertyCount() + + /** + * Returns the value of field 'source'. The field 'source' has + * the following description: TODO Database + * Naming + * Convention: + * either start + * using LSID (so + * change type to + * URI) or leave + * this as an + * uncontrolled/unspecified + * string ID + * * * @return String * @return the value of field 'source'. @@ -154,7 +513,10 @@ implements java.io.Serializable } //-- java.lang.String getSource() /** - * Returns the value of field 'version'. + * Returns the value of field 'version'. The field 'version' + * has the following description: Version must be + * specified - + * * * @return String * @return the value of field 'version'. @@ -211,7 +573,90 @@ implements java.io.Serializable } //-- void marshal(org.xml.sax.ContentHandler) /** - * Sets the value of field 'accessionId'. + * Method removeAllLink + * + */ + public void removeAllLink() + { + _linkList.removeAllElements(); + } //-- void removeAllLink() + + /** + * Method removeAllMap + * + */ + public void removeAllMap() + { + _mapList.removeAllElements(); + } //-- void removeAllMap() + + /** + * Method removeAllProperty + * + */ + public void removeAllProperty() + { + _propertyList.removeAllElements(); + } //-- void removeAllProperty() + + /** + * Method removeLink + * + * + * + * @param index + * @return Link + */ + public org.vamsas.objects.core.Link removeLink(int index) + { + java.lang.Object obj = _linkList.elementAt(index); + _linkList.removeElementAt(index); + return (org.vamsas.objects.core.Link) obj; + } //-- org.vamsas.objects.core.Link removeLink(int) + + /** + * Method removeMap + * + * + * + * @param index + * @return Map + */ + public org.vamsas.objects.core.Map removeMap(int index) + { + java.lang.Object obj = _mapList.elementAt(index); + _mapList.removeElementAt(index); + return (org.vamsas.objects.core.Map) obj; + } //-- org.vamsas.objects.core.Map removeMap(int) + + /** + * Method removeProperty + * + * + * + * @param index + * @return Property + */ + public org.vamsas.objects.core.Property removeProperty(int index) + { + java.lang.Object obj = _propertyList.elementAt(index); + _propertyList.removeElementAt(index); + return (org.vamsas.objects.core.Property) obj; + } //-- org.vamsas.objects.core.Property removeProperty(int) + + /** + * Sets the value of field 'accessionId'. The field + * 'accessionId' has the following description: TODO: make some + * specification of + * the database + * field from which + * this accessionId + * is taken from - + * should that be a + * special property + * of the dbRef + * object ? + * * * @param accessionId the value of field 'accessionId'. */ @@ -221,7 +666,11 @@ implements java.io.Serializable } //-- void setAccessionId(java.lang.String) /** - * Sets the value of field 'id'. + * Sets the value of field 'id'. The field 'id' has the + * following description: Primary Key for + * vamsas object + * referencing + * * * @param id the value of field 'id'. */ @@ -231,7 +680,120 @@ implements java.io.Serializable } //-- void setId(java.lang.String) /** - * Sets the value of field 'source'. + * Method setLink + * + * + * + * @param index + * @param vLink + */ + public void setLink(int index, org.vamsas.objects.core.Link vLink) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _linkList.size())) { + throw new IndexOutOfBoundsException("setLink: Index value '"+index+"' not in range [0.."+_linkList.size()+ "]"); + } + _linkList.setElementAt(vLink, index); + } //-- void setLink(int, org.vamsas.objects.core.Link) + + /** + * Method setLink + * + * + * + * @param linkArray + */ + public void setLink(org.vamsas.objects.core.Link[] linkArray) + { + //-- copy array + _linkList.removeAllElements(); + for (int i = 0; i < linkArray.length; i++) { + _linkList.addElement(linkArray[i]); + } + } //-- void setLink(org.vamsas.objects.core.Link) + + /** + * Method setMap + * + * + * + * @param index + * @param vMap + */ + public void setMap(int index, org.vamsas.objects.core.Map vMap) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _mapList.size())) { + throw new IndexOutOfBoundsException("setMap: Index value '"+index+"' not in range [0.."+_mapList.size()+ "]"); + } + _mapList.setElementAt(vMap, index); + } //-- void setMap(int, org.vamsas.objects.core.Map) + + /** + * Method setMap + * + * + * + * @param mapArray + */ + public void setMap(org.vamsas.objects.core.Map[] mapArray) + { + //-- copy array + _mapList.removeAllElements(); + for (int i = 0; i < mapArray.length; i++) { + _mapList.addElement(mapArray[i]); + } + } //-- void setMap(org.vamsas.objects.core.Map) + + /** + * Method setProperty + * + * + * + * @param index + * @param vProperty + */ + public void setProperty(int index, org.vamsas.objects.core.Property vProperty) + throws java.lang.IndexOutOfBoundsException + { + //-- check bounds for index + if ((index < 0) || (index > _propertyList.size())) { + throw new IndexOutOfBoundsException("setProperty: Index value '"+index+"' not in range [0.."+_propertyList.size()+ "]"); + } + _propertyList.setElementAt(vProperty, index); + } //-- void setProperty(int, org.vamsas.objects.core.Property) + + /** + * Method setProperty + * + * + * + * @param propertyArray + */ + public void setProperty(org.vamsas.objects.core.Property[] propertyArray) + { + //-- copy array + _propertyList.removeAllElements(); + for (int i = 0; i < propertyArray.length; i++) { + _propertyList.addElement(propertyArray[i]); + } + } //-- void setProperty(org.vamsas.objects.core.Property) + + /** + * Sets the value of field 'source'. The field 'source' has the + * following description: TODO Database + * Naming + * Convention: + * either start + * using LSID (so + * change type to + * URI) or leave + * this as an + * uncontrolled/unspecified + * string ID + * * * @param source the value of field 'source'. */ @@ -241,7 +803,10 @@ implements java.io.Serializable } //-- void setSource(java.lang.String) /** - * Sets the value of field 'version'. + * Sets the value of field 'version'. The field 'version' has + * the following description: Version must be + * specified - + * * * @param version the value of field 'version'. */