package org.nutz.mvc.view;

import org.nutz.ioc.Ioc;
import org.nutz.json.Json;
import org.nutz.json.JsonFormat;
import org.nutz.lang.Strings;
import org.nutz.mvc.View;
import org.nutz.mvc.ViewMaker;

/**
 * 默认的的视图工厂类
 * 
 * @author zozoh(zozohtnt@gmail.com)
 */
public class DefaultViewMaker implements ViewMaker {

	public View make(Ioc ioc, String type, String value) {
		if (type.equals("jsp")) {
			return new JspView(value);
		} else if (type.equals("json")) {
			if (Strings.isBlank(value)) {
				return new UTF8JsonView(JsonFormat.compact());
			} else {
				JsonFormat format = Json.fromJson(JsonFormat.class, value);
				return new UTF8JsonView(format);
			}
		} else if (type.equals("redirect") || type.equals("=>")) {
			return new ServerRedirectView(value);
		} else if (type.equals("void")) {
			return new VoidView();
		} else if (type.equals("ioc")) {
			return ioc.get(View.class, value);
		} else if (type.equals("http")) {
			int sc = Integer.parseInt(value);
			return new HttpStatusView(sc);
		}
		return null;
	}

}

@@ -741,17 +741,17 @@
 equals(%22
-=
+%3E
 %3E%22)) %7B%0D%0A

change redirect alias from "=>" to ">>"