Browse Source

Merge branch 'master' of Palin/finekit into master

remotes/1611766341912730171/master
richie 5 years ago committed by Gogs
parent
commit
7a9619e4f0
  1. 4
      src/main/java/com/fanruan/api/design/work/ReportletPane.java
  2. 7
      src/main/java/com/fanruan/api/err/ValidationException.java
  3. 6
      src/main/java/com/fanruan/api/net/NetworkKit.java
  4. 4
      src/main/java/com/fanruan/api/report/analy/data/NodeVisitor.java
  5. 15
      src/main/java/com/fanruan/api/util/RenderKit.java
  6. 14
      src/test/java/com/fanruan/api/util/RenderKitTest.java

4
src/main/java/com/fanruan/api/design/work/ReportletPane.java

@ -0,0 +1,4 @@
package com.fanruan.api.design.work;
public class ReportletPane extends com.fr.design.gui.itree.filetree.ReportletPane {
}

7
src/main/java/com/fanruan/api/err/ValidationException.java

@ -0,0 +1,7 @@
package com.fanruan.api.err;
/**
* 验证异常
*/
public class ValidationException extends com.fr.design.Exception.ValidationException {
}

6
src/main/java/com/fanruan/api/net/NetworkKit.java

@ -1,5 +1,6 @@
package com.fanruan.api.net;
import com.fr.base.ServerConfig;
import com.fr.data.NetworkHelper;
import org.jetbrains.annotations.Nullable;
@ -117,4 +118,9 @@ public class NetworkKit {
public static @Nullable String getHTTPRequestParameter(HttpServletRequest req, String... paraNames) {
return NetworkHelper.getHTTPRequestParameter(req, paraNames);
}
public static String createServletURL(HttpServletRequest req) {
return NetworkHelper.createServletURL(req, ServerConfig.getInstance().getServletName());
}
}

4
src/main/java/com/fanruan/api/report/analy/data/NodeVisitor.java

@ -0,0 +1,4 @@
package com.fanruan.api.report.analy.data;
public abstract class NodeVisitor extends com.fr.stable.core.NodeVisitor {
}

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

@ -1,7 +1,10 @@
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;
/**
@ -19,4 +22,16 @@ public class RenderKit {
public static String renderParameter4Tpl(String text, Map<String, Object> map) throws Exception {
return TemplateUtils.renderParameter4Tpl(text, map);
}
/**
* 根据参数, 来计算文档字符串
* @param s 待渲染的文本模板
* @param c 参数集合
* @return 返回渲染后的文本
* @throws Exception 渲染过程中出现错误则抛出此异常
*/
public static String render(String s, Calculator c) throws Exception {
return TemplateUtils.render(s, c);
}
}

14
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
@ -25,4 +24,15 @@ public class RenderKitTest extends Prepare {
String text = "${name} is ${age} years old, he earned ${salary} dollars per month.";
Assert.assertEquals("Alex is 20 years old, he earned 100 dollars per month.", RenderKit.renderParameter4Tpl(text, map));
}
@Test
public void render() throws Exception{
Calculator c = Calculator.createCalculator();
Map<String, Object> map = new HashMap<>();
map.put("p1",1);
map.put("p2",2);
String s = "abc${p1}xyz${p2}";
Assert.assertEquals("abcxyz", RenderKit.render(s,c));
}
}
Loading…
Cancel
Save