Browse Source

update: finekit的一些补充。

master
zjz1993 5 years ago
parent
commit
fd8d12543a
  1. 20
      src/main/java/com/fanruan/api/attachment/Attachment.java
  2. 23
      src/main/java/com/fanruan/api/cal/namespace/FArray.java
  3. 10
      src/main/java/com/fanruan/api/i18n/I18nKit.java
  4. 2
      src/main/java/com/fanruan/api/util/ArrayKit.java
  5. 8
      src/main/java/com/fanruan/api/util/CodeKit.java
  6. 9
      src/main/java/com/fanruan/api/util/GeneralKit.java
  7. 10
      src/main/java/com/fanruan/api/xml/XmlKit.java
  8. 13
      src/main/java/com/fanruan/api/xml/component/FRFile.java
  9. 33
      src/test/java/com/fanruan/api/util/ArrayKitTest.java
  10. 4
      src/test/java/com/fanruan/api/util/CodeKitTest.java
  11. 6
      src/test/java/com/fanruan/api/util/GeneralKitTest.java

20
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);
}
}

23
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<T> extends com.fr.general.FArray{
public FArray(){
}
/**
* 通过使用一个无需集合生成的链表类
* */
public FArray(Collection<T> collection) {
super(collection);
}
/**
* 通过使用一个数组生成的链表类
* */
public FArray(T[] array) {
super(array);
}
}

10
src/main/java/com/fanruan/api/i18n/I18nKit.java

@ -11,4 +11,14 @@ public class I18nKit {
public static String getLocText(String string) { public static String getLocText(String string) {
return InterProviderFactory.getProvider().getLocText(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);
}
} }

2
src/main/java/com/fanruan/api/util/ArrayKit.java

@ -55,7 +55,7 @@ public class ArrayKit {
* @param array 源数组 * @param array 源数组
* @return 返回数组判断为空的结果 * @return 返回数组判断为空的结果
*/ */
public static boolean isEmpty(Object[] array) { public static <T> boolean isEmpty(T[] array) {
return ArrayUtils.isEmpty(array); return ArrayUtils.isEmpty(array);
} }
/** /**

8
src/main/java/com/fanruan/api/util/CodeKit.java

@ -12,4 +12,12 @@ public class CodeKit {
public static String passwordDecode(String passwordText) { public static String passwordDecode(String passwordText) {
return CodeUtils.passwordDecode(passwordText); return CodeUtils.passwordDecode(passwordText);
} }
/**
* 将普通的java字符串编码成javascript代码
* @param string4javascript 待编码的字符串
* @return 编码后的代码
* */
public static String javascriptEncode(String string4javascript) {
return CommonCodeUtils.javascriptEncode(string4javascript);
}
} }

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

@ -96,6 +96,13 @@ public class GeneralKit {
public static Locale getLocale() { public static Locale getLocale() {
return FRContext.getLocale(); return FRContext.getLocale();
} }
/**
* 将路径节点数组用路径分隔符"/"连接起来
* @param nodes 路径节点数组
* @return 连接后的路径
* */
public static String pathJoin(String... nodes) {
return StableUtils.pathJoin(nodes);
}
} }

10
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.XMLTools;
import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLable;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.stable.xml.XMLWriter;
import java.io.InputStream; import java.io.InputStream;
@ -75,5 +76,12 @@ public class XmlKit {
public static void writeXMLConnection(XMLPrintWriter writer, Connection connection) { public static void writeXMLConnection(XMLPrintWriter writer, Connection connection) {
DataCoreXmlUtils.writeXMLConnection(writer, connection); DataCoreXmlUtils.writeXMLConnection(writer, connection);
} }
/**
* 把一个XMLable写成字符串
* @param xmlable xml文件
* @return 返回字符串
* */
public static String writeXMLableAsString(XMLWriter xmlable){
return GeneralXMLTools.writeXMLableAsString(xmlable);
}
} }

13
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);
}
}

33
src/test/java/com/fanruan/api/util/ArrayKitTest.java

@ -11,9 +11,40 @@ public class ArrayKitTest extends Prepare {
public void isEmpty() throws Exception{ public void isEmpty() throws Exception{
Object[] emptyArray = new Object[0]; Object[] emptyArray = new Object[0];
Object[] notEmptyArray = new Object[1]; 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.assertTrue(ArrayKit.isEmpty(emptyArray));
Assert.assertFalse(ArrayKit.isEmpty(notEmptyArray)); 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 @Test

4
src/test/java/com/fanruan/api/util/CodeKitTest.java

@ -6,7 +6,7 @@ import org.junit.Test;
public class CodeKitTest { public class CodeKitTest {
@Test @Test
public void passwordDecode(String passwordText) { public void javascriptEncode() {
Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); Assert.assertEquals(CodeKit.javascriptEncode("console.log(123)"), "console.log(123)");
} }
} }

6
src/test/java/com/fanruan/api/util/GeneralKitTest.java

@ -55,4 +55,10 @@ public class GeneralKitTest extends Prepare {
Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA);
} }
@Test
public void pathJoin(){
String strArray[] = {"abc", "def"};
Assert.assertEquals(GeneralKit.pathJoin(strArray), "abc/def");
}
} }
Loading…
Cancel
Save