@SuppressWarnings("unchecked")
static CompiledClause doCompile(Mapper<?> mapper, String clause) {
Map<String, AccessibleProperty> properties = mapper.allPropertiesMap;
StringBuilder sb = new StringBuilder(clause.length() + 10);
List<AttributeConverter<Object, Object>> list = new ArrayList<>();
int start = 0;
Matcher m = p.matcher(clause.toLowerCase());
while (m.find()) {
sb.append(clause.substring(start, m.start()));
String s = clause.substring(m.start(), m.end());
if (properties.containsKey(s.toLowerCase())) {
AccessibleProperty ap = properties.get(s.toLowerCase());
sb.append(ap.columnName);
list.add(ap.converter);
} else {
if (s.toLowerCase().equals("between")) {
list.add(list.get(list.size() - 1));
} else if (s.toLowerCase().equals("null")) {
list.remove(list.size() - 1);
} else {
if (!KEYWORDS.contains(s.toLowerCase())) {
throw new IllegalArgumentException("Invalid string \"" + s + "\" found in clause: " + clause);
}
}
sb.append(s);
}
start = m.end();
}
sb.append(clause.substring(start));
if (list.size() != numOfPlaceholder(clause)) {
throw new IllegalArgumentException("Invalid number of placeholder.");
}
return new CompiledClause(sb.toString(), list.toArray(new AttributeConverter[0]));
}
Where.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:warpdb
作者:
评论列表
文章目录