Skip to content

Commit

Permalink
format and remmove unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
pymBupt committed Feb 7, 2023
1 parent c643181 commit 856c032
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.List;

import org.apache.commons.logging.Log;

/**
* 远程缓存对象
*
Expand Down Expand Up @@ -61,5 +59,3 @@ public Object execute(String name, IExpressContext<String, Object> context, List
*/
public abstract void putCache(String key, Object object);
}


21 changes: 9 additions & 12 deletions src/main/java/com/ql/util/express/ExpressRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import com.ql.util.express.parse.NodeType;
import com.ql.util.express.parse.NodeTypeManager;
import com.ql.util.express.parse.Word;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* 语法分析和计算的入口类
Expand Down Expand Up @@ -126,17 +124,15 @@ public ExpressRunner(boolean isPrecise, boolean isTrace) {
}

/**
*
* @param isPrecise
* @param isTrace
* @param cacheMap user can define safe and efficient cache or use default concurrentMap
* @param cacheMap user can define safe and efficient cache or use default concurrentMap
*/
public ExpressRunner(boolean isPrecise, boolean isTrace,
Map<String, InstructionSet> cacheMap) {
this(isPrecise, isTrace, new DefaultExpressResourceLoader(), null, cacheMap);
}


public ExpressRunner(boolean isPrecise, boolean isStrace, NodeTypeManager nodeTypeManager) {
this(isPrecise, isStrace, new DefaultExpressResourceLoader(), nodeTypeManager);
}
Expand All @@ -156,7 +152,7 @@ public ExpressRunner(boolean isPrecise, boolean isTrace, IExpressResourceLoader
* @param isPrecise 是否需要高精度计算支持
* @param isTrace 是否跟踪执行指令的过程
* @param iExpressResourceLoader 表达式的资源装载器
* @param cacheMap 指令集缓存, 必须是线程安全的集合
* @param cacheMap 指令集缓存, 必须是线程安全的集合
*/
public ExpressRunner(boolean isPrecise, boolean isTrace, IExpressResourceLoader iExpressResourceLoader,
NodeTypeManager nodeTypeManager, Map<String, InstructionSet> cacheMap) {
Expand Down Expand Up @@ -224,7 +220,6 @@ public IExpressResourceLoader getExpressResourceLoader() {
return this.expressResourceLoader;
}


/**
* 添加宏定义
* 例如: macro 宏名称 { abc(userInfo.userId);}
Expand Down Expand Up @@ -536,7 +531,8 @@ public void addOperatorWithAlias(String keyWordName, String realKeyWordName, Str
}
boolean isExist = this.operatorManager.isExistOperator(realNodeType.getName());
if (!isExist && errorInfo != null) {
throw new QLException("关键字:" + realKeyWordName + "是通过指令来实现的,不能设置错误的提示信息,errorInfo 必须是 null");
throw new QLException(
"关键字:" + realKeyWordName + "是通过指令来实现的,不能设置错误的提示信息,errorInfo 必须是 null");
}
if (!isExist || errorInfo == null) {
//不需要新增操作符号,只需要建立一个关键子即可
Expand Down Expand Up @@ -646,7 +642,7 @@ public Object execute(String expressString, IExpressContext<String, Object> cont
parseResult = expressInstructionSetCache.get(expressString);
if (parseResult == null) {
expressInstructionSetCache.put(expressString,
parseResult = this.parseInstructionSet(expressString));
parseResult = this.parseInstructionSet(expressString));
}
}
}
Expand All @@ -665,9 +661,9 @@ private Object executeReentrant(InstructionSet sets, IExpressContext<String, Obj
return reentrantCount > 1 ?
// 线程重入
InstructionSetRunner.execute(this, sets, this.loader, iExpressContext, errorList, isTrace,
isCatchException, true, false) :
isCatchException, true, false) :
InstructionSetRunner.executeOuter(this, sets, this.loader, iExpressContext, errorList, isTrace,
isCatchException, false);
isCatchException, false);
} finally {
threadReentrantCount.set(threadReentrantCount.get() - 1);
}
Expand Down Expand Up @@ -721,7 +717,8 @@ public ExportItem[] getExportInfo() {
public InstructionSet getInstructionSetFromLocalCache(String expressString) throws Exception {
InstructionSet parseResult = expressInstructionSetCache.get(expressString);
if (parseResult == null) {
expressInstructionSetCache.putIfAbsent(expressString, parseResult = this.parseInstructionSet(expressString));
expressInstructionSetCache.putIfAbsent(expressString,
parseResult = this.parseInstructionSet(expressString));
}
return parseResult;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/ql/util/express/InstructionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import com.ql.util.express.instruction.detail.InstructionNewVirClass;
import com.ql.util.express.instruction.detail.InstructionOperator;
import com.ql.util.express.instruction.opdata.OperateDataLocalVar;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* 表达式执行编译后形成的指令集合
Expand Down Expand Up @@ -314,4 +312,4 @@ public String toString(int level) {
throw new RuntimeException(e);
}
}
}
}
2 changes: 0 additions & 2 deletions src/main/java/com/ql/util/express/InstructionSetRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import com.ql.util.express.config.QLExpressTimer;
import com.ql.util.express.instruction.OperateDataCacheManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class InstructionSetRunner {

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/ql/util/express/QLambda.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.ql.util.express.instruction.OperateDataCacheManager;
import com.ql.util.express.instruction.opdata.OperateDataLocalVar;
import org.apache.commons.logging.Log;

/**
* 代表一个 lambda 表达式
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class QLExpressRunStrategy {
SECURITY_RISK_METHOD_LIST.add("com.sun.rowset.JdbcRowSetImpl.setAutoCommit");

// QLE 自身开关
SECURITY_RISK_METHOD_LIST.add(QLExpressRunStrategy.class.getName()+".setForbidInvokeSecurityRiskMethods");
SECURITY_RISK_METHOD_LIST.add(QLExpressRunStrategy.class.getName() + ".setForbidInvokeSecurityRiskMethods");
SECURITY_RISK_METHOD_LIST.add("jdk.jshell.JShell.create");
SECURITY_RISK_METHOD_LIST.add("javax.script.ScriptEngineManager.getEngineByName");
SECURITY_RISK_METHOD_LIST.add("org.springframework.jndi.JndiLocatorDelegate.lookup");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import java.util.List;

import com.ql.util.express.RunEnvironment;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public abstract class Instruction {
private Integer line = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import com.ql.util.express.RunEnvironment;
import com.ql.util.express.exception.QLException;
import com.ql.util.express.instruction.OperateDataCacheManager;
import com.ql.util.express.instruction.opdata.OperateDataAttr;
import com.ql.util.express.instruction.opdata.OperateDataLocalVar;
import org.apache.commons.logging.Log;

public class InstructionCallSelfDefineFunction extends Instruction {
private final String functionName;
Expand All @@ -37,7 +35,8 @@ public void execute(RunEnvironment environment, List<String> errorList) throws E

Object function = environment.getContext().getSymbol(functionName);
if (!(function instanceof InstructionSet)) {
throw new QLException(getExceptionPrefix() + "在Runner的操作符定义和自定义函数中都没有找到" + this.functionName + "的定义");
throw new QLException(
getExceptionPrefix() + "在Runner的操作符定义和自定义函数中都没有找到" + this.functionName + "的定义");
}
InstructionSet functionSet = (InstructionSet)function;
OperateData result = InstructionCallSelfDefineFunction.executeSelfFunction(environment, functionSet, parameters,
Expand All @@ -59,8 +58,8 @@ public static OperateData executeSelfFunction(RunEnvironment environment, Instru
context.addSymbol(operateDataLocalVar.getName(), operateDataLocalVar);
operateDataLocalVar.setObject(context, parameters.get(i).getObject(environment.getContext()));
}
Object result = InstructionSetRunner.execute(functionSet,
context, errorList, environment.isTrace(), false, true);
Object result = InstructionSetRunner.execute(functionSet, context, errorList, environment.isTrace(), false,
true);
return OperateDataCacheManager.fetchOperateData(result, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.ql.util.express.OperateData;
import com.ql.util.express.exception.QLException;
import com.ql.util.express.instruction.OperateDataCacheManager;
import org.apache.commons.logging.Log;

/**
* 虚拟Class的内存对象
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/ql/util/express/match/QLPatternNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import java.util.List;

import com.ql.util.express.exception.QLCompileException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

enum MatchMode {
AND,
Expand Down Expand Up @@ -303,4 +301,4 @@ public String joinStringList(List<QLPatternNode> list, String splitChar) {
}
return buffer.toString();
}
}
}
3 changes: 0 additions & 3 deletions src/main/java/com/ql/util/express/parse/ExpressParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import com.ql.util.express.exception.QLSecurityRiskException;
import com.ql.util.express.match.QLMatchResult;
import com.ql.util.express.match.QLPattern;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ExpressParse {

Expand Down Expand Up @@ -435,4 +433,3 @@ public static String printInfo(List<ExpressNode> list, String splitOp) {
return stringBuilder.toString();
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.ql.util.express.ExpressRunner;
import com.ql.util.express.InstructionSet;
import com.ql.util.express.match.QLPattern;
import org.junit.Test;

public class CompileMemoryTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.IExpressContext;
import com.ql.util.express.match.QLPattern;
import org.junit.Test;

public class StackOverFlowTest {
Expand Down
2 changes: 0 additions & 2 deletions src/test/java/com/ql/util/express/test/DynamicFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.ql.util.express.ExpressRunner;
import com.ql.util.express.InstructionSet;
import com.ql.util.express.InstructionSetRunner;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.ql.util.express.DefaultContext;
import com.ql.util.express.ExportItem;
import com.ql.util.express.ExpressRunner;
import org.apache.commons.logging.Log;
import org.junit.Test;

public class LoadExpressFromFileTest {
Expand Down
89 changes: 0 additions & 89 deletions src/test/java/com/ql/util/express/test/MyLog.java

This file was deleted.

0 comments on commit 856c032

Please sign in to comment.