0 to unbounded Dataset/Sequence/DbRef/Map elements. Allows alternate mappings between...
authorjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 29 Jun 2007 12:23:12 +0000 (12:23 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Fri, 29 Jun 2007 12:23:12 +0000 (12:23 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@424 be28352e-c001-0410-b1a7-c7978e42abec

schemas/vamsas.xsd
src/uk/ac/vamsas/objects/core/.castor.cdr
src/uk/ac/vamsas/objects/core/DbRef.java
src/uk/ac/vamsas/objects/core/descriptors/DbRefDescriptor.java

index 946b609..80f5d91 100644 (file)
                                                                                <xs:complexType>
                                                                                        <xs:sequence>
                                                                                                <xs:element name="map" minOccurs="0"
-                                                                                               maxOccurs="1">
+                                                                                               maxOccurs="unbounded">
                                                                                                <xs:annotation>
                                                                                                <xs:documentation>
                                                                                                        the local mapType maps from the parent
index 6847de4..ed2e77c 100644 (file)
@@ -1,4 +1,4 @@
-#Thu Jun 21 15:41:21 BST 2007\r
+#Thu Jun 28 21:34:58 BST 2007\r
 uk.ac.vamsas.objects.core.Vref=uk.ac.vamsas.objects.core.descriptors.VrefDescriptor\r
 uk.ac.vamsas.objects.core.ReferenceType=uk.ac.vamsas.objects.core.descriptors.ReferenceTypeDescriptor\r
 uk.ac.vamsas.objects.core.SequenceType=uk.ac.vamsas.objects.core.descriptors.SequenceTypeDescriptor\r
index 54dfa2c..7206791 100644 (file)
@@ -73,7 +73,7 @@ implements java.io.Serializable
      *  However, it may be used to avoid ambiguity.
      *  
      */
-    private uk.ac.vamsas.objects.core.Map _map;
+    private java.util.Vector _mapList;
 
     /**
      * Field _linkList.
@@ -92,6 +92,7 @@ implements java.io.Serializable
 
     public DbRef() {
         super();
+        this._mapList = new java.util.Vector();
         this._linkList = new java.util.Vector();
         this._propertyList = new java.util.Vector();
     }
@@ -132,6 +133,34 @@ implements java.io.Serializable
     /**
      * 
      * 
+     * @param vMap
+     * @throws java.lang.IndexOutOfBoundsException if the index
+     * given is outside the bounds of the collection
+     */
+    public void addMap(
+            final uk.ac.vamsas.objects.core.Map vMap)
+    throws java.lang.IndexOutOfBoundsException {
+        this._mapList.addElement(vMap);
+    }
+
+    /**
+     * 
+     * 
+     * @param index
+     * @param vMap
+     * @throws java.lang.IndexOutOfBoundsException if the index
+     * given is outside the bounds of the collection
+     */
+    public void addMap(
+            final int index,
+            final uk.ac.vamsas.objects.core.Map vMap)
+    throws java.lang.IndexOutOfBoundsException {
+        this._mapList.add(index, vMap);
+    }
+
+    /**
+     * 
+     * 
      * @param vProperty
      * @throws java.lang.IndexOutOfBoundsException if the index
      * given is outside the bounds of the collection
@@ -169,6 +198,17 @@ implements java.io.Serializable
     }
 
     /**
+     * Method enumerateMap.
+     * 
+     * @return an Enumeration over all
+     * uk.ac.vamsas.objects.core.Map elements
+     */
+    public java.util.Enumeration enumerateMap(
+    ) {
+        return this._mapList.elements();
+    }
+
+    /**
      * Method enumerateProperty.
      * 
      * @return an Enumeration over all
@@ -286,27 +326,27 @@ implements java.io.Serializable
                 }
             } else if (temp._id != null)
                 return false;
-            if (this._map != null) {
-                if (temp._map == null) return false;
-                if (this._map != temp._map) {
-                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._map);
-                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._map);
+            if (this._mapList != null) {
+                if (temp._mapList == null) return false;
+                if (this._mapList != temp._mapList) {
+                    thcycle=org.castor.util.CycleBreaker.startingToCycle(this._mapList);
+                    tmcycle=org.castor.util.CycleBreaker.startingToCycle(temp._mapList);
                     if (thcycle!=tmcycle) {
-                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._map); };
-                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._map); };
+                        if (!thcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList); };
+                        if (!tmcycle) { org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList); };
                         return false;
                     }
                     if (!thcycle) {
-                        if (!this._map.equals(temp._map)) {
-                            org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
-                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
+                        if (!this._mapList.equals(temp._mapList)) {
+                            org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList);
+                            org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList);
                             return false;
                         }
-                        org.castor.util.CycleBreaker.releaseCycleHandle(this._map);
-                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._map);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(this._mapList);
+                        org.castor.util.CycleBreaker.releaseCycleHandle(temp._mapList);
                     }
                 }
-            } else if (temp._map != null)
+            } else if (temp._mapList != null)
                 return false;
             if (this._linkList != null) {
                 if (temp._linkList == null) return false;
@@ -443,25 +483,60 @@ implements java.io.Serializable
     }
 
     /**
-     * Returns the value of field 'map'. The field 'map' has the
-     * following description: the local mapType maps from the
-     * parent
-     *  sequence coordinate frame to the reference
-     *  frame defined by the dbRef element.
-     *  The mapped mapType is the mapped range defined
-     *  on the dbRef element's reference frame.
-     *  Conventionally, the unit attribute defaults to 1, or
-     *  will be inferred from the local sequence's
-     *  dictionary type and any dictionary type associated
-     *  with the database being mapped to. 
-     *  However, it may be used to avoid ambiguity.
-     *  
+     * Method getMap.
      * 
-     * @return the value of field 'Map'.
+     * @param index
+     * @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.Map at
+     * the given index
      */
     public uk.ac.vamsas.objects.core.Map getMap(
+            final int index)
+    throws java.lang.IndexOutOfBoundsException {
+        // check bounds for index
+        if (index < 0 || index >= this._mapList.size()) {
+            throw new IndexOutOfBoundsException("getMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]");
+        }
+        
+        return (uk.ac.vamsas.objects.core.Map) _mapList.get(index);
+    }
+
+    /**
+     * Method getMap.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 this collection as an Array
+     */
+    public uk.ac.vamsas.objects.core.Map[] getMap(
     ) {
-        return this._map;
+        uk.ac.vamsas.objects.core.Map[] array = new uk.ac.vamsas.objects.core.Map[0];
+        return (uk.ac.vamsas.objects.core.Map[]) this._mapList.toArray(array);
+    }
+
+    /**
+     * Method getMapAsReference.Returns a reference to '_mapList'.
+     * No type checking is performed on any modifications to the
+     * Vector.
+     * 
+     * @return a reference to the Vector backing this class
+     */
+    public java.util.Vector getMapAsReference(
+    ) {
+        return this._mapList;
+    }
+
+    /**
+     * Method getMapCount.
+     * 
+     * @return the size of this collection
+     */
+    public int getMapCount(
+    ) {
+        return this._mapList.size();
     }
 
     /**
@@ -581,10 +656,10 @@ implements java.io.Serializable
            result = 37 * result + _id.hashCode();
            org.castor.util.CycleBreaker.releaseCycleHandle(_id);
         }
-        if (_map != null
-            && !org.castor.util.CycleBreaker.startingToCycle(_map)) {
-           result = 37 * result + _map.hashCode();
-           org.castor.util.CycleBreaker.releaseCycleHandle(_map);
+        if (_mapList != null
+            && !org.castor.util.CycleBreaker.startingToCycle(_mapList)) {
+           result = 37 * result + _mapList.hashCode();
+           org.castor.util.CycleBreaker.releaseCycleHandle(_mapList);
         }
         if (_linkList != null
             && !org.castor.util.CycleBreaker.startingToCycle(_linkList)) {
@@ -656,6 +731,13 @@ implements java.io.Serializable
 
     /**
      */
+    public void removeAllMap(
+    ) {
+        this._mapList.clear();
+    }
+
+    /**
+     */
     public void removeAllProperty(
     ) {
         this._propertyList.clear();
@@ -686,6 +768,30 @@ implements java.io.Serializable
     }
 
     /**
+     * Method removeMap.
+     * 
+     * @param vMap
+     * @return true if the object was removed from the collection.
+     */
+    public boolean removeMap(
+            final uk.ac.vamsas.objects.core.Map vMap) {
+        boolean removed = _mapList.remove(vMap);
+        return removed;
+    }
+
+    /**
+     * Method removeMapAt.
+     * 
+     * @param index
+     * @return the element removed from the collection
+     */
+    public uk.ac.vamsas.objects.core.Map removeMapAt(
+            final int index) {
+        java.lang.Object obj = this._mapList.remove(index);
+        return (uk.ac.vamsas.objects.core.Map) obj;
+    }
+
+    /**
      * Method removeProperty.
      * 
      * @param vProperty
@@ -799,25 +905,64 @@ implements java.io.Serializable
     }
 
     /**
-     * Sets the value of field 'map'. The field 'map' has the
-     * following description: the local mapType maps from the
-     * parent
-     *  sequence coordinate frame to the reference
-     *  frame defined by the dbRef element.
-     *  The mapped mapType is the mapped range defined
-     *  on the dbRef element's reference frame.
-     *  Conventionally, the unit attribute defaults to 1, or
-     *  will be inferred from the local sequence's
-     *  dictionary type and any dictionary type associated
-     *  with the database being mapped to. 
-     *  However, it may be used to avoid ambiguity.
-     *  
      * 
-     * @param map the value of field 'map'.
+     * 
+     * @param index
+     * @param vMap
+     * @throws java.lang.IndexOutOfBoundsException if the index
+     * given is outside the bounds of the collection
      */
     public void setMap(
-            final uk.ac.vamsas.objects.core.Map map) {
-        this._map = map;
+            final int index,
+            final uk.ac.vamsas.objects.core.Map vMap)
+    throws java.lang.IndexOutOfBoundsException {
+        // check bounds for index
+        if (index < 0 || index >= this._mapList.size()) {
+            throw new IndexOutOfBoundsException("setMap: Index value '" + index + "' not in range [0.." + (this._mapList.size() - 1) + "]");
+        }
+        
+        this._mapList.set(index, vMap);
+    }
+
+    /**
+     * 
+     * 
+     * @param vMapArray
+     */
+    public void setMap(
+            final uk.ac.vamsas.objects.core.Map[] vMapArray) {
+        //-- copy array
+        _mapList.clear();
+        
+        for (int i = 0; i < vMapArray.length; i++) {
+                this._mapList.add(vMapArray[i]);
+        }
+    }
+
+    /**
+     * Sets the value of '_mapList' by copying the given Vector.
+     * All elements will be checked for type safety.
+     * 
+     * @param vMapList the Vector to copy.
+     */
+    public void setMap(
+            final java.util.Vector vMapList) {
+        // copy vector
+        this._mapList.clear();
+        
+        this._mapList.addAll(vMapList);
+    }
+
+    /**
+     * Sets the value of '_mapList' by setting it to the given
+     * Vector. No type checking is performed.
+     * @deprecated
+     * 
+     * @param mapVector the Vector to set.
+     */
+    public void setMapAsReference(
+            final java.util.Vector mapVector) {
+        this._mapList = mapVector;
     }
 
     /**
index ef04791..9f13e4f 100644 (file)
@@ -218,8 +218,8 @@ public class DbRefDescriptor extends org.exolab.castor.xml.util.XMLClassDescript
         desc.setValidator(fieldValidator);\r
         //-- initialize element descriptors\r
         \r
-        //-- _map\r
-        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Map.class, "_map", "map", org.exolab.castor.xml.NodeType.Element);\r
+        //-- _mapList\r
+        desc = new org.exolab.castor.xml.util.XMLFieldDescriptorImpl(uk.ac.vamsas.objects.core.Map.class, "_mapList", "map", org.exolab.castor.xml.NodeType.Element);\r
         handler = new org.exolab.castor.xml.XMLFieldHandler() {\r
             public java.lang.Object getValue( java.lang.Object object ) \r
                 throws IllegalStateException\r
@@ -232,7 +232,15 @@ public class DbRefDescriptor extends org.exolab.castor.xml.util.XMLClassDescript
             {\r
                 try {\r
                     DbRef target = (DbRef) object;\r
-                    target.setMap( (uk.ac.vamsas.objects.core.Map) value);\r
+                    target.addMap( (uk.ac.vamsas.objects.core.Map) value);\r
+                } catch (java.lang.Exception ex) {\r
+                    throw new IllegalStateException(ex.toString());\r
+                }\r
+            }\r
+            public void resetValue(Object object) throws IllegalStateException, IllegalArgumentException {\r
+                try {\r
+                    DbRef target = (DbRef) object;\r
+                    target.removeAllMap();\r
                 } catch (java.lang.Exception ex) {\r
                     throw new IllegalStateException(ex.toString());\r
                 }\r
@@ -243,11 +251,12 @@ public class DbRefDescriptor extends org.exolab.castor.xml.util.XMLClassDescript
         };\r
         desc.setHandler(handler);\r
         desc.setNameSpaceURI("http://www.vamsas.ac.uk/schemas/1.0/vamsasTypes");\r
-        desc.setMultivalued(false);\r
+        desc.setMultivalued(true);\r
         addFieldDescriptor(desc);\r
         \r
-        //-- validation code for: _map\r
+        //-- validation code for: _mapList\r
         fieldValidator = new org.exolab.castor.xml.FieldValidator();\r
+        fieldValidator.setMinOccurs(0);\r
         { //-- local scope\r
         }\r
         desc.setValidator(fieldValidator);\r