Search in sources :

Example 1 with StaticPItem

use of org.nutz.dao.impl.sql.pojo.StaticPItem in project nutz by nutzam.

the class NutSql method setSourceSql.

public void setSourceSql(String sql) {
    this.sourceSql = sql;
    SqlLiteral literal = literal();
    this.varIndex = literal.getVarIndexes();
    this.paramIndex = literal.getParamIndexes();
    if (getSqlType() == null)
        setSqlType(literal.getType());
    String[] ss = literal.stack.cloneChain();
    PItem[] tmp = new PItem[ss.length];
    for (String var : varIndex.getOrders()) {
        int[] is = varIndex.indexesOf(var);
        if (is != null) {
            for (int i : is) {
                tmp[i] = new SqlVarPItem(var);
            }
        }
    }
    for (String param : paramIndex.getOrders()) {
        int[] is = paramIndex.indexesOf(param);
        if (is != null) {
            for (int i : is) {
                tmp[i] = new SqlParamPItem(param);
            }
        }
    }
    for (int i = 0; i < tmp.length; i++) {
        if (tmp[i] == null) {
            tmp[i] = new StaticPItem(ss[i], true);
        }
    }
    this.items = Arrays.asList(tmp);
}
Also used : AbstractPItem(org.nutz.dao.impl.sql.pojo.AbstractPItem) StaticPItem(org.nutz.dao.impl.sql.pojo.StaticPItem) PItem(org.nutz.dao.sql.PItem) StaticPItem(org.nutz.dao.impl.sql.pojo.StaticPItem)

Aggregations

AbstractPItem (org.nutz.dao.impl.sql.pojo.AbstractPItem)1 StaticPItem (org.nutz.dao.impl.sql.pojo.StaticPItem)1 PItem (org.nutz.dao.sql.PItem)1