cool.scx.jdbc.sql.NamedParameterSQL Maven / Gradle / Ivy
package cool.scx.jdbc.sql;
import cool.scx.jdbc.dialect.Dialect;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
/**
* 具名参数 cool.scx.sql
*
* @author scx567888
* @version 0.0.1
*/
final class NamedParameterSQL implements SQL {
/**
* 具名参数匹配的正则表达式
*/
private static final Pattern NAMED_PARAMETER_PATTERN = Pattern.compile(":([\\w.-]+)");
/**
* 具名参数名称索引
*/
private final String[] namedParameterNameIndex;
/**
* a
*/
private final PlaceholderSQL placeholderSQL;
/**
* a
*
* @param namedParameterSQL a
* @param params a
*/
public NamedParameterSQL(String namedParameterSQL, Map params) {
var t = initNamedParameterNameIndex(namedParameterSQL);
var normalSQL = t.normalSQL();
this.namedParameterNameIndex = t.namedParameterNameIndex();
this.placeholderSQL = new PlaceholderSQL(normalSQL, mapToArray(params));
}
/**
* a
*
* @param namedParameterSQL a
* @param batchParams a
*/
public NamedParameterSQL(String namedParameterSQL, List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy