forked from fanruan/finekit
richie
5 years ago
11 changed files with 224 additions and 37 deletions
@ -0,0 +1,37 @@
|
||||
package com.fanruan.api.cal; |
||||
|
||||
import com.fr.general.FArray; |
||||
import com.fr.stable.ArrayProvider; |
||||
|
||||
import java.util.Collection; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-29 |
||||
* 创建容器的工具类 |
||||
*/ |
||||
public class ContainerKit { |
||||
|
||||
/** |
||||
* 创建一个插件可识别的数组对象 |
||||
* |
||||
* @param array 原始数组 |
||||
* @param <T> 数组元素类型 |
||||
* @return 插件可识别的数组对象 |
||||
*/ |
||||
public static <T> ArrayProvider<T> newArray(T[] array) { |
||||
return new FArray<>(array); |
||||
} |
||||
|
||||
/** |
||||
* 创建一个插件可识别的数组对象 |
||||
* |
||||
* @param collection 原始集合 |
||||
* @param <T> 数组元素类型 |
||||
* @return 插件可识别的数组对象 |
||||
*/ |
||||
public static <T> ArrayProvider<T> newArray(Collection<T> collection) { |
||||
return new FArray<>(collection); |
||||
} |
||||
} |
@ -1,22 +0,0 @@
|
||||
package com.fanruan.api.consts; |
||||
import com.fr.stable.EncodeConstants; |
||||
|
||||
public class EncodeConstantsKit { |
||||
|
||||
public static final String ENCODING_UTF_8 = EncodeConstants.ENCODING_UTF_8; |
||||
|
||||
public static final String ENCODING_GBK = EncodeConstants.ENCODING_GBK; |
||||
|
||||
public static final String ENCODING_BIG5 = EncodeConstants.ENCODING_BIG5; |
||||
|
||||
public static final String ENCODING_ISO_8859_1 = EncodeConstants.ENCODING_ISO_8859_1; |
||||
|
||||
|
||||
public static final String ENCODING_UTF_16 = EncodeConstants.ENCODING_UTF_16; |
||||
|
||||
public static final String ENCODING_EUC_JP = EncodeConstants.ENCODING_EUC_JP; |
||||
|
||||
public static final String ENCODING_EUC_KR = EncodeConstants.ENCODING_EUC_KR; |
||||
|
||||
public static final String ENCODING_CP850 = EncodeConstants.ENCODING_CP850; |
||||
} |
@ -0,0 +1,48 @@
|
||||
package com.fanruan.api.macro; |
||||
|
||||
|
||||
/** |
||||
* 编码常量 |
||||
*/ |
||||
public interface EncodeConstants { |
||||
|
||||
/** |
||||
* utf-8编码 |
||||
*/ |
||||
String ENCODING_UTF_8 = com.fr.stable.EncodeConstants.ENCODING_UTF_8; |
||||
|
||||
/** |
||||
* gbk编码 |
||||
*/ |
||||
String ENCODING_GBK = com.fr.stable.EncodeConstants.ENCODING_GBK; |
||||
|
||||
/** |
||||
* big5编码,一般用于繁体中文 |
||||
*/ |
||||
String ENCODING_BIG5 = com.fr.stable.EncodeConstants.ENCODING_BIG5; |
||||
|
||||
/** |
||||
* ios-8859-1编码 |
||||
*/ |
||||
String ENCODING_ISO_8859_1 = com.fr.stable.EncodeConstants.ENCODING_ISO_8859_1; |
||||
|
||||
/** |
||||
* utf16编码 |
||||
*/ |
||||
String ENCODING_UTF_16 = com.fr.stable.EncodeConstants.ENCODING_UTF_16; |
||||
|
||||
/** |
||||
* euc-jp编码 |
||||
*/ |
||||
String ENCODING_EUC_JP = com.fr.stable.EncodeConstants.ENCODING_EUC_JP; |
||||
|
||||
/** |
||||
* euc-kr编码 |
||||
*/ |
||||
String ENCODING_EUC_KR = com.fr.stable.EncodeConstants.ENCODING_EUC_KR; |
||||
|
||||
/** |
||||
* cp850编码 |
||||
*/ |
||||
String ENCODING_CP850 = com.fr.stable.EncodeConstants.ENCODING_CP850; |
||||
} |
@ -1,20 +1,49 @@
|
||||
package com.fanruan.api.xml; |
||||
|
||||
import com.fr.general.xml.GeneralXMLTools; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
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.XMLPrintWriter; |
||||
|
||||
import java.io.InputStream; |
||||
|
||||
/** |
||||
* xml读写相关类 |
||||
*/ |
||||
public class XmlKit { |
||||
/** |
||||
* 从输入流中读取对象 |
||||
* @param xmlReadable xml读取对象 |
||||
* @param inputStream xml输入流 |
||||
* |
||||
* @param read xml读取对象 |
||||
* @param in xml输入流 |
||||
*/ |
||||
public static void readInputStreamXML(XMLReadable read, InputStream in) throws Exception { |
||||
XMLTools.readInputStreamXML(read, in); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 将xml读取为具体的java对象 |
||||
* |
||||
* @param reader xml读取器 |
||||
* @return java对象 |
||||
*/ |
||||
public static XMLable readXMLable(XMLableReader reader) { |
||||
return GeneralXMLTools.readXMLable(reader); |
||||
} |
||||
|
||||
/** |
||||
* 将java对象写为xml文件 |
||||
* |
||||
* @param writer xml写入器 |
||||
* @param xml 实际java对象 |
||||
* @param tagName xml标签名 |
||||
*/ |
||||
public static void readInputStreamXML(XMLReadable xmlReadable, InputStream inputStream) throws Exception { |
||||
XMLTools.readInputStreamXML(xmlReadable, inputStream); |
||||
public static void writeXMLable(XMLPrintWriter writer, XMLable xml, String tagName) { |
||||
GeneralXMLTools.writeXMLable(writer, xml, tagName); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
@ -0,0 +1,24 @@
|
||||
package com.fanruan.api.cal; |
||||
|
||||
import com.fr.stable.ArrayProvider; |
||||
import com.fr.third.guava.collect.Lists; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-29 |
||||
*/ |
||||
public class ContainerKitTest { |
||||
|
||||
@Test |
||||
public void newArray() { |
||||
|
||||
ArrayProvider<String> array = ContainerKit.newArray(new String[]{"abc", "xyz"}); |
||||
Assert.assertEquals("xyz", array.elementAt(1)); |
||||
|
||||
ArrayProvider<String> array2 = ContainerKit.newArray(Lists.newArrayList("abc", "xyz")); |
||||
Assert.assertEquals("abc", array2.elementAt(0)); |
||||
} |
||||
} |
Loading…
Reference in new issue