Browse Source

update: 一些补充

master
zjz1993 5 years ago
parent
commit
cc61a9c157
  1. 19
      src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java
  2. 14
      src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java
  3. 11
      src/main/java/com/fanruan/api/net/NetworkKit.java
  4. 12
      src/main/java/com/fanruan/api/session/SessionKit.java
  5. 9
      src/main/java/com/fanruan/api/util/RenderKit.java
  6. 17
      src/main/java/com/fanruan/api/web/WebKit.java
  7. 9
      src/main/java/com/fanruan/api/xml/XmlKit.java
  8. 4
      src/test/java/com/fanruan/api/net/NetworkKitTest.java

19
src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java

@ -0,0 +1,19 @@
package com.fanruan.api.design.ui.container;
import com.fr.design.beans.BasicBeanPane;
/**
* 创建一个名称空间对象
* */
public class NameObjectCreator extends com.fr.design.gui.controlpane.NameObjectCreator{
public NameObjectCreator(String menuName, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, clazz, updatePane);
}
public NameObjectCreator(String menuName, String iconPath, Class clazz) {
super(menuName, iconPath, clazz);
}
public NameObjectCreator(String menuName, String iconPath, Class clazz, Class<? extends BasicBeanPane> updatePane) {
super(menuName, iconPath, clazz, updatePane);
}
}

14
src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java

@ -0,0 +1,14 @@
package com.fanruan.api.design.ui.editor;
/**
* 文本编辑器
* */
public class TextEditor extends com.fr.design.editor.editor.TextEditor{
public TextEditor(){
}
public TextEditor(String value) {
super(value);
}
}

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

@ -140,4 +140,15 @@ public class NetworkKit {
public static Locale getLocale(HttpServletRequest req) { public static Locale getLocale(HttpServletRequest req) {
return WebServiceUtils.getLocale(req); return WebServiceUtils.getLocale(req);
} }
/**
*获取HTTP请求中指定名字的参数值
* @param req 请求
* @param encode 是否编码
* @param paraName 参数名
* @return 参数值
* */
public static String getHTTPRequestEncodeParameter(HttpServletRequest req, String paraName, boolean encode) {
return NetworkHelper.getHTTPRequestEncodeParameter(req, paraName, encode);
}
} }

12
src/main/java/com/fanruan/api/session/SessionKit.java

@ -1,7 +1,10 @@
package com.fanruan.api.session; package com.fanruan.api.session;
import com.fr.stable.script.NameSpace;
import com.fr.stable.web.SessionProvider; import com.fr.stable.web.SessionProvider;
import com.fr.web.core.ReportSessionIDInfor;
import com.fr.web.core.SessionPoolManager; import com.fr.web.core.SessionPoolManager;
import com.fr.web.session.SessionIDInfo;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -20,4 +23,13 @@ public class SessionKit {
public static @Nullable SessionProvider getSession(@NotNull String sessionID) { public static @Nullable SessionProvider getSession(@NotNull String sessionID) {
return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class); return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class);
} }
/**
* 生成一个关于回话的用于计算的名字空间
* @param sessionId 会话ID
* @return 名字空间
* */
public static NameSpace asNameSpace(String sessionId) {
return SessionIDInfo.asNameSpace(sessionId);
}
} }

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

@ -33,5 +33,14 @@ public class RenderKit {
public static String render(String s, Calculator c) throws Exception { public static String render(String s, Calculator c) throws Exception {
return TemplateUtils.render(s, c); return TemplateUtils.render(s, c);
} }
/**
* 根据参数, 来计算文档字符串
* @param string 待渲染的文本模板
* @return 返回渲染后的文本
* @throws Exception 渲染过程中出现错误则抛出此异常
*/
public static String render(String string) throws Exception {
return TemplateUtils.render(string);
}
} }

17
src/main/java/com/fanruan/api/web/WebKit.java

@ -0,0 +1,17 @@
package com.fanruan.api.web;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
public class WebKit {
/**
* 将HTTPServletRequest中的所有参数都读取出来,存储在一个Map中,返回出去
* @param req 请求
* @return 参数的map
* */
public static Map<String, Object> parameters4SessionIDInfor(HttpServletRequest req){
return WebUtils.parameters4SessionIDInfor(req);
}
}

9
src/main/java/com/fanruan/api/xml/XmlKit.java

@ -104,4 +104,13 @@ public class XmlKit {
public static void writeParameters(XMLPrintWriter writer, ParameterProvider[] parameter) { public static void writeParameters(XMLPrintWriter writer, ParameterProvider[] parameter) {
StableXMLUtils.writeParameters(writer,parameter); StableXMLUtils.writeParameters(writer,parameter);
} }
/**
* 以xml方式读string
* @param xmlString xml字符串
* @return xml文件
* */
public static XMLReadable readStringAsXMLable(String xmlString) {
return GeneralXMLTools.readStringAsXMLable(xmlString);
}
} }

4
src/test/java/com/fanruan/api/net/NetworkKitTest.java

@ -48,4 +48,8 @@ public class NetworkKitTest extends Prepare {
@Test @Test
public void testGetHTTPRequestParameter() { public void testGetHTTPRequestParameter() {
} }
@Test
public void getHTTPRequestEncodeParameter() {
}
} }
Loading…
Cancel
Save