From 24b1d5115522015a541b30f2bd55223ecf1c9813 Mon Sep 17 00:00:00 2001 From: yulichang <570810310@qq.com> Date: Sat, 14 Sep 2024 20:23:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86idea=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yulichang/toolkit/MPJStringUtils.java | 87 ++----------------- .../yulichang/wrapper/interfaces/FuncStr.java | 42 ++++----- 2 files changed, 27 insertions(+), 102 deletions(-) diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MPJStringUtils.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MPJStringUtils.java index 50ec008..790c7d4 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MPJStringUtils.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/toolkit/MPJStringUtils.java @@ -33,14 +33,14 @@ import static java.util.stream.Collectors.joining; * @author hcl * @since 2016-08-18 */ -@SuppressWarnings("ALL") +@SuppressWarnings("unused") public final class MPJStringUtils { /** * 判断是否是中文 */ public static boolean isChinese(String str) { - if(isBlank(str)) + if (isBlank(str)) return false; char c = str.charAt(0); return c >= 0x4E00 && c <= 0x9FA5; @@ -70,13 +70,6 @@ public final class MPJStringUtils { */ private static final Pattern CAPITAL_MODE = Pattern.compile("^[0-9A-Z/_]+$"); - /** - * 字符串去除空白内容 - * - * - */ - private static final Pattern REPLACE_BLANK = Pattern.compile("'|\"|\\<|\\>|&|\\*|\\+|=|#|-|;|\\s*|\t|\r|\n"); - /** * 判断字符串中是否全是空白字符 * @@ -99,7 +92,6 @@ public final class MPJStringUtils { * 对象转为字符串去除左右空格 * * @param o 带转换对象 - * @return */ public static String toStringTrim(Object o) { return String.valueOf(o).trim(); @@ -150,7 +142,7 @@ public final class MPJStringUtils { * @return 字段名 */ public static String getTargetColumn(String column) { - if(isChinese(column)){ + if (isChinese(column)) { return column; } if (isNotColumnName(column)) { @@ -328,7 +320,7 @@ public final class MPJStringUtils { if (isBlank(concatStr)) { concatStr = StringPool.EMPTY; } - if (str == null || str.length() == 0) { + if (str == null || str.isEmpty()) { return str; } @@ -400,33 +392,6 @@ public final class MPJStringUtils { return matches(".*[A-Z]+.*", word) && matches(".*[/_]+.*", word); } - /** - * 判断是否以某个字符串结尾(区分大小写) - * Check if a String ends with a specified suffix. - *

- * nulls are handled without exceptions. Two null - * references are considered to be equal. The comparison is case sensitive. - *

- *

- *

-     * StringUtils.endsWith(null, null)      = true
-     * StringUtils.endsWith(null, "abcdef")  = false
-     * StringUtils.endsWith("def", null)     = false
-     * StringUtils.endsWith("def", "abcdef") = true
-     * StringUtils.endsWith("def", "ABCDEF") = false
-     * 
- *

- * - * @param str the String to check, may be null - * @param suffix the suffix to find, may be null - * @return true if the String ends with the suffix, case - * sensitive, or both null - * @see String#endsWith(String) - * @since 2.4 - */ - public static boolean endsWith(String str, String suffix) { - return endsWith(str, suffix, false); - } /** * Check if a String ends with a specified suffix (optionally case @@ -469,10 +434,8 @@ public final class MPJStringUtils { * @return ignore */ public static String prefixToLower(String rawString, int index) { - StringBuilder field = new StringBuilder(); - field.append(rawString.substring(0, index).toLowerCase()); - field.append(rawString.substring(index)); - return field.toString(); + return rawString.substring(0, index).toLowerCase() + + rawString.substring(index); } /** @@ -596,42 +559,4 @@ public final class MPJStringUtils { } return true; } - - /** - * SQL 注入字符串去除空白内容: - * - * - * @param str 字符串 - */ - public static String sqlInjectionReplaceBlank(String str) { - if (MPJSqlInjectionUtils.check(str)) { - /** - * 过滤sql黑名单字符,存在 SQL 注入,去除空白内容 - */ - str = replaceAllBlank(str); - - } - return str; - } - - /** - * 字符串去除空白内容: - * - * - * @param str 字符串 - */ - public static String replaceAllBlank(String str) { - Matcher matcher = REPLACE_BLANK.matcher(str); - return matcher.replaceAll(""); - } } diff --git a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java index 2fb1d38..d544a21 100644 --- a/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java +++ b/mybatis-plus-join-core/src/main/java/com/github/yulichang/wrapper/interfaces/FuncStr.java @@ -24,7 +24,7 @@ import java.util.List; * * @since 1.3.12 */ -@SuppressWarnings("ALL") +@SuppressWarnings({"unused", "unchecked"}) public interface FuncStr extends Serializable { /** @@ -164,10 +164,10 @@ public interface FuncStr extends Serializable { *

例1: gtSql("id", "1, 2, 3, 4, 5, 6")

*

例1: gtSql("id", "select id from table where name = 'JunJun'")

* - * @param condition - * @param column - * @param inValue - * @return + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children */ Children gtSql(boolean condition, R column, String inValue); @@ -183,10 +183,10 @@ public interface FuncStr extends Serializable { *

例1: geSql("id", "1, 2, 3, 4, 5, 6")

*

例1: geSql("id", "select id from table where name = 'JunJun'")

* - * @param condition - * @param column - * @param inValue - * @return + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children */ Children geSql(boolean condition, R column, String inValue); @@ -202,10 +202,10 @@ public interface FuncStr extends Serializable { *

例1: ltSql("id", "1, 2, 3, 4, 5, 6")

*

例1: ltSql("id", "select id from table where name = 'JunJun'")

* - * @param condition - * @param column - * @param inValue - * @return + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children */ Children ltSql(boolean condition, R column, String inValue); @@ -221,10 +221,10 @@ public interface FuncStr extends Serializable { *

例1: leSql("id", "1, 2, 3, 4, 5, 6")

*

例1: leSql("id", "select id from table where name = 'JunJun'")

* - * @param condition - * @param column - * @param inValue - * @return + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children */ Children leSql(boolean condition, R column, String inValue); @@ -240,10 +240,10 @@ public interface FuncStr extends Serializable { *

例1: eqSql("id", "1, 2, 3, 4, 5, 6")

*

例1: eqSql("id", "select id from table where name = 'JunJun'")

* - * @param condition - * @param column - * @param inValue - * @return + * @param condition 执行条件 + * @param column 字段 + * @param inValue sql语句 + * @return children */ Children eqSql(boolean condition, R column, String inValue);