[MOBY-guts] biomoby commit

Martin Senger senger at pub.open-bio.org
Sat Sep 24 17:51:52 UTC 2005


senger
Sat Sep 24 13:51:51 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv30711/src/main/org/biomoby/client

Modified Files:
	CentralDigestCachedImpl.java CentralImpl.java 
Log Message:


moby-live/Java/src/main/org/biomoby/client CentralDigestCachedImpl.java,1.7,1.8 CentralImpl.java,1.27,1.28
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/09/22 16:07:08	1.7
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedImpl.java	2005/09/24 17:51:51	1.8
@@ -16,6 +16,8 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Vector;
+import java.util.Arrays;
+import java.util.Comparator;
 
 import org.biomoby.shared.CentralAll;
 import org.biomoby.shared.MobyDataType;
@@ -413,6 +415,7 @@
 	    File[] list = dataTypesCache.listFiles();
 	    if (list == null)
 		throw new MobyException (MSG_CACHE_NOT_DIR (dataTypesCache));
+	    Arrays.sort (list, getFileComparator());
 
 	    for (int i = 0; i < list.length; i++) {
 		try {
@@ -463,6 +466,7 @@
 	    File[] list = servicesCache.listFiles();
 	    if (list == null)
 		throw new MobyException (MSG_CACHE_NOT_DIR (servicesCache));
+	    Arrays.sort (list, getFileComparator());
 	    for (int i = 0; i < list.length; i++) {
 		try {
 		    if (ignored (list[i])) continue;
@@ -550,6 +554,17 @@
     }
 
     /**************************************************************************
+     * Return a comparator for Files that compares in case-insensitive way.
+     *************************************************************************/
+    protected static Comparator getFileComparator() {
+	return new Comparator() {
+		public int compare (Object o1, Object o2) {
+		    return o1.toString().compareToIgnoreCase (o2.toString());
+		}
+	    };
+    }
+
+    /**************************************************************************
      * Some file (when being read from a cache directory) are ignored.
      *************************************************************************/
     protected static boolean ignored (File file) {

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/09/22 16:07:09	1.27
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java	2005/09/24 17:51:51	1.28
@@ -49,6 +49,8 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Vector;
+import java.util.TreeMap;
+import java.util.Comparator;
 
 /**
  * A default implementation of the
@@ -664,7 +666,7 @@
 					new Object[] {});
 
 	// parse returned XML
-	Map results = new HashMap();
+	Map results = new TreeMap (getStringComparator());
 	Document document = null;
 	try {
 	    document = docBuilder.parse(new ByteArrayInputStream(result.getBytes()));
@@ -710,7 +712,7 @@
 	throws MobyException {
 
 	// parse returned XML
-	Map results = new HashMap();
+	Map results = new TreeMap (getStringComparator());
 	Document document = null;
 	try {
 	    document = docBuilder.parse (new ByteArrayInputStream (result.getBytes()));
@@ -810,7 +812,7 @@
 	throws MobyException {
 
 	// parse returned XML
-	Map results = new HashMap();
+	Map results = new TreeMap (getStringComparator());
 	Document document = null;
 	try {
 	    document = docBuilder.parse(new ByteArrayInputStream(result.getBytes()));}
@@ -862,7 +864,7 @@
 	throws MobyException {
 
 	// parse returned XML
-	Map results = new HashMap();
+	Map results = new TreeMap (getStringComparator());
 	Document document = null;
 	try {
 	    document = docBuilder.parse(new ByteArrayInputStream(result.getBytes()));
@@ -924,7 +926,7 @@
 	throws MobyException {
 
 	// parse returned XML
-	Map results = new HashMap();
+	Map results = new TreeMap (getStringComparator());
 	Document document = null;
 	try {
 	    document = docBuilder.parse(new ByteArrayInputStream(result.getBytes()));
@@ -944,7 +946,6 @@
 		}
 	    }
 	}
-
 	return results;
     }
 
@@ -1711,4 +1712,16 @@
 	}
 	throw new MobyException ("No resource found for '" + resourceName + "'.");
     }
+
+    /**************************************************************************
+     * Return a case-insensitive comparator of Strings. It is used to
+     * create various TreeMaps where keys are strings.
+     *************************************************************************/
+    protected static Comparator getStringComparator() {
+	return new Comparator() {
+		public int compare (Object o1, Object o2) {
+		    return ((String)o1).compareToIgnoreCase ((String)o2);
+		}
+	    };
+    }
 }




More information about the MOBY-guts mailing list