Browse Source

Merge pull request #5 in TC/finekit from ~ZHAOJUNZHE/finekit:master to master

* commit '0b5d9ac6854a9a20fb427dd866c5a522b21ac3d8':
  feat: 针对pr意见进行修改。
  feat:删除重复的方法
  feat: 一些方法的增加
master
superman 5 years ago
parent
commit
97fc5f95b1
  1. 22
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  2. 50
      src/main/java/com/fanruan/api/design/DesignKit.java
  3. 8
      src/main/java/com/fanruan/api/design/ui/component/BasicPane.java
  4. 4
      src/main/java/com/fanruan/api/design/ui/component/ParameterTableModel.java
  5. 5
      src/main/java/com/fanruan/api/design/ui/component/UIIntNumberField.java
  6. 13
      src/main/java/com/fanruan/api/design/ui/component/UITableEditAction.java
  7. 8
      src/main/java/com/fanruan/api/design/ui/component/UpdateAction.java
  8. 14
      src/main/java/com/fanruan/api/i18n/I18nKit.java
  9. 7
      src/main/java/com/fanruan/api/layout/LayoutKit.java
  10. 18
      src/main/java/com/fanruan/api/security/SecurityKit.java
  11. 3
      src/main/java/com/fanruan/api/util/GeneralKit.java
  12. 12
      src/main/java/com/fanruan/api/util/IOKit.java
  13. 20
      src/main/java/com/fanruan/api/xml/XmlKit.java
  14. 18
      src/main/java/com/fanruan/api/xml/xml/component/XMLFileManager.java
  15. 19
      src/test/java/com/fanruan/api/util/GeneralKitTest.java

22
src/main/java/com/fanruan/api/cal/ParameterKit.java

