From 6d87a273a4c12a14cbbaa3e87d356418ee80ce6d Mon Sep 17 00:00:00 2001 From: Palin Date: Tue, 10 Sep 2019 14:10:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/function/FunctionKit.java | 9 --------- src/main/java/com/fanruan/api/util/RenderKit.java | 10 ++++++---- .../java/com/fanruan/api/util/RenderKitTest.java | 13 ++++++------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index 3aa6971..f9fccef 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/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); - } - } \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/util/RenderKit.java b/src/main/java/com/fanruan/api/util/RenderKit.java index 653aab7..bd5d003 100644 --- a/src/main/java/com/fanruan/api/util/RenderKit.java +++ b/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); } } diff --git a/src/test/java/com/fanruan/api/util/RenderKitTest.java b/src/test/java/com/fanruan/api/util/RenderKitTest.java index 78b498b..6946f6a 100644 --- a/src/test/java/com/fanruan/api/util/RenderKitTest.java +++ b/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)); +} + }