package org.pinae.ndb.common;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * ndb输出重定向
 * 
 * ndb执行结果重定向输出: 文件/网络
 * 
 * @author Huiyugeng
 *
 *
 */
public class NodeRedirect {
	
	@SuppressWarnings("unchecked")
	public void redirect(String redirect, Object result) {
		NodeWriter writer = new NodeWriter();
		
		Map<String, Object> resultMap = null;
		if (result instanceof Map) {
			resultMap = (Map<String, Object>)result;
		} else {
			resultMap = new HashMap<String, Object>();
			resultMap.put("result", result);
		}
		try {
			writer.write(redirect, null, resultMap);
		} catch (IOException e) {
			
		}
	}
}

@@ -270,23 +270,21 @@
 (String 
-redirec
+targe
 t, Objec
@@ -285,22 +285,19 @@
  Object 
-result
+ndb
 ) %7B%0A%09%09No
@@ -381,22 +381,19 @@
 ;%0A%09%09if (
-result
+ndb
  instanc
@@ -439,22 +439,19 @@
 Object%3E)
-result
+ndb
 ;%0A%09%09%7D el
@@ -532,29 +532,138 @@
 t%22, 
-result);%0A%09%09%7D
+ndb);%0A%09%09%7D%0A%09%09%0A%09%09if (target.equalsIgnoreCase(%22print%22)) %7B%0A%09%09%09System.out.println(writer.print(null, resultMap));%0A%09%09%7D else %7B
 %0A%09%09
+%09
 try %7B%0A
+%09
 %09%09%09w
@@ -674,23 +674,21 @@
 r.write(
-redirec
+targe
 t, null,
@@ -700,16 +700,17 @@
 ltMap);%0A
+%09
 %09%09%7D catc
@@ -732,16 +732,22 @@
 e) %7B%0A%09%09%09
+%09%0A%09%09%09%7D
 %0A%09%09%7D%0A%09%7D%0A

Add operate output redirect to screen