类 StringUtils
java.lang.Object
com.baomidou.mybatisplus.core.toolkit.StringUtils
String 工具类
- 从以下版本开始:
- 2016-08-18
- 作者:
- D.Yang, hcl, hcl
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String
camelToHyphen
(String input) 驼峰转连字符static String
camelToUnderline
(String param) 字符串驼峰转下划线格式static boolean
checkValNotNull
(Object object) 判断对象是否不为空static boolean
checkValNull
(Object object) 判断对象是否为空static String
concatCapitalize
(String concatStr, String str) 拼接字符串第二个字符串第一个字母大写static boolean
containsUpperCase
(String word) 包含大写字母static boolean
判断是否以某个字符串结尾(区分大小写) Check if a String ends with a specified suffix.static boolean
equals
(CharSequence cs1, CharSequence cs2) 比较两个字符串,相同则返回true。static String
firstToLowerCase
(String param) 首字母转换小写static String
getTargetColumn
(String column) 获取真正的字段名static boolean
isBlank
(CharSequence cs) 判断字符串中是否全是空白字符static boolean
判断字符串是不是驼峰命名 包含 '_' 不算 首字母大写的不算static boolean
isCapitalMode
(String word) 是否为大写命名static boolean
isCharSequence
(Class<?> clazz) 是否为CharSequence类型static boolean
isEmpty
(CharSequence cs) static boolean
isMixedMode
(String word) 是否为驼峰下划线混合命名static boolean
static boolean
isNotColumnName
(String str) 判断字符串是否符合数据库字段的命名static boolean
static boolean
正则表达式匹配static String
prefixToLower
(String rawString, int index) 前n个首字母小写,之后字符大小写的不变static String
使用单引号包含字符串static String
quotaMarkList
(Collection<?> coll) 使用单引号包含字符串static String
removePrefixAfterPrefixToLower
(String rawString, int index) 删除字符前缀之后,首字母小写,之后字符大小写的不变static StringBuilder
replace
(CharSequence src, Pattern ptn, BiIntFunction<Matcher, CharSequence> replacer) 根据指定的表达式替换字符串中指定格式的部分static String
replaceAllBlank
(String str) 字符串去除空白内容: \n 回车 \t 水平制表符 \s 空格 \r 换行static String
sqlArgsFill
(String content, Object... args) 替换 SQL 语句中的占位符,例如输入 SELECT * FROM test WHERE id = {0} AND name = {1} 会被替换为 SELECT * FROM test WHERE id = 1 AND name = 'MP'static String
SQL 注入字符串去除空白内容: \n 回车 \t 水平制表符 \s 空格 \r 换行static String
获取SQL PARAMS字符串static String
对象转为字符串去除左右空格static String
underlineToCamel
(String param) 字符串下划线转驼峰格式
-
字段详细资料
-
IS
字符串 is- 另请参阅:
-
UNDERLINE
public static final char UNDERLINE下划线字符- 另请参阅:
-
MP_SQL_PLACE_HOLDER
MP 内定义的 SQL 占位符表达式,匹配诸如 {0},{1},{2} ... 的形式
-
-
构造器详细资料
-
StringUtils
public StringUtils()
-
-
方法详细资料
-
isBlank
判断字符串中是否全是空白字符- 参数:
cs
- 需要判断的字符串- 返回:
- 如果字符串序列是 null 或者全是空白,返回 true
-
toStringTrim
对象转为字符串去除左右空格- 参数:
o
- 带转换对象- 返回:
-
isNotBlank
- 另请参阅:
-
isEmpty
-
isNotEmpty
-
isCamel
判断字符串是不是驼峰命名- 包含 '_' 不算
- 首字母大写的不算
- 参数:
str
- 字符串- 返回:
- 结果
-
isNotColumnName
判断字符串是否符合数据库字段的命名- 参数:
str
- 字符串- 返回:
- 判断结果
-
getTargetColumn
获取真正的字段名- 参数:
column
- 字段名- 返回:
- 字段名
-
camelToUnderline
字符串驼峰转下划线格式- 参数:
param
- 需要转换的字符串- 返回:
- 转换好的字符串
-
underlineToCamel
字符串下划线转驼峰格式- 参数:
param
- 需要转换的字符串- 返回:
- 转换好的字符串
-
firstToLowerCase
首字母转换小写- 参数:
param
- 需要转换的字符串- 返回:
- 转换好的字符串
-
matches
正则表达式匹配- 参数:
regex
- 正则表达式字符串input
- 要匹配的字符串- 返回:
- 如果 input 符合 regex 正则表达式格式, 返回true, 否则返回 false;
-
sqlArgsFill
替换 SQL 语句中的占位符,例如输入 SELECT * FROM test WHERE id = {0} AND name = {1} 会被替换为 SELECT * FROM test WHERE id = 1 AND name = 'MP'当数组中参数不足时,该方法会抛出错误:数组下标越界
ArrayIndexOutOfBoundsException
- 参数:
content
- 填充内容args
- 填充参数
-
replace
public static StringBuilder replace(CharSequence src, Pattern ptn, BiIntFunction<Matcher, CharSequence> replacer) 根据指定的表达式替换字符串中指定格式的部分BiIntFunction 中的 第二个 参数将传递 参数在字符串中的索引
- 参数:
src
- 源字符串ptn
- 需要替换部分的正则表达式replacer
- 替换处理器- 返回:
- 返回字符串构建起
-
sqlParam
获取SQL PARAMS字符串 -
quotaMark
使用单引号包含字符串- 参数:
obj
- 原字符串- 返回:
- 单引号包含的原字符串
-
quotaMarkList
使用单引号包含字符串- 参数:
coll
- 集合- 返回:
- 单引号包含的原字符串的集合形式
-
concatCapitalize
拼接字符串第二个字符串第一个字母大写 -
checkValNotNull
判断对象是否不为空- 参数:
object
- ignore- 返回:
- ignore
-
checkValNull
判断对象是否为空- 参数:
object
- ignore- 返回:
- ignore
-
containsUpperCase
包含大写字母- 参数:
word
- 待判断字符串- 返回:
- ignore
-
isCapitalMode
是否为大写命名- 参数:
word
- 待判断字符串- 返回:
- ignore
-
isMixedMode
是否为驼峰下划线混合命名- 参数:
word
- 待判断字符串- 返回:
- ignore
-
endsWith
判断是否以某个字符串结尾(区分大小写) Check if a String ends with a specified suffix.null
s are handled without exceptions. Twonull
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
- 参数:
str
- the String to check, may be nullsuffix
- the suffix to find, may be null- 返回:
true
if the String ends with the suffix, case sensitive, or bothnull
- 从以下版本开始:
- 2.4
- 另请参阅:
-
isCharSequence
是否为CharSequence类型- 参数:
clazz
- class- 返回:
- true 为是 CharSequence 类型
-
prefixToLower
前n个首字母小写,之后字符大小写的不变- 参数:
rawString
- 需要处理的字符串index
- 多少个字符(从左至右)- 返回:
- ignore
-
removePrefixAfterPrefixToLower
删除字符前缀之后,首字母小写,之后字符大小写的不变StringUtils.removePrefixAfterPrefixToLower( "isUser", 2 ) = user
StringUtils.removePrefixAfterPrefixToLower( "isUserInfo", 2 ) = userInfo
- 参数:
rawString
- 需要处理的字符串index
- 删除多少个字符(从左至右)- 返回:
- ignore
-
camelToHyphen
驼峰转连字符StringUtils.camelToHyphen( "managerAdminUserService" ) = manager-admin-user-service
- 参数:
input
- ignore- 返回:
- 以'-'分隔
- 另请参阅:
-
equals
比较两个字符串,相同则返回true。字符串可为null
对字符串大小写敏感
StringUtils.equals(null, null) = true StringUtils.equals(null, "abc") = false StringUtils.equals("abc", null) = false StringUtils.equals("abc", "abc") = true StringUtils.equals("abc", "ABC") = false
- 参数:
cs1
- 第一个字符串, 可为null
cs2
- 第二个字符串, 可为null
- 返回:
true
如果两个字符串相同, 或者都为null
- 另请参阅:
-
sqlInjectionReplaceBlank
SQL 注入字符串去除空白内容:- \n 回车
- \t 水平制表符
- \s 空格
- \r 换行
- 参数:
str
- 字符串
-
replaceAllBlank
字符串去除空白内容:- \n 回车
- \t 水平制表符
- \s 空格
- \r 换行
- 参数:
str
- 字符串
-