[Swift-commit] r7171 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Wed Oct 16 14:28:24 CDT 2013


Author: hategan
Date: 2013-10-16 14:28:24 -0500 (Wed, 16 Oct 2013)
New Revision: 7171

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
Log:
fixed assumption that keys are strings representing integers in writeData() (bug 1107)(trunk version)

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java	2013-10-16 19:26:06 UTC (rev 7170)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java	2013-10-16 19:28:24 UTC (rev 7171)
@@ -21,7 +21,6 @@
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.Comparator;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -135,7 +134,7 @@
 			ExecutionException {
 	    // this scheme currently only works properly if the keys are strings
 		Map<Comparable<?>, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
-		Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>(new ArrayIndexComparator());
+		Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>();
 		c.putAll(m);
 		for (DSHandle h : c.values()) {
 			br.write(h.getValue().toString());
@@ -147,7 +146,7 @@
 			ExecutionException {
 		writeStructHeader(src.getType().itemType(), br);
 		Map<Comparable<?>, DSHandle> m = ((AbstractDataNode) src).getArrayValue();
-		Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>(new ArrayIndexComparator());
+		Map<Comparable<?>, DSHandle> c = new TreeMap<Comparable<?>, DSHandle>();
 		c.putAll(m);
 		for (DSHandle h : c.values()) {
 			writeStruct(br, h);
@@ -176,14 +175,4 @@
 			throw new ExecutionException("Unexpectedly invalid path", e);
 		}
 	}
-
-	class ArrayIndexComparator implements Comparator<Comparable<?>> {
-		public int compare(Comparable<?> o1, Comparable<?> o2) {
-			int i1 = Integer.parseInt(String.valueOf(o1));
-			int i2 = Integer.parseInt(String.valueOf(o2));
-			if(i1 < i2) return -1;
-			if(i1 > i2) return 1;
-			return 0;
-		}
-	}
 }




More information about the Swift-commit mailing list