All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nutz.plugins.sqltpl.VarSetMap Maven / Gradle / Ivy

There is a newer version: 1.r.69.v20220215
Show newest version
package org.nutz.plugins.sqltpl;

import java.util.HashMap;
import java.util.Map;

import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.VarSet;

public class VarSetMap {
    
    protected static Map global;
    
    public static void setGlobal(Map global) {
        VarSetMap.global = global;
    }
    
    public static Map asMap(VarSet vars) {
        Map map = new HashMap();
        for (String key : vars.keys()) {
            map.put(key, vars.get(key));
        }
        return map;
    }
    
    public static Map asCtx(Sql sql) {
        Map params = VarSetMap.asMap(sql.params());
        Map ctx = new HashMap();
        if (global != null) {
            ctx.putAll(global);
        }
        ctx.putAll(params);
        ctx.put("params", params);
        ctx.put("vars", VarSetMap.asMap(sql.vars()));
        return ctx;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy