Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

English translation within code #141

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
501 changes: 246 additions & 255 deletions README.md

Large diffs are not rendered by default.

683 changes: 598 additions & 85 deletions VERSIONS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/java/com/ql/util/express/CacheObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serializable;

/**
* 简单的缓存对象
* Simple cache object
* @author tianqiao
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public String loadExpress(String expressName) throws Exception {
InputStream in = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(expressName);
if (in == null) {
throw new QLException("不能找到表达式文件:" + expressName);
throw new QLException("Cannot find expression file:" + expressName);
}
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
StringBuilder builder = new StringBuilder();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/ql/util/express/DynamicParamsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class DynamicParamsUtil {
public static Object[] transferDynamicParams(InstructionSetContext context, ArraySwap list, Class<?>[] delaredParamsClasses,boolean maybeDynamicParams) throws Exception {

Object[] params = null;
//参数定义不符合动态参数形式 || 用户自定义不支持 || 用户传入的参数不符合
//The parameter definition does not conform to the dynamic parameter form || User-defined does not support || The parameter passed in by the user does not conform
if(!maybeDynamicParams || !supportDynamicParams || !maybeDynamicParams(context,list,delaredParamsClasses)){
if(delaredParamsClasses.length != list.length){
throw new QLException("定义的参数长度与运行期传入的参数长度不一致");
throw new QLException("The defined parameter length is inconsistent with the parameter length passed in during runtime");
}
params = new Object[list.length];
for (int i = 0; i < list.length; i++) {
Expand All @@ -26,7 +26,7 @@ public static Object[] transferDynamicParams(InstructionSetContext context, Arra
return params;
}

//支持不定参数的使用 function(arg1,arg2,arg3...)
//Support the use of indefinite parameters function(arg1,arg2,arg3...)
//list -> parameres[]
// arg1,arg2 -> arg1,arg2,[]
// arg1,arg2,arg3,arg4,arg5 -> arg1,arg2,[arg3,arg4,arg5]
Expand All @@ -47,7 +47,7 @@ public static Object[] transferDynamicParams(InstructionSetContext context, Arra
}
}
}else {
throw new QLException("定义的参数长度与运行期传入的参数长度不一致");
throw new QLException("The defined parameter length is inconsistent with the parameter length passed in during runtime");
}
return params;

Expand All @@ -65,11 +65,11 @@ public static boolean maybeDynamicParams(Class<?>[] delaredParamsClasses)

private static boolean maybeDynamicParams(InstructionSetContext context, ArraySwap list, Class<?>[] delaredParamsClasses) throws Exception {

//长度不一致,有可能
//Inconsistent length, it is possible
if(delaredParamsClasses.length != list.length) {
return true;
}
//长度一致的不定参数:不定参数的数组,只输入了一个参数并且为array,有可能
//Indefinite parameters with the same length: an array of indefinite parameters, only one parameter is input and it is an array, it is possible
int length = list.length;
Object lastParam = list.get(length-1).getObject(context);
if(lastParam!=null && !lastParam.getClass().isArray())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ql/util/express/ExportItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serializable;

/**
* 输出给其它指令共享使用的对象
* Output to objects shared by other commands
* @author xuannan
*
*/
Expand All @@ -16,7 +16,7 @@ public class ExportItem implements Serializable{
String globeName;
String name;
String type;//def,alias
String desc;//类名或者别名
String desc;//Class name or alias
public ExportItem(String aName,String aType,String aDesc){
this.globeName = aName;
this.name = aName;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/ql/util/express/ExpressClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public Class<?> loadClass(String name, byte[] code) {

public synchronized Class<?> loadClass(String name, boolean resolve)
throws ClassNotFoundException {
//System.out.print("开始查找 类" + name + "。。。。。。。。。。。");
//System.out.print("Start to find class" + name + "。。。。。。。。。。。");
Class<?> clasz = findLoadedClass(this, name);
if (clasz != null) {
//System.out.println(clasz.getClassLoader());
Expand All @@ -22,7 +22,7 @@ public synchronized Class<?> loadClass(String name, boolean resolve)
if (clasz == null) {
clasz = parentLoadClass(this, name);
}
if (clasz == null && name.startsWith("[")) { // 进行数组处理
if (clasz == null && name.startsWith("[")) { // Array processing
int index = name.indexOf("L");
String str = name.substring(0, index);
String componentClassName = name.substring(index + 1,
Expand All @@ -35,7 +35,7 @@ public synchronized Class<?> loadClass(String name, boolean resolve)
Class<?> componentType = this.loadClass(componentClassName);
clasz = Array.newInstance(componentType, dimes).getClass();
} catch (Exception e) {
// 不错处理
// Good deal
}
}

Expand Down Expand Up @@ -72,7 +72,7 @@ public static Class<?> findLoadedClass(ClassLoader loader, String name)

public static Class<?> parentLoadClass(ClassLoader loader, String name)
throws ClassNotFoundException {
// 如果存在这个类,则直接返回
// If this class exists, return directly
Class<?> clasz = null;
if (clasz == null) {
try {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/ql/util/express/ExpressLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


/**
* 表达式装载器
* Expression loader
*
* @author xuannan
*
Expand All @@ -29,7 +29,7 @@ public void addInstructionSet(String expressName, InstructionSet set)
throws Exception {
synchronized (expressInstructionSetCache) {
if (expressInstructionSetCache.containsKey(expressName)) {
throw new QLException("表达式定义重复:" + expressName);
throw new QLException("Duplicate expression definition:" + expressName);
}
expressInstructionSetCache.put(expressName, set);
}
Expand All @@ -39,13 +39,13 @@ public InstructionSet parseInstructionSet(String expressName,
String expressString) throws Exception {
InstructionSet parseResult = null;
if (expressInstructionSetCache.containsKey(expressName)) {
throw new QLException("表达式定义重复:" + expressName);
throw new QLException("Duplicate expression definition:" + expressName);
}
synchronized (expressInstructionSetCache) {
parseResult = this.creator.parseInstructionSet(expressString);
parseResult.setName(expressName);
parseResult.setGlobeName(expressName);
// 需要将函数和宏定义都提取出来
// Need to extract both functions and macro definitions
for (FunctionInstructionSet item : parseResult
.getFunctionInstructionSets()) {
this.addInstructionSet(item.name, item.instructionSet);
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/com/ql/util/express/ExpressRemoteCacheRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import org.apache.commons.logging.Log;

/**
* 远程缓存对象
* Remote cache object
* @author tianqiao
*
*/
public abstract class ExpressRemoteCacheRunner {



public void loadCache(String expressName,String text){
InstructionSet instructionSet;
Expand All @@ -23,37 +23,37 @@ public void loadCache(String expressName,String text){
cache.setInstructionSet(instructionSet);
this.putCache(expressName, cache);
} catch (Exception e) {
throw new RuntimeException("解析指令并缓存过程出现错误.",e);
}
throw new RuntimeException("An error occurred during the process of parsing instructions and caching.",e);
}
}


public Object execute(String name,IExpressContext<String,Object> context, List<String> errorList,
boolean isTrace,boolean isCatchException, Log aLog){
try {
CacheObject cache = (CacheObject) this.getCache(name);
if(cache==null){
throw new RuntimeException("未获取到缓存对象.");
throw new RuntimeException("The cache object was not obtained.");
}
return getExpressRunner().execute(cache.getInstructionSet(), context, errorList, isTrace, isCatchException, aLog);
} catch (Exception e) {
throw new RuntimeException("获取缓存信息,并且执行指令集出现错误.",e);
}
throw new RuntimeException("Obtain cache information, and an error occurred in the execution instruction set.",e);
}
}

/**
* 获取执行器ExpressRunner
* Get the executor ExpressRunner
* @return
*/
public abstract ExpressRunner getExpressRunner();
/**
* 获取缓存对象
* Get the cache object
* @param key
* @return
*/
public abstract Object getCache(String key);
/**
* 放置缓存的对象
* Place the cached object
* @param key
* @param object
*/
Expand Down
Loading