Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
a941cfbe
Commit
a941cfbe
authored
Oct 22, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
暂停BUG
parent
0cf8805e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
24 deletions
+4
-24
PlaceholderUtils.java
...on/src/main/java/com/byit/job/utils/PlaceholderUtils.java
+4
-24
No files found.
byit-myth-core/myth-core-common/src/main/java/com/byit/job/utils/PlaceholderUtils.java
View file @
a941cfbe
...
@@ -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
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment