[Swift-commit] r4473 - in trunk/src/org/griphyn/vdl: karajan/lib karajan/lib/swiftscript mapping

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Fri May 13 18:12:32 CDT 2011


Author: hategan
Date: 2011-05-13 18:12:32 -0500 (Fri, 13 May 2011)
New Revision: 4473

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
   trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
   trunk/src/org/griphyn/vdl/mapping/MappingParam.java
Log:
nicer representation of data in toString()

Modified: trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java	2011-05-13 23:11:48 UTC (rev 4472)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SwiftArg.java	2011-05-13 23:12:32 UTC (rev 4473)
@@ -22,7 +22,7 @@
 
 public abstract class SwiftArg extends Arg {
 	public static final Logger logger = Logger.getLogger(SwiftArg.class);
-
+	
 	public SwiftArg(String name, int index) {
 		super(name, index);
 	}

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-05-13 23:11:48 UTC (rev 4472)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java	2011-05-13 23:12:32 UTC (rev 4473)
@@ -65,22 +65,27 @@
 		for (int i = 0; i < args.length; i++) {
 			DSHandle handle = args[i];
 			VDLFunction.waitFor(stack, handle);
-			if(i!=0) buf.append(", ");
+			if (i != 0) {
+			    buf.append(", ");
+			}
 			buf.append(args[i]);
 		}
 		traceLogger.warn(buf);
 		return null;
 	}
 
-	public DSHandle swiftscript_strcat(VariableStack stack)
-	throws ExecutionException {
-	    logger.debug(stack);
+	public DSHandle swiftscript_strcat(VariableStack stack) throws ExecutionException {
+	    if (logger.isDebugEnabled()) {
+	        logger.debug(stack);
+	    }
 		Object[] args = SwiftArg.VARGS.asArray(stack);
 		int provid = VDLFunction.nextProvenanceID();
 		StringBuffer buf = new StringBuffer();
+		
 		for (int i = 0; i < args.length; i++) {
 			buf.append(TypeUtil.toString(args[i]));
 		}
+		
 		DSHandle handle = new RootDataNode(Types.STRING);
 		handle.setValue(buf.toString());
 		handle.closeShallow();

Modified: trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2011-05-13 23:11:48 UTC (rev 4472)
+++ trunk/src/org/griphyn/vdl/mapping/AbstractDataNode.java	2011-05-13 23:12:32 UTC (rev 4473)
@@ -85,24 +85,36 @@
      * text description.
      */
     public String toString() {
-        if (this.value != null && !(this.value instanceof Exception)) {
-            // special handling for ints...
-            if (this.getType().equals(Types.INT)) {
-                try {
-                    Number n = (Number) this.getValue();
-                    return String.valueOf(n.intValue());
-                }
-                catch (ClassCastException e) {
-                    throw new RuntimeException(
-                        "Internal type error. Value is not a Number for "
-                        + getDisplayableName() + getPathFromRoot());
-                }
-            }
-            else {
-                return this.value.toString();
-            }
+        return toDisplayableString();
+    }
+
+    private String toDisplayableString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getDisplayableName());
+        Path p = getPathFromRoot();
+        if (!p.isEmpty()) {
+            sb.append(".");
+            sb.append(p.toString());
         }
-        return getIdentifyingString();
+        sb.append(":");
+        sb.append(getType());
+        sb.append(" = ");
+        if (value == null) {
+            sb.append("?");
+        }
+        else if (value instanceof Throwable) {
+            sb.append(value.getClass().getName());
+        }
+        else {
+            sb.append(value);
+        }
+        if (closed) {
+            sb.append(" - Closed");
+        }
+        else {
+            sb.append(" - Open");
+        }
+        return sb.toString();
     }
 
     public String getIdentifyingString() {
@@ -152,7 +164,7 @@
             prefix = getRoot().getParam("prefix");
         }
         if (prefix == null) {
-            prefix = "unnamed SwiftScript value";
+            prefix = "?";
         }
         return prefix;
     }

Modified: trunk/src/org/griphyn/vdl/mapping/MappingParam.java
===================================================================
--- trunk/src/org/griphyn/vdl/mapping/MappingParam.java	2011-05-13 23:11:48 UTC (rev 4472)
+++ trunk/src/org/griphyn/vdl/mapping/MappingParam.java	2011-05-13 23:12:32 UTC (rev 4473)
@@ -44,7 +44,7 @@
 		if (value instanceof DSHandle) {
 			DSHandle handle = (DSHandle) value;
 			checkHandle(handle);
-			return handle.toString();
+			return handle.getValue().toString();
 		}
 		else if (value == null) {
 			if (!defSet) {
@@ -65,7 +65,7 @@
         if (value instanceof DSHandle) {
             DSHandle handle = (DSHandle) value;
             checkHandle(handle);
-            return handle.toString();
+            return handle.getValue().toString();
         }
         else if (value == null) {
             if (!defSet) {
@@ -102,15 +102,17 @@
 	    converted to a String as appropriate. */
 	public String getStringValue(Mapper mapper) {
 		Object value = getValue(mapper);
-		if (value == null)
+		if (value == null) {
 			return null;
+		}
 		return String.valueOf(value);
 	}
 	
 	public String getStringValue(Map params) {
         Object value = getValue(params);
-        if (value == null)
+        if (value == null) {
             return null;
+        }
         return String.valueOf(value);
     }
 




More information about the Swift-commit mailing list