[Swift-commit] r7323 - in trunk/src/org/griphyn/vdl/mapping: . file

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Mon Nov 25 02:01:58 CST 2013


Author: hategan
Date: 2013-11-25 02:01:57 -0600 (Mon, 25 Nov 2013)
New Revision: 7323

Modified:
   trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java
   trunk/src/org/griphyn/vdl/mapping/file/AbstractFileMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/CSVMapper.params
   trunk/src/org/griphyn/vdl/mapping/file/CSVMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/ExternalMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.java
   trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.params
   trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/MappingParamFileGenerator.java
   trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/SimpleFileMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/SingleFileMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapper.java
   trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapperParams.java
   trunk/src/org/griphyn/vdl/mapping/file/TestMapperParams.java
Log:
fixed a few remaining issues with the latest mapper changes

Modified: trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/MappingParamSet.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -54,11 +54,11 @@
 
     public void unwrapPrimitives() {
     }
-    
+        
     /** 
      * Unwraps objects stored in AbstractDataNodes 
      */
-    public Object unwrap(Object value) {
+    public Object unwrap(Object value, Class<?> expected) {
         if (value instanceof AbstractDataNode) {
             AbstractDataNode handle = (AbstractDataNode) value;
             /*
@@ -71,7 +71,14 @@
             if (!handle.isPrimitive()) {
                 throw new IllegalArgumentException("Cannot unwrap non-primitive data");
             }
-            return handle.getValue();
+            Object x = handle.getValue();
+            if (expected == Boolean.class && x instanceof String) {
+                x = Boolean.parseBoolean((String) x);
+            }
+            else if (expected == Integer.class && x instanceof String) {
+                x = Integer.parseInt((String) x);
+            }
+            return x;
         }
         else {
             return value;

Modified: trunk/src/org/griphyn/vdl/mapping/file/AbstractFileMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/AbstractFileMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/AbstractFileMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -103,10 +103,10 @@
 
 	@Override
 	public void unwrapPrimitives() {
-		prefix = unwrap(prefix);
-		suffix = unwrap(suffix);
-		pattern = unwrap(pattern);
-		location = unwrap(location);
+		prefix = unwrap(prefix, String.class);
+		suffix = unwrap(suffix, String.class);
+		pattern = unwrap(pattern, String.class);
+		location = unwrap(location, String.class);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/CSVMapper.params
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/CSVMapper.params	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/CSVMapper.params	2013-11-25 08:01:57 UTC (rev 7323)
@@ -1,6 +1,6 @@
 @import org.griphyn.vdl.mapping.DSHandle
 DSHandle file = null
-Boolean header = false
+Boolean header = true
 Integer skip = 0
 String hdelim = null
 String delim  = " \t,"

Modified: trunk/src/org/griphyn/vdl/mapping/file/CSVMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/CSVMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/CSVMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -13,7 +13,7 @@
 	public static final List<String> NAMES = Arrays.asList("file", "header", "skip", "hdelim", "delim");
 
 	private Object file = null;
-	private Object header = false;
+	private Object header = true;
 	private Object skip = 0;
 	private Object hdelim = null;
 	private Object delim = " \t,";
@@ -120,10 +120,10 @@
 
 	@Override
 	public void unwrapPrimitives() {
-		header = unwrap(header);
-		skip = unwrap(skip);
-		hdelim = unwrap(hdelim);
-		delim = unwrap(delim);
+		header = unwrap(header, Boolean.class);
+		skip = unwrap(skip, Integer.class);
+		hdelim = unwrap(hdelim, String.class);
+		delim = unwrap(delim, String.class);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/ExternalMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/ExternalMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/ExternalMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -68,9 +68,9 @@
 	}
 	@Override
 	public void unwrapPrimitives() {
-		exec = unwrap(exec);
+		exec = unwrap(exec, String.class);
 		for (Map.Entry<String, Object> e : other.entrySet()) {
-		    e.setValue(unwrap(e.getValue()));
+		    e.setValue(unwrap(e.getValue(), String.class));
 		}
 		super.unwrapPrimitives();
 	}

Modified: trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -58,7 +58,7 @@
 	public void initialize(RootHandle root) {
 		super.initialize(root);
 		FixedArrayFileMapperParams cp = getParams();
-		DSHandle files = (DSHandle) cp.getFiles();
+		DSHandle files = cp.getFiles();
 		if (files.getType().isArray() && Types.STRING.equals(files.getType().itemType())) {
 		    int i = 0;
 		    Collection<DSHandle> a = files.getArrayValue().values();

Modified: trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.params
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.params	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapper.params	2013-11-25 08:01:57 UTC (rev 7323)
@@ -1 +1,2 @@
-Object files
\ No newline at end of file
+ at import org.griphyn.vdl.mapping.DSHandle
+DSHandle files
\ No newline at end of file

Modified: trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/FixedArrayFileMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -5,6 +5,7 @@
 import java.util.List;
 import org.griphyn.vdl.mapping.AbstractDataNode;
 import org.griphyn.vdl.mapping.MappingParamSet;
+import org.griphyn.vdl.mapping.DSHandle;
 
 
 public class FixedArrayFileMapperParams extends MappingParamSet {
@@ -18,12 +19,12 @@
 		return NAMES;
 	}
 
-	public void setFiles(Object files) {
+	public void setFiles(DSHandle files) {
 		this.files = files;
 	}
 
-	public Object getFiles() {
-		return files;
+	public DSHandle getFiles() {
+		return (DSHandle) files;
 	}
 
 	@Override
@@ -58,7 +59,6 @@
 		if (files == null) {
 			throw new IllegalArgumentException("Missing required argument 'files'");
 		}
-		files = unwrap(files);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/MappingParamFileGenerator.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/MappingParamFileGenerator.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/MappingParamFileGenerator.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -245,7 +245,7 @@
                     bw.write("\t\t}\n");
                 }
                 if (!p.type.equals("DSHandle")) {
-                    bw.write(String.format("\t\t%s = unwrap(%s);\n", p.name, p.name));
+                    bw.write(String.format("\t\t%s = unwrap(%s, %s.class);\n", p.name, p.name, p.type));
                 }
             }
         }

Modified: trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/RegularExpressionMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -94,8 +94,8 @@
 		if (match == null) {
 			throw new IllegalArgumentException("Missing required argument 'match'");
 		}
-		match = unwrap(match);
-		transform = unwrap(transform);
+		match = unwrap(match, String.class);
+		transform = unwrap(transform, String.class);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/SimpleFileMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/SimpleFileMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/SimpleFileMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -56,7 +56,7 @@
 
 	@Override
 	public void unwrapPrimitives() {
-		padding = unwrap(padding);
+		padding = unwrap(padding, Integer.class);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/SingleFileMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/SingleFileMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/SingleFileMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -56,7 +56,7 @@
 		if (file == null) {
 			throw new IllegalArgumentException("Missing required argument 'file'");
 		}
-		file = new AbsFile((String) unwrap(file));
+		file = new AbsFile((String) unwrap(file, String.class));
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapper.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapper.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapper.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -30,6 +30,7 @@
 import org.griphyn.vdl.mapping.DSHandle;
 import org.griphyn.vdl.mapping.HandleOpenException;
 import org.griphyn.vdl.mapping.InvalidPathException;
+import org.griphyn.vdl.mapping.MappingParamSet;
 import org.griphyn.vdl.mapping.Path;
 import org.griphyn.vdl.mapping.PhysicalFormat;
 
@@ -52,6 +53,11 @@
         return "StructuredRegexpMapper";
     }
 
+    @Override
+    public MappingParamSet newParams() {
+        return new StructuredRegularExpressionMapperParams();
+    }
+
     @Override
 	public Collection<Path> existing() {
 	    StructuredRegularExpressionMapperParams cp = getParams();

Modified: trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/StructuredRegularExpressionMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -94,8 +94,8 @@
 		if (match == null) {
 			throw new IllegalArgumentException("Missing required argument 'match'");
 		}
-		match = unwrap(match);
-		transform = unwrap(transform);
+		match = unwrap(match, String.class);
+		transform = unwrap(transform, String.class);
 		super.unwrapPrimitives();
 	}
 

Modified: trunk/src/org/griphyn/vdl/mapping/file/TestMapperParams.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/file/TestMapperParams.java	2013-11-25 08:00:06 UTC (rev 7322)
+++ trunk/src/org/griphyn/vdl/mapping/file/TestMapperParams.java	2013-11-25 08:01:57 UTC (rev 7323)
@@ -106,10 +106,10 @@
 		if (file == null) {
 			throw new IllegalArgumentException("Missing required argument 'file'");
 		}
-		file = unwrap(file);
-		temp = unwrap(temp);
-		remappable = unwrap(remappable);
-		static_ = unwrap(static_);
+		file = unwrap(file, String.class);
+		temp = unwrap(temp, Boolean.class);
+		remappable = unwrap(remappable, Boolean.class);
+		static_ = unwrap(static_, Boolean.class);
 		super.unwrapPrimitives();
 	}
 




More information about the Swift-commit mailing list