Commit a941cfbe by huangfusuper

暂停BUG

parent 0cf8805e
...@@ -42,31 +42,11 @@ public class PlaceholderUtils { ...@@ -42,31 +42,11 @@ public class PlaceholderUtils {
} }
//读取脚本文件 //读取脚本文件
String scriptContent = new String(scriptData, StandardCharsets.UTF_8); String scriptContent = new String(scriptData, StandardCharsets.UTF_8);
StringBuilder sbt = new StringBuilder(scriptContent); for (Map.Entry<String, String> entity : parameter.entrySet()) {
//找到第一个需要替换的位置 String newKey = String.format("%s%s%s",PLACEHOLDER_PREFIX,entity.getKey(),PLACEHOLDER_SUFFIX);
int startIndex = sbt.indexOf(PLACEHOLDER_PREFIX); scriptContent = scriptContent.replace(newKey, entity.getValue());
//开始循环遍历
while (startIndex != -1){
//寻找这个替换符 结束的位置
int endIndex = sbt.indexOf(PLACEHOLDER_SUFFIX, startIndex + PLACEHOLDER_PREFIX.length());
//确定是否存在后缀
int nextIndex= 0 ;
if(endIndex != -1){
//截取变量值
String placeholder = sbt.substring(startIndex + PLACEHOLDER_PREFIX.length(), endIndex);
//确定下一次查询的位置
//开始从 map中解析
if(parameter.containsKey(placeholder)){
String placeholderValue = parameter.get(placeholder);
//替换这个位置
sbt.replace(startIndex,endIndex+PLACEHOLDER_SUFFIX.length(),placeholderValue);
//再次计算替换后的查询开始位置
nextIndex = startIndex+placeholderValue.length();
} }
startIndex = sbt.indexOf(PLACEHOLDER_PREFIX,nextIndex); return scriptContent.getBytes(StandardCharsets.UTF_8);
}
}
return sbt.toString().getBytes(StandardCharsets.UTF_8);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment