Skip to content

Commit

Permalink
优化translate 多代码翻译
Browse files Browse the repository at this point in the history
  • Loading branch information
chenrenfei committed May 28, 2018
1 parent d0d6da0 commit 5ae60e1
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,9 @@ public static HashMap<String, SqlTranslate> parseTranslate(List<Element> transla
String splitRegex = null;
// 对应split重新连接的字符
String linkSign = ",";
boolean hasLink = false;
for (Element translate : translates) {
hasLink = false;
cacheName = translate.attributeValue("cache");
// 具体的缓存子分类,如数据字典类别
if (translate.attribute("cache-type") != null)
Expand All @@ -706,13 +708,23 @@ else if (translate.attribute("uncached") != null)

if (translate.attribute("split-regex") != null) {
splitRegex = translate.attributeValue("split-regex");
if (translate.attribute("link-sign") != null) {
linkSign = translate.attributeValue("link-sign");
hasLink = true;
}
// 正则转化
if (splitRegex.equals(",") || splitRegex.equals(","))
if (splitRegex.equals(",") || splitRegex.equals(",")) {
splitRegex = "\\,";
else if (splitRegex.equals(";") || splitRegex.equals(";"))
} else if (splitRegex.equals(";") || splitRegex.equals(";")) {
splitRegex = "\\;";
if (translate.attribute("link-sign") != null) {
linkSign = translate.attributeValue("link-sign");
if (!hasLink)
linkSign = ";";
} else if (splitRegex.equals("、")) {
splitRegex = "\\、";
} else if (splitRegex.equals("->")) {
splitRegex = "\\-\\>";
if (!hasLink)
linkSign = "->";
}
}
// 使用alias时只能针对单列处理
Expand Down

0 comments on commit 5ae60e1

Please sign in to comment.