public class TextTool extends Object
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
static int |
findChar(CharSequence source,
char destChar,
int startIndex,
int endIndex) |
Finds the index of the destination character from the specified range of the source string.
|
static String |
getSubstring(CharSequence source,
int startIndex,
int endIndex) |
Obtains a new string based on the specified range of the source string.
|
static boolean |
isEqual(CharSequence sourceA,
CharSequence sourceB) |
Checks whether the content of string A equals that of string B.
|
static boolean |
isLayoutRightToLeft(Locale locale) |
Checks whether the text layout of a specified
Locale is from right to left. |
static boolean |
isNullOrEmpty(CharSequence source) |
Checks whether the source string is empty.
|
static CharSequence |
replaceCharSequence(CharSequence source,
char[] originalCharacterSet,
char[] replacementCharacterSet) |
Replaces one or more target characters in the input text with one or more specified characters.
|
static char[] |
subCharArray(CharSequence source,
int startIndex,
int endIndex) |
Obtains a new character array based on the specified range of the source string.
|
static void |
subCharArray(CharSequence source,
int startIndex,
int endIndex,
char[] destChars,
int destIndex) |
Obtains a new character array based on the specified range of the source string and puts the array
in a particular position of the destination character array.
|
public static boolean isNullOrEmpty(CharSequence source)
source - Indicates the source string to check.true if the string is empty; returns false otherwise.public static boolean isEqual(CharSequence sourceA, CharSequence sourceB)
sourceA - Indicates the source string A to compare.sourceB - Indicates the source string B to compare.true if the contents of the two strings are equal; returns false otherwise.public static boolean isLayoutRightToLeft(Locale locale)
Locale is from right to left.locale - Indicates the locale to check. This parameter can be null.true if the layout is from right to left; returns false if the layout
is from left to right or if locale is null.public static int findChar(CharSequence source, char destChar, int startIndex, int endIndex)
source - Indicates the source string.destChar - Indicates the destination character to find.startIndex - Indicates the start index of the search range.endIndex - Indicates the end index of the search range.-1 otherwise.public static String getSubstring(CharSequence source, int startIndex, int endIndex)
source - Indicates the source string.startIndex - Indicates the start index of the search range.endIndex - Indicates the end index of the search range.public static char[] subCharArray(CharSequence source, int startIndex, int endIndex)
source - Indicates the source string.startIndex - Indicates the start index of the search range.endIndex - Indicates the end index of the search range.public static void subCharArray(CharSequence source, int startIndex, int endIndex, char[] destChars, int destIndex)
source - Indicates the source string.startIndex - Indicates the start index of the search range.endIndex - Indicates the end index of the search range.destChars - Indicates the destination character array.destIndex - Indicates the start index in the destination character array for putting the obtained array.public static CharSequence replaceCharSequence(CharSequence source, char[] originalCharacterSet, char[] replacementCharacterSet)
RichText are supported.
This method does not change source.
source - Indicates the target text.originalCharacterSet - Indicates the character set to be replaced.replacementCharacterSet - Indicates the character set for replacement.source is not null ; returns an empty string otherwise.