public class StringUtils extends Object
String 工具类
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
EMPTY
空字符
|
static String |
IS
空字符
|
static String |
PLACE_HOLDER
占位符
|
static char |
UNDERLINE
下划线字符
|
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
camelToHyphen(String input)
驼峰转连字符
StringUtils.camelToHyphen( "managerAdminUserService" ) = manager-admin-user-service |
static String |
camelToUnderline(String param)
字符串驼峰转下划线格式
|
static String |
capitalize(String str)
字符串第一个字母大写
|
static boolean |
checkValNotNull(Object object)
判断对象是否为空
|
static boolean |
checkValNull(Object object)
判断对象是否为空
|
static String |
concatCapitalize(String concatStr,
String str)
拼接字符串第二个字符串第一个字母大写
|
static boolean |
containsLowerCase(String s) |
static boolean |
containsUpperCase(String word)
包含大写字母
|
static boolean |
endsWith(String str,
String suffix)
Check if a String ends with a specified suffix.
|
static boolean |
endsWithIgnoreCase(String str,
String suffix)
Case insensitive check if a String ends with a specified suffix.
|
static String |
firstCharToLower(String rawString)
第一个首字母小写,之后字符大小写的不变
StringUtils.firstCharToLower( "UserService" ) = userService StringUtils.firstCharToLower( "UserServiceImpl" ) = userServiceImpl |
static String |
firstToLowerCase(String param)
首字母转换小写
|
static Boolean |
isBoolean(Class<?> propertyCls)
是否为Boolean类型(包含普通类型)
|
static boolean |
isCapitalMode(String word)
是否为大写命名
|
static Boolean |
isCharSequence(Class<?> cls)
是否为CharSequence类型
|
static Boolean |
isCharSequence(String propertyType)
是否为CharSequence类型
|
static boolean |
isEmpty(CharSequence cs)
判断字符串是否为空
|
static boolean |
isNotEmpty(CharSequence cs)
判断字符串是否不为空
|
static boolean |
isUpperCase(String str)
判断字符串是否为纯大写字母
|
static boolean |
match(String regex,
String str)
正则表达式匹配
|
static String |
prefixToLower(String rawString,
int index)
前n个首字母小写,之后字符大小写的不变
|
static String |
quotaMark(Object obj)
使用单引号包含字符串
|
static String |
quotaMarkList(Collection<?> coll)
使用单引号包含字符串
|
static String |
removeIsPrefixIfBoolean(String propertyName,
Class<?> propertyType)
去除boolean类型is开头的字符串
|
static String |
removePrefixAfterPrefixToLower(String rawString,
int index)
删除字符前缀之后,首字母小写,之后字符大小写的不变
StringUtils.removePrefixAfterPrefixToLower( "isUser", 2 ) = user StringUtils.removePrefixAfterPrefixToLower( "isUserInfo", 2 ) = userInfo |
static String[] |
split(String str,
String separatorChars)
Splits the provided text into an array, separators specified.
|
static List<String> |
splitWorker(String str,
String separatorChars,
int max,
boolean preserveAllTokens)
Performs the logic for the
split and
splitPreserveAllTokens methods that return a maximum array
length. |
static String |
sqlArgsFill(String content,
Object... args)
SQL 参数填充
|
static String |
sqlParam(Object obj)
获取SQL PARAMS字符串
|
static String |
underlineToCamel(String param)
字符串下划线转驼峰格式
|
public static final char UNDERLINE
public static boolean isEmpty(CharSequence cs)
判断字符串是否为空
cs - 需要判断字符串public static boolean isNotEmpty(CharSequence cs)
判断字符串是否不为空
cs - 需要判断字符串public static String camelToUnderline(String param)
字符串驼峰转下划线格式
param - 需要转换的字符串public static String underlineToCamel(String param)
字符串下划线转驼峰格式
param - 需要转换的字符串public static String firstToLowerCase(String param)
首字母转换小写
param - 需要转换的字符串public static boolean isUpperCase(String str)
判断字符串是否为纯大写字母
str - 要匹配的字符串public static boolean match(String regex, String str)
正则表达式匹配
regex - 正则表达式字符串str - 要匹配的字符串public static String sqlArgsFill(String content, Object... args)
SQL 参数填充
content - 填充内容args - 填充参数public static String quotaMarkList(Collection<?> coll)
使用单引号包含字符串
coll - 集合public static String concatCapitalize(String concatStr, String str)
拼接字符串第二个字符串第一个字母大写
concatStr - str - public static boolean checkValNotNull(Object object)
判断对象是否为空
object - public static boolean checkValNull(Object object)
判断对象是否为空
object - public static boolean containsUpperCase(String word)
包含大写字母
word - 待判断字符串public static boolean isCapitalMode(String word)
是否为大写命名
word - 待判断字符串public static boolean endsWith(String str, String suffix)
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
str - the String to check, may be nullsuffix - the suffix to find, may be nulltrue if the String ends with the suffix, case
sensitive, or both nullString.endsWith(String)public static boolean endsWithIgnoreCase(String str, String suffix)
Case insensitive 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
insensitive.
StringUtils.endsWithIgnoreCase(null, null) = true
StringUtils.endsWithIgnoreCase(null, "abcdef") = false
StringUtils.endsWithIgnoreCase("def", null) = false
StringUtils.endsWithIgnoreCase("def", "abcdef") = true
StringUtils.endsWithIgnoreCase("def", "ABCDEF") = false
str - the String to check, may be nullsuffix - the suffix to find, may be nulltrue if the String ends with the suffix, case
insensitive, or both nullString.endsWith(String)public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A null input String returns null. A null
separatorChars splits on whitespace.
StringUtils.split(null, *) = null
StringUtils.split("", *) = []
StringUtils.split("abc def", null) = ["abc", "def"]
StringUtils.split("abc def", " ") = ["abc", "def"]
StringUtils.split("abc def", " ") = ["abc", "def"]
StringUtils.split("ab:cd:ef", ":") = ["ab", "cd", "ef"]
str - the String to parse, may be nullseparatorChars - the characters used as the delimiters, null splits on
whitespacenull if null String inputpublic static List<String> splitWorker(String str, String separatorChars, int max, boolean preserveAllTokens)
split and
splitPreserveAllTokens methods that return a maximum array
length.str - the String to parse, may be nullseparatorChars - the separate charactermax - the maximum number of elements to include in the array. A zero
or negative value implies no limit.preserveAllTokens - if true, adjacent separators are treated as empty
token separators; if false, adjacent separators are
treated as one separator.null if null String inputpublic static String removeIsPrefixIfBoolean(String propertyName, Class<?> propertyType)
去除boolean类型is开头的字符串
propertyName - 字段名propertyType - 字段类型public static Boolean isCharSequence(String propertyType)
是否为CharSequence类型
propertyType - public static Boolean isBoolean(Class<?> propertyCls)
是否为Boolean类型(包含普通类型)
propertyCls - public static String firstCharToLower(String rawString)
第一个首字母小写,之后字符大小写的不变
StringUtils.firstCharToLower( "UserService" ) = userService
StringUtils.firstCharToLower( "UserServiceImpl" ) = userServiceImpl
rawString - 需要处理的字符串public static String prefixToLower(String rawString, int index)
前n个首字母小写,之后字符大小写的不变
rawString - 需要处理的字符串index - 多少个字符(从左至右)public static String removePrefixAfterPrefixToLower(String rawString, int index)
删除字符前缀之后,首字母小写,之后字符大小写的不变
StringUtils.removePrefixAfterPrefixToLower( "isUser", 2 ) = user
StringUtils.removePrefixAfterPrefixToLower( "isUserInfo", 2 ) = userInfo
rawString - 需要处理的字符串index - 删除多少个字符(从左至右)public static String camelToHyphen(String input)
驼峰转连字符
StringUtils.camelToHyphen( "managerAdminUserService" ) = manager-admin-user-service
input - public static boolean containsLowerCase(String s)
Copyright © 2017. All rights reserved.