类 StringUtil
java.lang.Object
org.apache.commons.lang3.StringUtils
cn.jrack.core.util.common.StringUtil
public class StringUtil
extends org.apache.commons.lang3.StringUtils
字符串工具类
-
字段概要
从类继承的字段 org.apache.commons.lang3.StringUtils
CR, EMPTY, INDEX_NOT_FOUND, LF, SPACE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static <T> Tstatic StringconvertToCamelCase(String name) 将下划线大写方式命名的字符串转换为驼峰式。static String格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数
如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
例:
通常使用:format("this is {} for {}", "a", "b") -> this is a for b
转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for bstatic booleaninStringIgnoreCase(String str, String... strs) 是否包含字符串static boolean* 判断一个对象是否是数组类型(Java基本型别的数组)static boolean* 判断一个对象数组是否为空static boolean* 判断一个字符串是否为空串static booleanisEmpty(Collection<?> coll) * 判断一个Collection是否为空, 包含List,Set,Queuestatic boolean* 判断一个Map是否为空static booleanisNotEmpty(Object[] objects) * 判断一个对象数组是否非空static booleanisNotEmpty(String str) * 判断一个字符串是否为非空串static booleanisNotEmpty(Collection<?> coll) * 判断一个Collection是否非空,包含List,Set,Queuestatic booleanisNotEmpty(Map<?, ?> map) * 判断一个Map是否为空static boolean* 判断一个对象是否非空static boolean* 判断一个对象是否为空static <T> Tnvl(T value, T defaultValue) 获取参数不为空值static String截取字符串static String截取字符串static String驼峰式命名法 例如:user_name->userNamestatic StringtoUnderLineCase(String name) 驼峰转下划线 例如:userName->user_namestatic StringtoUnderScoreCase(String str) 下划线转驼峰命名static String去空格从类继承的方法 org.apache.commons.lang3.StringUtils
abbreviate, abbreviate, abbreviate, abbreviate, abbreviateMiddle, appendIfMissing, appendIfMissingIgnoreCase, capitalize, center, center, center, chomp, chomp, chop, compare, compare, compareIgnoreCase, compareIgnoreCase, contains, contains, containsAny, containsAny, containsAny, containsAnyIgnoreCase, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, containsWhitespace, countMatches, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsAny, equalsAnyIgnoreCase, equalsIgnoreCase, firstNonBlank, firstNonEmpty, getBytes, getBytes, getCommonPrefix, getDigits, getFuzzyDistance, getIfBlank, getIfEmpty, getJaroWinklerDistance, getLevenshteinDistance, getLevenshteinDistance, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllBlank, isAllEmpty, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAnyBlank, isAnyEmpty, isAsciiPrintable, isBlank, isEmpty, isMixedCase, isNoneBlank, isNoneEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, joinWith, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, left, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, prependIfMissing, prependIfMissingIgnoreCase, remove, remove, removeAll, removeEnd, removeEndIgnoreCase, removeFirst, removeIgnoreCase, removePattern, removeStart, removeStartIgnoreCase, repeat, repeat, repeat, replace, replace, replaceAll, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceFirst, replaceIgnoreCase, replaceIgnoreCase, replaceOnce, replaceOnceIgnoreCase, replacePattern, reverse, reverseDelimited, right, rightPad, rightPad, rightPad, rotate, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAccents, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substringAfter, substringAfter, substringAfterLast, substringAfterLast, substringBefore, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, toCodePoints, toEncodedString, toRootLowerCase, toRootUpperCase, toString, trimToEmpty, trimToNull, truncate, truncate, uncapitalize, unwrap, unwrap, upperCase, upperCase, valueOf, wrap, wrap, wrapIfMissing, wrapIfMissing
-
构造器详细资料
-
StringUtil
public StringUtil()
-
-
方法详细资料
-
nvl
public static <T> T nvl(T value, T defaultValue) 获取参数不为空值- 参数:
value- defaultValue 要判断的value- 返回:
- value 返回值
-
isEmpty
* 判断一个Collection是否为空, 包含List,Set,Queue- 参数:
coll- 要判断的Collection- 返回:
- true:为空 false:非空
-
isNotEmpty
* 判断一个Collection是否非空,包含List,Set,Queue- 参数:
coll- 要判断的Collection- 返回:
- true:非空 false:空
-
isEmpty
* 判断一个对象数组是否为空- 参数:
objects- 要判断的对象数组 * @return true:为空 false:非空
-
isNotEmpty
* 判断一个对象数组是否非空- 参数:
objects- 要判断的对象数组- 返回:
- true:非空 false:空
-
isEmpty
* 判断一个Map是否为空- 参数:
map- 要判断的Map- 返回:
- true:为空 false:非空
-
isNotEmpty
* 判断一个Map是否为空- 参数:
map- 要判断的Map- 返回:
- true:非空 false:空
-
isEmpty
* 判断一个字符串是否为空串- 参数:
str- String- 返回:
- true:为空 false:非空
-
isNotEmpty
* 判断一个字符串是否为非空串- 参数:
str- String- 返回:
- true:非空串 false:空串
-
isNull
* 判断一个对象是否为空- 参数:
object- Object- 返回:
- true:为空 false:非空
-
isNotNull
* 判断一个对象是否非空- 参数:
object- Object- 返回:
- true:非空 false:空
-
isArray
* 判断一个对象是否是数组类型(Java基本型别的数组)- 参数:
object- 对象- 返回:
- true:是数组 false:不是数组
-
trim
去空格 -
substring
截取字符串- 参数:
str- 字符串start- 开始- 返回:
- 结果
-
substring
截取字符串- 参数:
str- 字符串start- 开始end- 结束- 返回:
- 结果
-
format
格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数
如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可
例:
通常使用:format("this is {} for {}", "a", "b") -> this is a for b
转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a
转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b- 参数:
template- 文本模板,被替换的部分用 {} 表示params- 参数值- 返回:
- 格式化后的文本
-
toUnderScoreCase
下划线转驼峰命名 -
inStringIgnoreCase
是否包含字符串- 参数:
str- 验证字符串strs- 字符串组- 返回:
- 包含返回true
-
convertToCamelCase
将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld- 参数:
name- 转换前的下划线大写方式命名的字符串- 返回:
- 转换后的驼峰式命名的字符串
-
toCamelCase
驼峰式命名法 例如:user_name->userName -
toUnderLineCase
驼峰转下划线 例如:userName->user_name -
cast
-