@ -2,6 +2,7 @@ package com.fanruan.api.cal;
import com.fr.base.ParameterHelper;
import com.fr.base.ParameterMapNameSpace;
import com.fr.script.CalculatorMap;
import com.fr.stable.ParameterProvider;
import com.fr.stable.script.NameSpace;
import org.jetbrains.annotations.NotNull;
@ -14,8 +15,7 @@ import java.util.Map;
* Created by richie on 2019-08-16
* 参数相关的工具类
*/
public class ParameterKit {
public class ParameterKit{
/**
* 分析公式中所携带的参数
* @param text 公式内容
@ -24,6 +24,15 @@ public class ParameterKit {
public static @NotNull ParameterProvider[] analyze4ParametersFromFormula(String text) {
return ParameterHelper.analyze4ParametersFromFormula(text);
}
/**
* 分析一组字符串中的参数
* @param paramTexts 字符串组
* @param isFormula 是否是公式类型的字符串数组
* @return 参数集合
*/
public static @NotNull ParameterProvider[] analyze4Parameters(String[] paramTexts, boolean isFormula) {
return ParameterHelper.analyze4Parameters(paramTexts, isFormula);
}
/**
* 创建一个用于计算的参数对名字空间
@ -33,4 +42,13 @@ public class ParameterKit {
public static @NotNull NameSpace createParameterMapNameSpace(Map<String, Object> map) {
return ParameterMapNameSpace.create(map);
}
/**
* 创建一个用于计算的参数对名字空间
* @param ps ParameterProvider的数组
* @return 名字空间用于传递给算子做计算
*/
public static @NotNull ParameterMapNameSpace createParameterProvider(ParameterProvider[] ps) {
return ParameterMapNameSpace.create(ps);
}
}

50
src/main/java/com/fanruan/api/design/DesignKit.java

@ -0,0 +1,50 @@
package com.fanruan.api.design;
import com.fr.base.TableData;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.gui.itextfield.UIIntNumberField;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
public class DesignKit {
/**
* 直接预览数据集没有实际值及显示值
* @param tableData 数据集
*/
public static void previewTableData(TableData tableData){
PreviewTablePane.previewTableData(tableData, -1, -1);
}
/**
* 标题布局
* @param components 组件
* @param rowSize 行宽
* @param columnSize 列宽
* @return 布局后的组件
*/
public static JPanel createTableLayoutPane(Component[][] components, double[] rowSize, double[] columnSize) {
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
/**
* 生成一个边界布局
* @param args 布局内部的元素位置等
* @return 具有边界布局的面板
*/
public static JPanel createBorderLayoutPane(Object... args) {
return GUICoreUtils.createBorderLayoutPane(args);
}
/**
* 产生一个Flow Pane, flowAligment是FlowLayout.LEFT, CENTER, RIGHT.
* @param comps 组件
* @param flowAlignment 对齐方式
* @return 具有边界布局的面板
*/
public static JPanel createFlowPane(Component comps, int flowAlignment) {
return GUICoreUtils.createFlowPane(comps,flowAlignment);
}
public static class UIIntNumberField extends com.fr.design.gui.itextfield.UIIntNumberField{
}
}

8
src/main/java/com/fanruan/api/design/ui/component/BasicPane.java

@ -0,0 +1,8 @@
package com.fanruan.api.design.ui.component;
public class BasicPane extends com.fr.design.dialog.BasicPane{
@Override
protected String title4PopupWindow() {
return "";
}
}

4
src/main/java/com/fanruan/api/design/ui/component/ParameterTableModel.java

@ -0,0 +1,4 @@
package com.fanruan.api.design.ui.component;
public class ParameterTableModel extends com.fr.design.gui.itableeditorpane.ParameterTableModel{
}

5
src/main/java/com/fanruan/api/design/ui/component/UIIntNumberField.java

@ -0,0 +1,5 @@
package com.fanruan.api.design.ui.component;
public class UIIntNumberField extends com.fr.design.gui.itextfield.UIIntNumberField{
}

13
src/main/java/com/fanruan/api/design/ui/component/UITableEditAction.java

@ -0,0 +1,13 @@
package com.fanruan.api.design.ui.component;
import java.awt.event.ActionEvent;
public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction{
@Override
public void checkEnabled() {
}
@Override
public void actionPerformed(ActionEvent e) {
}
}

8
src/main/java/com/fanruan/api/design/ui/component/UpdateAction.java

@ -0,0 +1,8 @@
package com.fanruan.api.design.ui.component;
import java.awt.event.ActionEvent;
public class UpdateAction extends com.fr.design.actions.UpdateAction{
@Override
public void actionPerformed(ActionEvent evt) {}
}

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

@ -0,0 +1,14 @@
package com.fanruan.api.i18n;
import com.fr.locale.InterProviderFactory;
public class I18nKit {
/**
* 获取国际化文本
*
* @param string 需要国际化的值对应的键
* @return 返回国际化文本
*/
public static String getLocText(String string) {
return InterProviderFactory.getProvider().getLocText(string);
}
}

7
src/main/java/com/fanruan/api/layout/LayoutKit.java

@ -0,0 +1,7 @@
package com.fanruan.api.layout;
import com.fr.design.layout.TableLayout;
public class LayoutKit {
public static final double PREFERRED = TableLayout.PREFERRED;
public static final double FILL = TableLayout.FILL;
}

18
src/main/java/com/fanruan/api/security/SecurityKit.java

@ -1,5 +1,7 @@
package com.fanruan.api.security;
import com.fr.security.SecurityToolbox;
/**
* @author richie
* @version 10.0
@ -7,4 +9,20 @@ package com.fanruan.api.security;
* 文本加密解密相关的工具类
*/
public class SecurityKit {
/**
* RSA加密
* @param plainText 要加密的文本内容
* @return 加密后的内容
*/
public static String encrypt(String plainText) {
return SecurityToolbox.encrypt(plainText);
}
/**
* RSA解密
* @param cipherText 密文数据
* @return 解密后的内容
*/
public static String decrypt(String cipherText) {
return SecurityToolbox.decrypt(cipherText);
}
}

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

@ -2,10 +2,12 @@ package com.fanruan.api.util;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.third.guava.base.Objects;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.util.Map;
/**
* @author richie
@ -13,7 +15,6 @@ import java.io.IOException;
* Created by richie on 2019-08-09
*/
public class GeneralKit {
/**
* 返回系统的首选MAC地址
*

12
src/main/java/com/fanruan/api/util/IOKit.java

@ -2,6 +2,7 @@ package com.fanruan.api.util;
import com.fr.general.CommonIOUtils;
import com.fr.general.IOUtils;
import com.fr.io.utils.ResourceIOUtils;
import javax.swing.*;
import java.awt.image.BufferedImage;
@ -21,6 +22,17 @@ import java.nio.charset.Charset;
* Created by richie on 2019-08-16
*/
public class IOKit {
/**
* 读取文件到流
* 相对路径下如果是仓库资源从仓库读取其它从本地读取
* 据对路径按绝对路径读
*
* @param path 路径
* @return
*/
public static InputStream read(String path) {
return ResourceIOUtils.read(path);
}
/**
* 重命名指定的文件为另外一个文件.(不抛异常)

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

@ -0,0 +1,20 @@
package com.fanruan.api.xml;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLableReader;
import com.fr.stable.xml.XMLPrintWriter;
import java.io.InputStream;
public class XmlKit {
/**
* 从输入流中读取对象
* @param xmlReadable xml读取对象
* @param inputStream xml输入流
*
*/
public static void readInputStreamXML(XMLReadable xmlReadable, InputStream inputStream) throws Exception {
XMLTools.readInputStreamXML(xmlReadable, inputStream);
}
}

18
src/main/java/com/fanruan/api/xml/xml/component/XMLFileManager.java

@ -0,0 +1,18 @@
package com.fanruan.api.xml.xml.component;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
public class XMLFileManager extends com.fr.file.XMLFileManager {
@Override
public String fileName() {
return "";
}
@Override
public void writeXML(XMLPrintWriter writer) {
}
@Override
public void readXML(XMLableReader reader) {
}
}

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

@ -1,6 +1,7 @@
package com.fanruan.api.util;
import com.fanruan.api.Prepare;
import com.fr.third.guava.base.Objects;
import com.fr.general.GeneralUtils;
import com.fr.third.javax.persistence.criteria.CriteriaBuilder;
import org.junit.Assert;
@ -19,6 +20,24 @@ public class GeneralKitTest extends Prepare {
}
@Test
public void equals() throws Exception{
Integer x = 5;
Integer y = 10;
Integer z =5;
Short a = 5;
Assert.assertEquals(GeneralKit.equals(x, y), false);
Assert.assertEquals(GeneralKit.equals(x, z), true);
Assert.assertEquals(GeneralKit.equals(z, a), false);
}
@Test
public void hashCodes() {
class A {
}
;
Object a = new A();
Assert.assertEquals(GeneralKit.hashCode(a), Objects.hashCode(a));
}
public void objectToString() {
Integer s = new Integer(1);
Assert.assertEquals(GeneralKit.objectToString(s),"1");

Loading…
Cancel
Save