Browse Source

再次修改

master
Palin 5 years ago
parent
commit
6d87a273a4
  1. 9
      src/main/java/com/fanruan/api/function/FunctionKit.java
  2. 10
      src/main/java/com/fanruan/api/util/RenderKit.java
  3. 11
      src/test/java/com/fanruan/api/util/RenderKitTest.java

9
src/main/java/com/fanruan/api/function/FunctionKit.java

@ -7,7 +7,6 @@ import com.fr.file.FunctionManager;
import com.fr.file.FunctionManagerProvider;
import com.fr.script.Calculator;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionHelper;
import com.fr.stable.script.FunctionDef;
import java.util.ArrayList;
@ -87,12 +86,4 @@ public class FunctionKit {
return com.fr.file.FunctionManager.getInstance();
}
/**
* 得到函数标识
* @return 函数标识
*/
public static int generateFunctionID(String string) {
return FunctionHelper.generateFunctionID(string);
}
}

10
src/main/java/com/fanruan/api/util/RenderKit.java

@ -2,7 +2,9 @@ package com.fanruan.api.util;
import com.fr.base.TemplateUtils;
import com.fr.script.Calculator;
import com.fr.stable.script.CalculatorProvider;
import java.util.Collections;
import java.util.Map;
/**
@ -23,13 +25,13 @@ public class RenderKit {
/**
* 根据参数, 来计算文档字符串
* @param string 待渲染的文本模板
* @param calculator 参数集合
* @param s 待渲染的文本模板
* @param c 参数集合
* @return 返回渲染后的文本
* @throws Exception 渲染过程中出现错误则抛出此异常
*/
public static String render(String string, Calculator calculator) throws Exception {
return TemplateUtils.render(string, calculator);
public static String render(String s, Calculator c) throws Exception {
return TemplateUtils.render(s, c);
}
}

11
src/test/java/com/fanruan/api/util/RenderKitTest.java

@ -1,13 +1,12 @@
package com.fanruan.api.util;
import com.fanruan.api.Prepare;
import com.fr.script.Calculator;
import org.junit.Assert;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
/**
* @author richie
@ -28,9 +27,9 @@ public class RenderKitTest extends Prepare {
@Test
public void render() throws Exception{
String string = new String("a");
Calculator calculator = new Calculator("b");
Assert.assertEquals("a", RenderKit.render(string));
Assert.assertEquals("b", RenderKit.render(calculator));
Calculator c = Calculator.createCalculator();
String s = "abc${p1}xyz${p2}";
Assert.assertEquals("abc1xyz2", RenderKit.render(s,c));
}
}

Loading…
Cancel
Save