Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水滴come
qlexpress
提交
9cb548e1
Q
qlexpress
项目概览
水滴come
/
qlexpress
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qlexpress
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9cb548e1
编写于
4月 20, 2022
作者:
水滴come
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加注释功能-添加工具类
上级
922529c9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
99 addition
and
40 deletion
+99
-40
src/main/java/com/ql/util/express/ExpressRunner.java
src/main/java/com/ql/util/express/ExpressRunner.java
+43
-39
src/main/java/com/ql/util/express/FilterExpressString.java
src/main/java/com/ql/util/express/FilterExpressString.java
+55
-0
src/test/java/com/ql/util/express/test/DateTest.java
src/test/java/com/ql/util/express/test/DateTest.java
+1
-1
未找到文件。
src/main/java/com/ql/util/express/ExpressRunner.java
浏览文件 @
9cb548e1
...
...
@@ -105,7 +105,7 @@ public class ExpressRunner {
private
AppendingClassFieldManager
appendingClassFieldManager
;
private
final
ThreadLocal
<
IOperateDataCache
>
operateDataCacheThreadLocal
=
ThreadLocal
.
withInitial
(
()
->
new
OperateDataCacheImpl
(
30
));
()
->
new
OperateDataCacheImpl
(
30
));
public
IOperateDataCache
getOperateDataCache
()
{
return
this
.
operateDataCacheThreadLocal
.
get
();
...
...
@@ -133,7 +133,7 @@ public class ExpressRunner {
* @param iExpressResourceLoader 表达式的资源装载器
*/
public
ExpressRunner
(
boolean
isPrecise
,
boolean
isTrace
,
IExpressResourceLoader
iExpressResourceLoader
,
NodeTypeManager
nodeTypeManager
)
{
NodeTypeManager
nodeTypeManager
)
{
this
.
isTrace
=
isTrace
;
this
.
isPrecise
=
isPrecise
;
this
.
expressResourceLoader
=
iExpressResourceLoader
;
...
...
@@ -313,9 +313,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfClassMethod
(
String
name
,
String
className
,
String
functionName
,
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineClassFunction
operatorSelfDefineClassFunction
=
new
OperatorSelfDefineClassFunction
(
name
,
className
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
className
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineClassFunction
);
}
...
...
@@ -330,9 +330,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfClassMethod
(
String
name
,
Class
<?>
clazz
,
String
functionName
,
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineClassFunction
operatorSelfDefineClassFunction
=
new
OperatorSelfDefineClassFunction
(
name
,
clazz
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
clazz
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineClassFunction
);
}
...
...
@@ -349,10 +349,10 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfClassMethod
(
String
name
,
String
className
,
String
functionName
,
Class
<?>[]
parameterClassTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
Class
<?>[]
parameterClassTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineClassFunction
operatorSelfDefineClassFunction
=
new
OperatorSelfDefineClassFunction
(
name
,
className
,
functionName
,
parameterClassTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
className
,
functionName
,
parameterClassTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineClassFunction
);
}
...
...
@@ -367,9 +367,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfClassMethod
(
String
name
,
String
className
,
String
functionName
,
String
[]
parameterTypes
,
String
errorInfo
)
throws
Exception
{
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineClassFunction
operatorSelfDefineClassFunction
=
new
OperatorSelfDefineClassFunction
(
name
,
className
,
functionName
,
parameterTypes
,
null
,
null
,
errorInfo
);
className
,
functionName
,
parameterTypes
,
null
,
null
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineClassFunction
);
}
...
...
@@ -386,9 +386,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfClassMethod
(
String
name
,
String
className
,
String
functionName
,
String
[]
parameterTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineClassFunction
operatorSelfDefineClassFunction
=
new
OperatorSelfDefineClassFunction
(
name
,
className
,
functionName
,
parameterTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
className
,
functionName
,
parameterTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineClassFunction
);
}
...
...
@@ -403,9 +403,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfServiceMethod
(
String
name
,
Object
serviceObject
,
String
functionName
,
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
Class
<?>[]
parameterClassTypes
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineServiceFunction
operatorSelfDefineServiceFunction
=
new
OperatorSelfDefineServiceFunction
(
name
,
serviceObject
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
name
,
serviceObject
,
functionName
,
parameterClassTypes
,
null
,
null
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineServiceFunction
);
}
...
...
@@ -422,10 +422,10 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfServiceMethod
(
String
name
,
Object
serviceObject
,
String
functionName
,
Class
<?>[]
parameterClassTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
Class
<?>[]
parameterClassTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineServiceFunction
operatorSelfDefineServiceFunction
=
new
OperatorSelfDefineServiceFunction
(
name
,
serviceObject
,
functionName
,
parameterClassTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
name
,
serviceObject
,
functionName
,
parameterClassTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineServiceFunction
);
}
...
...
@@ -440,17 +440,17 @@ public class ExpressRunner {
* @throws Exception
*/
public
void
addFunctionOfServiceMethod
(
String
name
,
Object
serviceObject
,
String
functionName
,
String
[]
parameterTypes
,
String
errorInfo
)
throws
Exception
{
String
[]
parameterTypes
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineServiceFunction
operatorSelfDefineServiceFunction
=
new
OperatorSelfDefineServiceFunction
(
name
,
serviceObject
,
functionName
,
parameterTypes
,
null
,
null
,
errorInfo
);
name
,
serviceObject
,
functionName
,
parameterTypes
,
null
,
null
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineServiceFunction
);
}
public
void
addFunctionOfServiceMethod
(
String
name
,
Object
serviceObject
,
String
functionName
,
String
[]
parameterTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
String
[]
parameterTypes
,
String
[]
parameterDesc
,
String
[]
parameterAnnotation
,
String
errorInfo
)
throws
Exception
{
OperatorSelfDefineServiceFunction
operatorSelfDefineServiceFunction
=
new
OperatorSelfDefineServiceFunction
(
name
,
serviceObject
,
functionName
,
parameterTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
name
,
serviceObject
,
functionName
,
parameterTypes
,
parameterDesc
,
parameterAnnotation
,
errorInfo
);
this
.
addFunction
(
name
,
operatorSelfDefineServiceFunction
);
}
...
...
@@ -549,9 +549,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
Object
executeByExpressName
(
String
name
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isTrace
,
boolean
isCatchException
,
Log
log
)
throws
Exception
{
boolean
isTrace
,
boolean
isCatchException
,
Log
log
)
throws
Exception
{
return
InstructionSetRunner
.
executeOuter
(
this
,
this
.
loader
.
getInstructionSet
(
name
),
this
.
loader
,
context
,
errorList
,
isTrace
,
isCatchException
,
log
,
false
);
errorList
,
isTrace
,
isCatchException
,
log
,
false
);
}
///**
...
...
@@ -588,9 +588,9 @@ public class ExpressRunner {
* @throws Exception
*/
public
Object
execute
(
InstructionSet
instructionSet
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isTrace
,
boolean
isCatchException
,
Log
log
)
throws
Exception
{
List
<
String
>
errorList
,
boolean
isTrace
,
boolean
isCatchException
,
Log
log
)
throws
Exception
{
return
InstructionSetRunner
.
executeOuter
(
this
,
instructionSet
,
this
.
loader
,
context
,
errorList
,
isTrace
,
isCatchException
,
log
,
false
);
isTrace
,
isCatchException
,
log
,
false
);
}
/**
...
...
@@ -606,7 +606,7 @@ public class ExpressRunner {
* @throws Exception
*/
public
Object
execute
(
String
expressString
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isCache
,
boolean
isTrace
,
long
timeoutMillis
)
throws
Exception
{
boolean
isCache
,
boolean
isTrace
,
long
timeoutMillis
)
throws
Exception
{
//设置超时毫秒时间
QLExpressTimer
.
setTimer
(
timeoutMillis
);
try
{
...
...
@@ -628,7 +628,7 @@ public class ExpressRunner {
* @throws Exception
*/
public
Object
execute
(
String
expressString
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isCache
,
boolean
isTrace
)
throws
Exception
{
boolean
isCache
,
boolean
isTrace
)
throws
Exception
{
return
this
.
execute
(
expressString
,
context
,
errorList
,
isCache
,
isTrace
,
null
);
}
...
...
@@ -644,9 +644,9 @@ public class ExpressRunner {
* @return
* @throws Exception
*/
public
Object
execute
(
String
expressString
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isCache
,
boolean
isTrace
,
Log
log
)
throws
Exception
{
public
Object
execute
(
String
expressString
,
IExpressContext
<
String
,
Object
>
context
,
List
<
String
>
errorList
,
boolean
isCache
,
boolean
isTrace
,
Log
log
)
throws
Exception
{
InstructionSet
parseResult
;
expressString
=
FilterExpressString
.
filterAllUseless
(
expressString
);
if
(
isCache
)
{
parseResult
=
expressInstructionSetCache
.
get
(
expressString
);
if
(
parseResult
==
null
)
{
...
...
@@ -665,17 +665,17 @@ public class ExpressRunner {
}
private
Object
executeReentrant
(
InstructionSet
sets
,
IExpressContext
<
String
,
Object
>
iExpressContext
,
List
<
String
>
errorList
,
boolean
isTrace
,
Log
log
)
throws
Exception
{
List
<
String
>
errorList
,
boolean
isTrace
,
Log
log
)
throws
Exception
{
try
{
int
reentrantCount
=
threadReentrantCount
.
get
()
+
1
;
threadReentrantCount
.
set
(
reentrantCount
);
return
reentrantCount
>
1
?
// 线程重入
InstructionSetRunner
.
execute
(
this
,
sets
,
this
.
loader
,
iExpressContext
,
errorList
,
isTrace
,
false
,
true
,
log
,
false
)
:
InstructionSetRunner
.
executeOuter
(
this
,
sets
,
this
.
loader
,
iExpressContext
,
errorList
,
isTrace
,
false
,
log
,
false
);
// 线程重入
InstructionSetRunner
.
execute
(
this
,
sets
,
this
.
loader
,
iExpressContext
,
errorList
,
isTrace
,
false
,
true
,
log
,
false
)
:
InstructionSetRunner
.
executeOuter
(
this
,
sets
,
this
.
loader
,
iExpressContext
,
errorList
,
isTrace
,
false
,
log
,
false
);
}
finally
{
threadReentrantCount
.
set
(
threadReentrantCount
.
get
()
-
1
);
}
...
...
@@ -755,7 +755,7 @@ public class ExpressRunner {
}
public
boolean
createInstructionSetPrivate
(
InstructionSet
result
,
Stack
<
ForRelBreakContinue
>
forStack
,
ExpressNode
node
,
boolean
isRoot
)
throws
Exception
{
ExpressNode
node
,
boolean
isRoot
)
throws
Exception
{
InstructionFactory
factory
=
InstructionFactory
.
getInstructionFactory
(
node
.
getInstructionFactory
());
return
factory
.
createInstruction
(
this
,
result
,
forStack
,
node
,
isRoot
);
}
...
...
@@ -823,7 +823,7 @@ public class ExpressRunner {
}
Word
[]
words
=
this
.
parse
.
splitWords
(
text
,
isTrace
,
selfDefineClass
);
ExpressNode
root
=
this
.
parse
.
parse
(
this
.
rootExpressPackage
,
words
,
text
,
isTrace
,
selfDefineClass
,
mockRemoteJavaClass
);
mockRemoteJavaClass
);
InstructionSet
result
=
createInstructionSet
(
root
,
"main"
);
if
(
this
.
isTrace
&&
log
.
isDebugEnabled
())
{
log
.
debug
(
result
);
...
...
@@ -837,4 +837,8 @@ public class ExpressRunner {
return
false
;
}
}
}
src/main/java/com/ql/util/express/FilterExpressString.java
0 → 100644
浏览文件 @
9cb548e1
package
com.ql.util.express
;
/**
* @description: 过滤 程序文本 无用参数
* @author: xingyipeng
* @create: 22/4/20
**/
public
class
FilterExpressString
{
/**
* 过滤无用代码执行段
*
* @param expressString
* @return
* @author xingyipeng
* @email 1103914483@qq.com
*/
public
static
String
filterAllUseless
(
String
expressString
)
{
expressString
=
filterNotes
(
expressString
);
expressString
=
filterLF
(
expressString
);
return
expressString
;
}
/**
* <p>
* 过滤笔记注释块
* <ul>
* 过滤:
* <li>/** ... ** /</li>
* <li>//...</li>
* </ul>
* </p>
*
* @param expressString 程序文本
* @return
* @author xingyipeng
* @email 1103914483@qq.com
*/
public
static
String
filterNotes
(
String
expressString
)
{
return
expressString
.
replaceAll
(
"\\/\\*\\*{1,2}[\\s\\S]*?\\*{1,2}\\/|\\/\\/[\\s\\S]*?\\n|\\/\\/[\\s\\S]*?$"
,
""
);
}
/**
* 过滤多余换行
*
* @param expressString 程序文本
* @return
* @author xingyipeng
* @email 1103914483@qq.com
*/
public
static
String
filterLF
(
String
expressString
)
{
return
expressString
.
replaceAll
(
"\n+"
,
"\n"
);
}
}
src/test/java/com/ql/util/express/test/DateTest.java
浏览文件 @
9cb548e1
...
...
@@ -11,7 +11,7 @@ import org.junit.Test;
public
class
DateTest
{
@Test
public
void
testDateCompare
()
throws
Exception
{
String
express
=
"a = new Date();
b = a; a == b;
"
;
String
express
=
"a = new Date();
/**:::**/ b = a; a == b; // 22323323
"
;
DefaultContext
<
String
,
Object
>
context
=
new
DefaultContext
<>();
ExpressRunner
runner
=
new
ExpressRunner
();
Object
r
=
runner
.
execute
(
express
,
context
,
null
,
false
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录