From fd8d12543af687fb8ae8931f0a158e22a6b960fc Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 18 Sep 2019 16:07:15 +0800 Subject: [PATCH] =?UTF-8?q?update:=20finekit=E7=9A=84=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/attachment/Attachment.java | 20 +++++++++++ .../com/fanruan/api/cal/namespace/FArray.java | 23 +++++++++++++ .../java/com/fanruan/api/i18n/I18nKit.java | 10 ++++++ .../java/com/fanruan/api/util/ArrayKit.java | 2 +- .../java/com/fanruan/api/util/CodeKit.java | 8 +++++ .../java/com/fanruan/api/util/GeneralKit.java | 9 ++++- src/main/java/com/fanruan/api/xml/XmlKit.java | 10 +++++- .../com/fanruan/api/xml/component/FRFile.java | 13 ++++++++ .../com/fanruan/api/util/ArrayKitTest.java | 33 ++++++++++++++++++- .../com/fanruan/api/util/CodeKitTest.java | 4 +-- .../com/fanruan/api/util/GeneralKitTest.java | 6 ++++ 11 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/fanruan/api/attachment/Attachment.java create mode 100644 src/main/java/com/fanruan/api/cal/namespace/FArray.java create mode 100644 src/main/java/com/fanruan/api/xml/component/FRFile.java diff --git a/src/main/java/com/fanruan/api/attachment/Attachment.java b/src/main/java/com/fanruan/api/attachment/Attachment.java new file mode 100644 index 0000000..e3e1e61 --- /dev/null +++ b/src/main/java/com/fanruan/api/attachment/Attachment.java @@ -0,0 +1,20 @@ +package com.fanruan.api.attachment; + +import com.fr.cache.AttachmentFileBase; +/** + * 附件信息类,用来存储FR中的各种附件 + * */ +public class Attachment extends com.fr.cache.Attachment{ + /** + * 根据给定的编号、类型、文件名和二进制数组创建一个附件对象 + * */ + public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase){ + super(id, type, filename, attachmentFileBase); + } + /** + * 根据给定的编号、类型、文件名、二进制数组、宽度和高度创建一个附件对象 + * */ + public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase, int width, int height){ + super(id, type, filename, attachmentFileBase, width, height); + } +} diff --git a/src/main/java/com/fanruan/api/cal/namespace/FArray.java b/src/main/java/com/fanruan/api/cal/namespace/FArray.java new file mode 100644 index 0000000..51c59b8 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/namespace/FArray.java @@ -0,0 +1,23 @@ +package com.fanruan.api.cal.namespace; +import java.util.Collection; + +/** + * 生成一个链表类 + * */ +public class FArray extends com.fr.general.FArray{ + public FArray(){ + + } + /** + * 通过使用一个无需集合生成的链表类 + * */ + public FArray(Collection collection) { + super(collection); + } + /** + * 通过使用一个数组生成的链表类 + * */ + public FArray(T[] array) { + super(array); + } +} diff --git a/src/main/java/com/fanruan/api/i18n/I18nKit.java b/src/main/java/com/fanruan/api/i18n/I18nKit.java index a2f3cb1..e4e56d1 100644 --- a/src/main/java/com/fanruan/api/i18n/I18nKit.java +++ b/src/main/java/com/fanruan/api/i18n/I18nKit.java @@ -11,4 +11,14 @@ public class I18nKit { public static String getLocText(String string) { return InterProviderFactory.getProvider().getLocText(string); } + /** + * 获取国际化文本 + * + * @param string 需要国际化的值对应的键 + * @param args 变量 + * @return 返回国际化文本 + */ + public static String getLocText(String string,String... args) { + return InterProviderFactory.getProvider().getLocText(string,args); + } } diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 5df74b7..ed5b319 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -55,7 +55,7 @@ public class ArrayKit { * @param array 源数组 * @return 返回数组判断为空的结果 */ - public static boolean isEmpty(Object[] array) { + public static boolean isEmpty(T[] array) { return ArrayUtils.isEmpty(array); } /** diff --git a/src/main/java/com/fanruan/api/util/CodeKit.java b/src/main/java/com/fanruan/api/util/CodeKit.java index b819eb4..f59227f 100644 --- a/src/main/java/com/fanruan/api/util/CodeKit.java +++ b/src/main/java/com/fanruan/api/util/CodeKit.java @@ -12,4 +12,12 @@ public class CodeKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + /** + * 将普通的java字符串编码成javascript代码 + * @param string4javascript 待编码的字符串 + * @return 编码后的代码 + * */ + public static String javascriptEncode(String string4javascript) { + return CommonCodeUtils.javascriptEncode(string4javascript); + } } diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 60d642b..9c6dc15 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -96,6 +96,13 @@ public class GeneralKit { public static Locale getLocale() { return FRContext.getLocale(); } - + /** + * 将路径节点数组用路径分隔符"/"连接起来 + * @param nodes 路径节点数组 + * @return 连接后的路径 + * */ + public static String pathJoin(String... nodes) { + return StableUtils.pathJoin(nodes); + } } diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 89de42a..b497b7e 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -8,6 +8,7 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; +import com.fr.stable.xml.XMLWriter; import java.io.InputStream; @@ -75,5 +76,12 @@ public class XmlKit { public static void writeXMLConnection(XMLPrintWriter writer, Connection connection) { DataCoreXmlUtils.writeXMLConnection(writer, connection); } - + /** + * 把一个XMLable写成字符串 + * @param xmlable xml文件 + * @return 返回字符串 + * */ + public static String writeXMLableAsString(XMLWriter xmlable){ + return GeneralXMLTools.writeXMLableAsString(xmlable); + } } diff --git a/src/main/java/com/fanruan/api/xml/component/FRFile.java b/src/main/java/com/fanruan/api/xml/component/FRFile.java new file mode 100644 index 0000000..e62b732 --- /dev/null +++ b/src/main/java/com/fanruan/api/xml/component/FRFile.java @@ -0,0 +1,13 @@ +package com.fanruan.api.xml.component; + +/** +* FR文件类,用于表示具有指定名字、类型和内容的文件 +* */ +public class FRFile extends com.fr.stable.xml.FRFile{ + /** + * 根据指定的文件类型,文件名以及文件内容生成一个文件 + * */ + public FRFile(String type, String filename, byte[] bytes){ + super(type, filename, bytes); + } +} diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index 45c6096..4803a7c 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -11,9 +11,40 @@ public class ArrayKitTest extends Prepare { public void isEmpty() throws Exception{ Object[] emptyArray = new Object[0]; Object[] notEmptyArray = new Object[1]; + Boolean[] booleanEmptyArray = new Boolean[0]; + Boolean[] booleanNotEmptyArray = new Boolean[1]; + Byte[] byteEmptyArray = new Byte[0]; + Byte[] byteNotEmptyArray = new Byte[1]; + Character[] charEmptyArray = new Character[0]; + Character[] charNotEmptyArray = new Character[1]; + Double[] doubleEmptyArray = new Double[0]; + Double[] doubleNotEmptyArray = new Double[1]; + Float[] floatEmptyArray = new Float[0]; + Float[] floatNotEmptyArray = new Float[1]; + Integer[] intEmptyArray = new Integer[0]; + Integer[] intNotEmptyArray = new Integer[1]; + Long[] longEmptyArray = new Long[0]; + Long[] longNotEmptyArray = new Long[1]; + Short[] shortEmptyArray = new Short[0]; + Short[] shortNotEmptyArray = new Short[1]; Assert.assertTrue(ArrayKit.isEmpty(emptyArray)); Assert.assertFalse(ArrayKit.isEmpty(notEmptyArray)); - + Assert.assertTrue(ArrayKit.isEmpty(booleanEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(booleanNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(byteEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(byteNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(charEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(charNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(doubleEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(doubleNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(floatEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(floatNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(intEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(intNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(longEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(longNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(shortEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(shortNotEmptyArray)); } @Test diff --git a/src/test/java/com/fanruan/api/util/CodeKitTest.java b/src/test/java/com/fanruan/api/util/CodeKitTest.java index 10853e6..4b11e3b 100644 --- a/src/test/java/com/fanruan/api/util/CodeKitTest.java +++ b/src/test/java/com/fanruan/api/util/CodeKitTest.java @@ -6,7 +6,7 @@ import org.junit.Test; public class CodeKitTest { @Test - public void passwordDecode(String passwordText) { - Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); + public void javascriptEncode() { + Assert.assertEquals(CodeKit.javascriptEncode("console.log(123)"), "console.log(123)"); } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 6ba3bf6..12882ee 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -55,4 +55,10 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } + @Test + public void pathJoin(){ + String strArray[] = {"abc", "def"}; + Assert.assertEquals(GeneralKit.pathJoin(strArray), "abc/def"); + } + } \ No newline at end of file