| 构造器 | 说明 |
|---|---|
S() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static boolean |
allBlank(CharSequence... css) |
true if all array values are null or empty "" or blank
or CharSequence array is null. |
static boolean |
allBlank(List<? extends CharSequence> css) |
true if all List values are null or empty "" or blank
or CharSequence List is null. |
static boolean |
allEmpty(CharSequence... css) |
true if all array values are null or empty "" value
or CharSequence array is null. |
static boolean |
allEmpty(List<? extends CharSequence> css) |
true if all List values are null or empty "" value
or CharSequence List is null. |
static String |
blankToEmpty(String s) |
Returns itself if string is non-blank; otherwise, returns empty(
""). |
static String |
blankToNull(String s) |
Returns itself if string is non-blank; otherwise, returns
null. |
static int |
countChars(CharSequence str,
char c) |
Counts how many times the char occurrences in the given string.
|
static int[] |
countMultiChars(CharSequence str,
char... cs) |
Counts how many times the char in char array occurrences in the given string.
|
static int[] |
countMultiChars(CharSequence str,
CharSequence chars) |
Counts how many times the char in
CharSequence occurrences in the given string. |
static String |
emptyToNull(String s) |
Returns itself if string is non-empty; otherwise, returns
null. |
static String |
enclose(String enclosedStr,
char encloseChar) |
Using char to enclose a String
|
static String |
enclose(String enclosedStr,
char encloseChar1,
char encloseChar2) |
Using two chars to enclose a String
|
static String |
enclose(String enclosedStr,
String encloseStr) |
Using string to enclose a String
|
static String |
enclose(String enclosedStr,
String encloseStr1,
String encloseStr2) |
Using two strings to enclose a String
|
static boolean |
endsWith(String str,
String suffix,
int offsetFromEnd) |
Tests if the given string ends with the specified suffix, when compared starting from the specified offset from the end of the string.
|
static boolean |
hasBlank(CharSequence... css) |
Whether CharSequence array contains
null or empty "" or blank
or CharSequence array is null. |
static boolean |
hasBlank(List<? extends CharSequence> css) |
Whether CharSequence List contains
null or empty "" or blank
or CharSequence List is null. |
static boolean |
hasEmpty(CharSequence... css) |
Whether CharSequence array contains
null or empty ""
or CharSequence array is null. |
static boolean |
hasEmpty(List<? extends CharSequence> css) |
Whether CharSequence List contains
null or empty ""
or CharSequence List is null. |
static int |
indexOf(String source,
String subStr,
int appearanceOrder) |
The index within this string of the specified occurrence order of the specified substring.
|
static boolean |
isBlank(CharSequence cs) |
true if all chars in CharSequence are whitespace Character.isWhitespace(char). |
static boolean |
isBlankChar(char c) |
|
static boolean |
isBlankChar(int c) |
|
static boolean |
isEmpty(CharSequence cs) |
|
static String |
nullToEmpty(String s) |
Returns itself if string is non-null; otherwise, returns empty(
""). |
static String |
padLeftChars(CharSequence cs,
char padChar,
int length) |
Padding chars to the left of the input char sequence to the given length.
|
static String |
padLeftChars(Number number,
char padChar,
int length) |
Padding chars to the left of the input number to the given length.
|
static Tuple2<String,String> |
splitOnce(String source,
String delimiter) |
Split by the place where the delimiter first appears, only split once.
|
static String |
trim(String str,
String trimHeadStr,
String trimTailStr) |
Trims the string and returns a string that does not start with
trimHeadStr and does not end with trimTailStr. |
static String |
trim(String str,
String trimHeadStr,
String trimTailStr,
boolean isTrimHeadFirst) |
Trims the string and returns a string that does not start with
trimHeadStr and does not end with trimTailStr. |
static String |
trimOnce(String str,
String trimHeadStr,
String trimTailStr) |
Trim the given string once with the specified header string and tail string.
|
static String |
trimOnce(String str,
String trimHeadStr,
String trimTailStr,
boolean isTrimHeadFirst) |
Trim the given string once with the specified header string and tail string.
|
public static boolean hasEmpty(CharSequence... css)
null or empty ""
or CharSequence array is null. css.length == 0), return true. null值或者空字符串""或者CharSequence数组本身就为null,则返回true。
特别地,当数组本身长度等于0时,也返回true。css - CharSequence arraytrue or falsepublic static boolean allEmpty(CharSequence... css)
true if all array values are null or empty "" value
or CharSequence array is null. css.length == 0), return true. null或者空字符串""或者CharSequence数组本身就为null,则返回true。
特别地,当数组本身长度等于0时,也返回true。css - CharSequence arraytrue or falsepublic static boolean hasBlank(CharSequence... css)
null or empty "" or blank
or CharSequence array is null. css.length == 0), return true. null值或空字符串""或空白字符串或CharSequence数组本身就为null,则返回true。
特别地,当数组本身长度等于0时,也返回true。css - string arraytrue or falseisBlank(CharSequence)public static boolean allBlank(CharSequence... css)
true if all array values are null or empty "" or blank
or CharSequence array is null. css.length == 0), return true. null或空字符串""或空白字符串或CharSequence数组本身就为null,则返回true。
特别地,当数组本身长度等于0时,也返回true。css - CharSequence arraytrue or falseisBlank(CharSequence)public static boolean hasEmpty(List<? extends CharSequence> css)
null or empty ""
or CharSequence List is null. css.length == 0), return true. null值或者空字符串""或者CharSequence列表本身就为null,则返回true。
特别地,当列表本身长度等于0时,也返回true。css - CharSequence Listtrue or falsepublic static boolean allEmpty(List<? extends CharSequence> css)
true if all List values are null or empty "" value
or CharSequence List is null. css.length == 0), return true. null或者空字符串""或者CharSequence列表本身就为null,则返回true。
特别地,当列表本身长度等于0时,也返回true。css - CharSequence Listtrue or falsepublic static boolean hasBlank(List<? extends CharSequence> css)
null or empty "" or blank
or CharSequence List is null. css.length == 0), return true. null值或空字符串""或空白字符串或CharSequence列表本身就为null,则返回true。
特别地,当列表本身长度等于0时,也返回true。css - string Listtrue or falseisBlank(CharSequence)public static boolean allBlank(List<? extends CharSequence> css)
true if all List values are null or empty "" or blank
or CharSequence List is null. css.length == 0), return true. null或空字符串""或空白字符串或CharSequence列表本身就为null,则返回true。
特别地,当列表本身长度等于0时,也返回true。css - CharSequence Listtrue or falseisBlank(CharSequence)public static boolean isBlank(CharSequence cs)
true if all chars in CharSequence are whitespace Character.isWhitespace(char). cs - CharSequencetrue or falsepublic static boolean isBlankChar(char c)
public static boolean isBlankChar(int c)
public static boolean isEmpty(CharSequence cs)
public static String nullToEmpty(String s)
"").s - string"")public static String emptyToNull(String s)
null.s - stringnullpublic static String blankToNull(String s)
null.s - stringnullpublic static String blankToEmpty(String s)
"").s - string"").public static String padLeftChars(CharSequence cs, char padChar, int length)
cs - input char sequencepadChar - pad charlength - final length of returns stringpublic static String padLeftChars(Number number, char padChar, int length)
number - input numberpadChar - pad charlength - final length of returns stringpublic static boolean endsWith(String str, String suffix, int offsetFromEnd)
str - the string to checksuffix - the suffix to check foroffsetFromEnd - the offset from the end of the string to start the comparison from. 从字符串末尾开始的偏移量public static String trim(String str, String trimHeadStr, String trimTailStr)
trimHeadStr and does not end with trimTailStr. trimHeadStr 开头 且 不以 trimTailStr 结尾的字符串str - 待修剪的字符串trimHeadStr - 修剪头部指定的字符串trimTailStr - 修剪尾部指定的字符串public static String trim(String str, String trimHeadStr, String trimTailStr, boolean isTrimHeadFirst)
trimHeadStr and does not end with trimTailStr. trimHeadStr 开头 且 不以 trimTailStr 结尾的字符串str - 待修剪的字符串trimHeadStr - 修剪头部指定的字符串trimTailStr - 修剪尾部指定的字符串isTrimHeadFirst - true,先修剪头部,再修剪尾部;false,先修剪尾部,再修剪头部public static String trimOnce(String str, String trimHeadStr, String trimTailStr)
str - 待修剪的字符串trimHeadStr - 修剪头部指定的字符串trimTailStr - 修剪尾部指定的字符串public static String trimOnce(String str, String trimHeadStr, String trimTailStr, boolean isTrimHeadFirst)
str - 待修剪的字符串trimHeadStr - 修剪头部指定的字符串trimTailStr - 修剪尾部指定的字符串isTrimHeadFirst - true,先修剪头部,再修剪尾部;false,先修剪尾部,再修剪头部public static String enclose(String enclosedStr, String encloseStr)
Examples:
S.enclose("abc", "||"); // returns "||abc||";
enclosedStr - 被包围的字符串encloseStr - 包围的字符串public static String enclose(String enclosedStr, String encloseStr1, String encloseStr2)
Examples:
S.enclose("abc", ">>", "<<"); // returns ">>abc<<";
enclosedStr - 被包围的字符串encloseStr1 - 包围的字符串1encloseStr2 - 包围的字符串2public static String enclose(String enclosedStr, char encloseChar)
Examples:
S.enclose("abc", '"'); // returns "\"abc\"";
enclosedStr - 被包围的字符串encloseChar - 包围的字符public static String enclose(String enclosedStr, char encloseChar1, char encloseChar2)
Examples:
S.enclose("abc", '>', '<'); // returns ">abc<";
enclosedStr - 被包围的字符串encloseChar1 - 包围的字符1encloseChar2 - 包围的字符2public static Tuple2<String,String> splitOnce(String source, String delimiter)
source - will be splitdelimiter - delimiterpublic static int indexOf(String source, String subStr, int appearanceOrder)
source - 原字符串subStr - 要匹配的子字符串appearanceOrder - 出现的次序(第几次出现),从 1 开始计数NullPointerException - if source or subStr is nullUnexpectedParameterException - if appearanceOrder less than 1.public static int countChars(CharSequence str, char c)
str - input stringc - match characterpublic static int[] countMultiChars(CharSequence str, char... cs)
Examples:
S.countMultiChars("abc- Defgh_IJ--klm _nop-", '-', ' ', 'z', '_'); // returns [4, 3, 0, 2];
// --------------------
// The number of '-': 4
// The number of ' ': 3
// The number of 'z': 0
// The number of '_': 2
str - stringcs - char arraypublic static int[] countMultiChars(CharSequence str, CharSequence chars)
CharSequence occurrences in the given string.
Examples:
S.countMultiChars("abc- Defgh_IJ--klm _nop-", "- z_"); // returns [4, 3, 0, 2];
// --------------------
// The number of '-': 4
// The number of ' ': 3
// The number of 'z': 0
// The number of '_': 2
str - stringchars - CharSequenceCopyright © 2023 io-fairy. All rights reserved.