类 StringUtils
java.lang.Object
com.baomidou.mybatisplus.core.toolkit.StringUtils
String 工具类
- 从以下版本开始:
- 2016-08-18
- 作者:
- D.Yang, hcl, hcl
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StringcamelToHyphen(String input) 驼峰转连字符static StringcamelToUnderline(String param) 字符串驼峰转下划线格式static booleancheckValNotNull(Object object) 判断对象是否不为空static booleancheckValNull(Object object) 判断对象是否为空static StringconcatCapitalize(String concatStr, String str) 拼接字符串第二个字符串第一个字母大写static booleancontainsUpperCase(String word) 包含大写字母static boolean判断是否以某个字符串结尾(区分大小写) Check if a String ends with a specified suffix.static booleanequals(CharSequence cs1, CharSequence cs2) 比较两个字符串,相同则返回true。static StringfirstToLowerCase(String param) 首字母转换小写static StringgetTargetColumn(String column) 获取真正的字段名static booleanisBlank(CharSequence cs) 判断字符串中是否全是空白字符static boolean判断字符串是不是驼峰命名 包含 '_' 不算 首字母大写的不算static booleanisCapitalMode(String word) 是否为大写命名static booleanisCharSequence(Class<?> clazz) 是否为CharSequence类型static booleanisEmpty(CharSequence cs) static booleanisMixedMode(String word) 是否为驼峰下划线混合命名static booleanstatic booleanisNotColumnName(String str) 判断字符串是否符合数据库字段的命名static booleanstatic boolean正则表达式匹配static StringprefixToLower(String rawString, int index) 前n个首字母小写,之后字符大小写的不变static String已过时。3.5.12static StringquotaMarkList(Collection<?> coll) 已过时。3.5.12static StringremovePrefixAfterPrefixToLower(String rawString, int index) 删除字符前缀之后,首字母小写,之后字符大小写的不变static StringBuilderreplace(CharSequence src, Pattern ptn, BiIntFunction<Matcher, CharSequence> replacer) 已过时。3.5.12static StringreplaceAllBlank(String str) 字符串去除空白内容: \n 回车 \t 水平制表符 \s 空格 \r 换行static StringsqlArgsFill(String content, Object... args) 已过时。3.5.12static StringSQL 注入字符串去除空白内容: \n 回车 \t 水平制表符 \s 空格 \r 换行static String已过时。3.5.12static String对象转为字符串去除左右空格static StringunderlineToCamel(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
已过时。3.5.12替换 SQL 语句中的占位符,例如输入 SELECT * FROM test WHERE id = {0} AND name = {1} 会被替换为 SELECT * FROM test WHERE id = 1 AND name = 'MP'当数组中参数不足时,该方法会抛出错误:数组下标越界
ArrayIndexOutOfBoundsException- 参数:
content- 填充内容args- 填充参数
-
replace
@Deprecated public static StringBuilder replace(CharSequence src, Pattern ptn, BiIntFunction<Matcher, CharSequence> replacer) 已过时。3.5.12根据指定的表达式替换字符串中指定格式的部分BiIntFunction 中的 第二个 参数将传递 参数在字符串中的索引
- 参数:
src- 源字符串ptn- 需要替换部分的正则表达式replacer- 替换处理器- 返回:
- 返回字符串构建起
-
sqlParam
已过时。3.5.12获取SQL PARAMS字符串 -
quotaMark
已过时。3.5.12使用单引号包含字符串- 参数:
obj- 原字符串- 返回:
- 单引号包含的原字符串
-
quotaMarkList
已过时。3.5.12使用单引号包含字符串- 参数:
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.nulls are handled without exceptions. Twonullreferences 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- 返回:
trueif 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- 第一个字符串, 可为nullcs2- 第二个字符串, 可为null- 返回:
true如果两个字符串相同, 或者都为null- 另请参阅:
-
sqlInjectionReplaceBlank
SQL 注入字符串去除空白内容:- \n 回车
- \t 水平制表符
- \s 空格
- \r 换行
- 参数:
str- 字符串
-
replaceAllBlank
字符串去除空白内容:- \n 回车
- \t 水平制表符
- \s 空格
- \r 换行
- 参数:
str- 字符串
-