Browse Source

空标记

remotes/1611766341912730171/master
richie 5 years ago
parent
commit
7bd623aeed
  1. 8
      src/main/java/com/fanruan/api/cal/FormulaKit.java
  2. 5
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  3. 5
      src/main/java/com/fanruan/api/data/TableDataKit.java
  4. 46
      src/main/java/com/fanruan/api/login/LoginKit.java
  5. 7
      src/main/java/com/fanruan/api/net/NetworkKit.java
  6. 3
      src/main/java/com/fanruan/api/session/SessionKit.java
  7. 28
      src/main/java/com/fanruan/api/util/GeneralKit.java

8
src/main/java/com/fanruan/api/cal/FormulaKit.java

@ -6,6 +6,8 @@ import com.fr.script.Calculator;
import com.fr.stable.FormulaProvider; import com.fr.stable.FormulaProvider;
import com.fr.stable.UtilEvalError; import com.fr.stable.UtilEvalError;
import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.CalculatorProvider;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* @author richie * @author richie
@ -21,7 +23,7 @@ public class FormulaKit {
* @return 公式计算后的结果值 * @return 公式计算后的结果值
* @throws KitError 如果计算过程中出现错误则抛出此异常 * @throws KitError 如果计算过程中出现错误则抛出此异常
*/ */
public static Object eval(String formula) throws KitError { public static @Nullable Object eval(String formula) throws KitError {
return eval(Calculator.createCalculator(), formula); return eval(Calculator.createCalculator(), formula);
} }
@ -32,7 +34,7 @@ public class FormulaKit {
* @return 公式计算后的结果值 * @return 公式计算后的结果值
* @throws KitError 如果计算过程中出现错误则抛出此异常 * @throws KitError 如果计算过程中出现错误则抛出此异常
*/ */
public static Object eval(CalculatorProvider calculator, String formula) throws KitError { public static @Nullable Object eval(CalculatorProvider calculator, String formula) throws KitError {
try { try {
return BaseFormula.createFormulaBuilder().build(formula).eval(calculator); return BaseFormula.createFormulaBuilder().build(formula).eval(calculator);
} catch (UtilEvalError u) { } catch (UtilEvalError u) {
@ -45,7 +47,7 @@ public class FormulaKit {
* @param content 公式的内容 * @param content 公式的内容
* @return 公式对象 * @return 公式对象
*/ */
public static FormulaProvider newFormula(Object content) { public static @NotNull FormulaProvider newFormula(Object content) {
return BaseFormula.createFormulaBuilder().build(content); return BaseFormula.createFormulaBuilder().build(content);
} }
} }

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

@ -4,6 +4,7 @@ import com.fr.base.ParameterHelper;
import com.fr.base.ParameterMapNameSpace; import com.fr.base.ParameterMapNameSpace;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.script.NameSpace; import com.fr.stable.script.NameSpace;
import org.jetbrains.annotations.NotNull;
import java.util.Map; import java.util.Map;
@ -20,7 +21,7 @@ public class ParameterKit {
* @param text 公式内容 * @param text 公式内容
* @return 参数数组 * @return 参数数组
*/ */
public static ParameterProvider[] analyze4ParametersFromFormula(String text) { public static @NotNull ParameterProvider[] analyze4ParametersFromFormula(String text) {
return ParameterHelper.analyze4ParametersFromFormula(text); return ParameterHelper.analyze4ParametersFromFormula(text);
} }
@ -29,7 +30,7 @@ public class ParameterKit {
* @param map 参数键值对 * @param map 参数键值对
* @return 名字空间用于传递给算子做计算 * @return 名字空间用于传递给算子做计算
*/ */
public static NameSpace createParameterMapNameSpace(Map<String, Object> map) { public static @NotNull NameSpace createParameterMapNameSpace(Map<String, Object> map) {
return ParameterMapNameSpace.create(map); return ParameterMapNameSpace.create(map);
} }
} }

5
src/main/java/com/fanruan/api/data/TableDataKit.java

@ -6,6 +6,7 @@ import com.fr.data.api.TableDataAssist;
import com.fr.script.Calculator; import com.fr.script.Calculator;
import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.CalculatorProvider;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* @author richie * @author richie
@ -25,7 +26,7 @@ public class TableDataKit {
* @param name 数据集名字 * @param name 数据集名字
* @return 数据集 * @return 数据集
*/ */
public static TableData getTableData(@NotNull CalculatorProvider cal, String name) { public static @Nullable TableData getTableData(@NotNull CalculatorProvider cal, String name) {
return TableDataAssist.getTableData((Calculator) cal, name); return TableDataAssist.getTableData((Calculator) cal, name);
} }
@ -39,7 +40,7 @@ public class TableDataKit {
* @param name 数据集名字 * @param name 数据集名字
* @return 数据集 * @return 数据集
*/ */
public static TableData getTableData(@NotNull TableDataSource source, String name) { public static @Nullable TableData getTableData(@NotNull TableDataSource source, String name) {
return TableDataAssist.getTableData(source, name); return TableDataAssist.getTableData(source, name);
} }
} }

46
src/main/java/com/fanruan/api/login/LoginKit.java

@ -0,0 +1,46 @@
package com.fanruan.api.login;
import com.fr.decision.authorize.Passport;
import com.fr.decision.authorize.impl.HttpPassport;
import com.fr.decision.config.FSConfig;
import org.jetbrains.annotations.Nullable;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-16
*/
public class LoginKit {
/**
* 获取决策平台设置的认证类型
* @return 认证对象
*/
public static Passport getCurrentPassport() {
return FSConfig.getInstance().getPassport();
}
/**
* 获取http认证的地址
* @return http认证地址
*/
public static @Nullable String getHttpPassportUrl() {
Passport passport = getCurrentPassport();
if (passport instanceof HttpPassport) {
return ((HttpPassport) passport).getUrl();
}
return null;
}
/**
* 获取http认证的秘钥
* @return http认证地址
*/
public static @Nullable String getHttpPassportKey() {
Passport passport = getCurrentPassport();
if (passport instanceof HttpPassport) {
return ((HttpPassport) passport).getPublicKey();
}
return null;
}
}

7
src/main/java/com/fanruan/api/net/NetworkKit.java

@ -1,6 +1,7 @@
package com.fanruan.api.net; package com.fanruan.api.net;
import com.fr.data.NetworkHelper; import com.fr.data.NetworkHelper;
import org.jetbrains.annotations.Nullable;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -80,7 +81,7 @@ public class NetworkKit {
* @param req HTTP请求 * @param req HTTP请求
* @return session编号 * @return session编号
*/ */
public static String getHTTPRequestSessionIDParameter(HttpServletRequest req) { public static @Nullable String getHTTPRequestSessionIDParameter(HttpServletRequest req) {
return NetworkHelper.getHTTPRequestSessionIDParameter(req); return NetworkHelper.getHTTPRequestSessionIDParameter(req);
} }
@ -102,7 +103,7 @@ public class NetworkKit {
* @param paraName 参数名 * @param paraName 参数名
* @return 字符型参数值 * @return 字符型参数值
*/ */
public static String getHTTPRequestParameter(HttpServletRequest req, String paraName) { public static @Nullable String getHTTPRequestParameter(HttpServletRequest req, String paraName) {
return NetworkHelper.getHTTPRequestParameter(req, paraName); return NetworkHelper.getHTTPRequestParameter(req, paraName);
} }
@ -113,7 +114,7 @@ public class NetworkKit {
* @param paraNames 参数列表 * @param paraNames 参数列表
* @return 字符型参数值 * @return 字符型参数值
*/ */
public static String getHTTPRequestParameter(HttpServletRequest req, String... paraNames) { public static @Nullable String getHTTPRequestParameter(HttpServletRequest req, String... paraNames) {
return NetworkHelper.getHTTPRequestParameter(req, paraNames); return NetworkHelper.getHTTPRequestParameter(req, paraNames);
} }
} }

3
src/main/java/com/fanruan/api/session/SessionKit.java

@ -3,6 +3,7 @@ package com.fanruan.api.session;
import com.fr.stable.web.SessionProvider; import com.fr.stable.web.SessionProvider;
import com.fr.web.core.SessionPoolManager; import com.fr.web.core.SessionPoolManager;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* @author richie * @author richie
@ -16,7 +17,7 @@ public class SessionKit {
* @param sessionID 会话唯一标识符 * @param sessionID 会话唯一标识符
* @return 会话对象 * @return 会话对象
*/ */
public static SessionProvider getSession(@NotNull String sessionID) { public static @Nullable SessionProvider getSession(@NotNull String sessionID) {
return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class); return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class);
} }
} }

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

@ -1,5 +1,9 @@
package com.fanruan.api.util; package com.fanruan.api.util;
import com.fr.general.GeneralUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException; import java.io.IOException;
/** /**
@ -14,8 +18,8 @@ public class GeneralKit {
* *
* @return 表示系统MAC地址的字符串 * @return 表示系统MAC地址的字符串
*/ */
public static String getMacAddress() throws IOException { public static @NotNull String getMacAddress() throws IOException {
return com.fr.general.GeneralUtils.getMacAddress(); return GeneralUtils.getMacAddress();
} }
/** /**
@ -23,16 +27,26 @@ public class GeneralKit {
* @param obj 待转换的对象 * @param obj 待转换的对象
* @return 文本值 * @return 文本值
*/ */
public static String objectToString(Object obj) { public static @NotNull String objectToString(Object obj) {
return com.fr.general.GeneralUtils.objectToString(obj); return GeneralUtils.objectToString(obj);
} }
/** /**
* 任意对象转换为数值 * 任意对象转换为数值如果无法转换为数值就返回0
* @param obj 待转换的对象 * @param obj 待转换的对象
* @return 数值 * @return 数值
*/ */
public static Number objectToNumber(Object obj) { public static @NotNull Number objectToNumber(Object obj) {
return com.fr.general.GeneralUtils.objectToNumber(obj); return GeneralUtils.objectToNumber(obj);
}
/**
* 任意对象转换为数值如果无法转换为数值根据returnNull参数决定返回0或者返回null
* @param obj 待转换的对象
* @param returnNull 无法转换时是否返回null
* @return 数值对象或者null
*/
public static @Nullable Number objectToNumber(Object obj, boolean returnNull) {
return GeneralUtils.objectToNumber(obj, returnNull);
} }
} }

Loading…
Cancel
Save