From 852b32943a8258830ff167d0758ef3b3f8f0b7eb Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Fri, 6 Sep 2019 11:38:04 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-1198=20JSON=E6=8F=92=E4=BB=B6=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/Parameter.java | 4 ---- .../com/fanruan/api/cal/ParameterKit.java | 8 +++++++ .../fanruan/api/conf/ConfigurationKit.java | 10 +++++++++ .../fanruan/api/data/AbstractDataModel.java | 4 ++++ .../api/data/AbstractDatabaseConnection.java | 4 ++++ .../api/data/AbstractParameterTableData.java | 4 ++++ .../com/fanruan/api/net/http/EntityKit.java | 21 +++++++++++++++++++ .../net/http/message/BasicNameValuePair.java | 9 ++++++++ .../java/com/fanruan/api/util/CodeKit.java | 10 +++++++++ .../com/fanruan/api/util/ComparatorKit.java | 15 +++++++++++++ src/main/java/com/fanruan/api/xml/XmlKit.java | 16 +++++++++----- 11 files changed, 96 insertions(+), 9 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/Parameter.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractDataModel.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractParameterTableData.java create mode 100644 src/main/java/com/fanruan/api/net/http/EntityKit.java create mode 100644 src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java create mode 100644 src/main/java/com/fanruan/api/util/ComparatorKit.java diff --git a/src/main/java/com/fanruan/api/cal/Parameter.java b/src/main/java/com/fanruan/api/cal/Parameter.java deleted file mode 100644 index 6375a76..0000000 --- a/src/main/java/com/fanruan/api/cal/Parameter.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.cal; - -public class Parameter extends com.fr.base.Parameter { -} diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 471d9fe..c1e1b68 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -136,4 +136,12 @@ public class ParameterKit { return parameters; } + /** + * 将ParameterProvider转化为Parameter + * @param providers 需要转换的ParameterProvider + * @return 转换后的Parameter + */ + public static Parameter[] providers2Parameter(ParameterProvider[] providers) { + return Parameter.providers2Parameter(providers); + } } diff --git a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java index b433465..43625ed 100644 --- a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java +++ b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.conf; +import com.fr.config.ConfigContext; import com.fr.config.Configuration; import com.fr.config.holder.ConfigChangeListener; import com.fr.transaction.Configurations; @@ -38,4 +39,13 @@ public class ConfigurationKit { }); } + /** + * 返回config实例,且config实例只存在一个 + * @param configuration Configuration类 + * @param + * @return config实例 + */ + public static T getConfigInstance(final Class configuration) { + return ConfigContext.getConfigInstance(configuration); + } } diff --git a/src/main/java/com/fanruan/api/data/AbstractDataModel.java b/src/main/java/com/fanruan/api/data/AbstractDataModel.java new file mode 100644 index 0000000..7ee273f --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractDataModel.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractDataModel extends com.fr.data.AbstractDataModel { +} diff --git a/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java b/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java new file mode 100644 index 0000000..925da74 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractDatabaseConnection extends com.fr.data.impl.AbstractDatabaseConnection { +} diff --git a/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java b/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java new file mode 100644 index 0000000..23c1f05 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractParameterTableData extends com.fr.data.AbstractParameterTableData { +} diff --git a/src/main/java/com/fanruan/api/net/http/EntityKit.java b/src/main/java/com/fanruan/api/net/http/EntityKit.java new file mode 100644 index 0000000..d1d7b3f --- /dev/null +++ b/src/main/java/com/fanruan/api/net/http/EntityKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.net.http; + +import com.fr.third.org.apache.http.HttpEntity; +import com.fr.third.org.apache.http.ParseException; +import com.fr.third.org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class EntityKit { + /** + * 利用defaultCharset字符集将HttpEntity对象转化为String对象 + * @param entity 需要转化为String的HttpEntity对象 + * @param defaultCharset 传入的字符集 + * @return HttpEntity对象转化为的String对象 + * @throws IOException + * @throws ParseException + */ + public static String toString(HttpEntity entity, String defaultCharset) throws IOException, ParseException { + return EntityUtils.toString(entity, defaultCharset); + } +} diff --git a/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java b/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java new file mode 100644 index 0000000..82ffb80 --- /dev/null +++ b/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java @@ -0,0 +1,9 @@ +package com.fanruan.api.net.http.message; +/** + * 键值对类 + */ +public class BasicNameValuePair extends com.fr.third.org.apache.http.message.BasicNameValuePair { + public BasicNameValuePair(String name, String value) { + super(name, value); + } +} diff --git a/src/main/java/com/fanruan/api/util/CodeKit.java b/src/main/java/com/fanruan/api/util/CodeKit.java index b819eb4..5c89421 100644 --- a/src/main/java/com/fanruan/api/util/CodeKit.java +++ b/src/main/java/com/fanruan/api/util/CodeKit.java @@ -12,4 +12,14 @@ public class CodeKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + + /** + * 将经过处理的中日韩文字符串解码成原先的中日韩文 + * @param text 经过处理的中日韩文字 + * @return 中日韩文字 + * @throws Exception + */ + public static String cjkDecode(String text) throws Exception { + return CodeUtils.cjkDecode(text); + } } diff --git a/src/main/java/com/fanruan/api/util/ComparatorKit.java b/src/main/java/com/fanruan/api/util/ComparatorKit.java new file mode 100644 index 0000000..39fddff --- /dev/null +++ b/src/main/java/com/fanruan/api/util/ComparatorKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.general.ComparatorUtils; + +public class ComparatorKit { + /** + * 比较两个Object对象是否相等 + * @param object1 第一个Object对象 + * @param object2 第二个Object对象 + * @return 相等返回True 不相等返回False + */ + public static boolean equals(Object object1, Object object2){ + return ComparatorUtils.equals(object1, object2); + } +} diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 89de42a..bcc1ae0 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -3,11 +3,8 @@ package com.fanruan.api.xml; import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.Connection; 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.ParameterProvider; +import com.fr.stable.xml.*; import java.io.InputStream; @@ -76,4 +73,13 @@ public class XmlKit { DataCoreXmlUtils.writeXMLConnection(writer, connection); } + /** + *读出xml参数 + * @param reader xml读出对象 + * @return 返回保存参数数组 + */ + public static ParameterProvider readParameter(XMLableReader reader) { + return StableXMLUtils.readParameter(reader); + } + }