[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Dec 6 16:45:20 UTC 2007


gordonp
Thu Dec  6 11:45:19 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data
In directory dev.open-bio.org:/tmp/cvs-serv25174/src/main/org/biomoby/shared/data

Modified Files:
	MobyDataObjectSetSAI.java MobyDataObjectSet.java 
Log Message:
Added typechecking
moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSetSAI.java,1.2,1.3 MobyDataObjectSet.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java	2006/12/11 18:58:58	1.2
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java	2007/12/06 16:45:19	1.3
@@ -127,7 +127,7 @@
 	return dataInstance.isEmpty();
     }
 
-    public Iterator iterator(){
+    public Iterator<org.biomoby.shared.data.MobyDataObject> iterator(){
 	return dataInstance.iterator();
     }
 
@@ -147,7 +147,7 @@
 	return dataInstance.toArray();
     }
 
-    public Object[] toArray(Object[] classArray) throws ArrayStoreException, NullPointerException{
+    public <T extends Object>T[] toArray(T[] classArray) throws ArrayStoreException, NullPointerException{
 	return dataInstance.toArray(classArray);
     }
 

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java	2007/07/27 21:45:13	1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java	2007/12/06 16:45:19	1.10
@@ -36,13 +36,17 @@
 
     }
     
-    public static Collection getChildren(org.w3c.dom.Element e, Registry registry) throws MobyException{
-	Vector members = new Vector();
+    public static Collection<? extends MobyDataObject> getChildren(org.w3c.dom.Element e, Registry registry) throws MobyException{
+	Vector<MobyDataObject> members = new Vector<MobyDataObject>();
 
 	org.w3c.dom.NodeList children = MobyPrefixResolver.getChildElements(e, "*");  // wildcard
 	int numChildren = children.getLength();
 	for(int i = 0; i < numChildren; i++){
-	    members.add(MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i), registry));
+	    MobyDataInstance mdi = MobyDataObject.createInstanceFromDOM((org.w3c.dom.Element) children.item(i), 
+                                                                        registry);
+            if(mdi instanceof MobyDataObject){
+               members.add((MobyDataObject) mdi);
+            }
 	}
 	return members;
     }
@@ -73,7 +77,7 @@
      * @throws ClassCastException if a member of the input collection is not a MobyDataObject
      * @throws NullPointerException if the collection or one of its members is a null object
      */
-    public MobyDataObjectSet(String name, Collection c) throws ClassCastException, NullPointerException{
+    public MobyDataObjectSet(String name, Collection<? extends MobyDataObject> c) throws ClassCastException, NullPointerException{
 	this(name);
 	addAll(c);
     }
@@ -142,12 +146,12 @@
      * properly implemented for proper set intersection functionality.
      *************************************************************************/
     public MobyNamespace[] getNamespaces() {
-	Vector namespaces = new Vector();
+	Vector<MobyNamespace> namespaces = new Vector<MobyNamespace>();
 	boolean first = true;
 	synchronized (bag) {
 	    for (MobyDataObject member: bag){
 		MobyNamespace[]	nsInstances = member.getNamespaces();
-		Vector newNames = new Vector();
+		Vector<MobyNamespace> newNames = new Vector<MobyNamespace>();
 		for(int i = 0; nsInstances != null && i < nsInstances.length; i++){
 		    newNames.add(nsInstances[i]);
 		}
@@ -384,12 +388,12 @@
 
 	MobyDataObject[] inputMdsis = (MobyDataObject[]) ((Collection) set).toArray();
 	Arrays.sort(inputMdsis);
-	Vector sortedInput = new Vector();
+	Vector<MobyDataObject> sortedInput = new Vector<MobyDataObject>();
 	for(int i = 0; i < inputMdsis.length; i++){
 	    sortedInput.add(inputMdsis[i]);
 	}	
 
-	return bag.equals(new Vector(sortedInput));
+	return bag.equals(sortedInput);
     }
 	
     /**
@@ -477,7 +481,7 @@
      * collection elements are of a particular MOBY primitive subtype.  Otherwise
      * an ArrayStoreException will be thrown.
      */
-    public Object[] toArray(Object[] classArray) throws ArrayStoreException, NullPointerException{
+    public <T extends Object>T[] toArray(T[] classArray) throws ArrayStoreException, NullPointerException{
 	return bag.toArray(classArray);
     }
     




More information about the MOBY-guts mailing list