public class CharSequenceUtils extends Object
Operations on CharSequence that are
null safe.
CharSequence| 构造器和说明 |
|---|
CharSequenceUtils()
CharSequenceUtils instances should NOT be constructed in
standard programming. |
| 限定符和类型 | 方法和说明 |
|---|---|
(专用程序包) static int |
indexOf(CharSequence cs,
CharSequence searchChar,
int start)
Used by the indexOf(CharSequence methods) as a green implementation of indexOf.
|
(专用程序包) static int |
indexOf(CharSequence cs,
int searchChar,
int start)
Returns the index within
cs of the first occurrence of the
specified character, starting the search at the specified index. |
(专用程序包) static int |
lastIndexOf(CharSequence cs,
CharSequence searchChar,
int start)
Used by the lastIndexOf(CharSequence methods) as a green implementation of lastIndexOf
|
(专用程序包) static int |
lastIndexOf(CharSequence cs,
int searchChar,
int start)
Returns the index within
cs of the last occurrence of
the specified character, searching backward starting at the
specified index. |
(专用程序包) static boolean |
regionMatches(CharSequence cs,
boolean ignoreCase,
int thisStart,
CharSequence substring,
int start,
int length)
Green implementation of regionMatches.
|
static CharSequence |
subSequence(CharSequence cs,
int start)
Returns a new
CharSequence that is a subsequence of this
sequence starting with the char value at the specified index. |
(专用程序包) static char[] |
toCharArray(CharSequence cs)
Green implementation of toCharArray.
|
public CharSequenceUtils()
CharSequenceUtils instances should NOT be constructed in
standard programming.
This constructor is public to permit tools that require a JavaBean instance to operate.
public static CharSequence subSequence(CharSequence cs, int start)
Returns a new CharSequence that is a subsequence of this
sequence starting with the char value at the specified index.
This provides the CharSequence equivalent to String.substring(int).
The length (in char) of the returned sequence is length() - start,
so if start == end then an empty sequence is returned.
cs - the specified subsequence, null returns nullstart - the start index, inclusive, validIndexOutOfBoundsException - if start is negative or if
start is greater than length()static int indexOf(CharSequence cs, int searchChar, int start)
cs of the first occurrence of the
specified character, starting the search at the specified index.
If a character with value searchChar occurs in the
character sequence represented by the cs
object at an index no smaller than start, then
the index of the first such occurrence is returned. For values
of searchChar in the range from 0 to 0xFFFF (inclusive),
this is the smallest value k such that:
is true. For other values of(this.charAt(k) == searchChar) && (k >= start)
searchChar, it is the
smallest value k such that:
is true. In either case, if no such character occurs inm(this.codePointAt(k) == searchChar) && (k >= start)
cs
at or after position start, then
-1 is returned.
There is no restriction on the value of start. If it
is negative, it has the same effect as if it were zero: the entire
CharSequence may be searched. If it is greater than
the length of cs, it has the same effect as if it were
equal to the length of cs: -1 is returned.
All indices are specified in char values
(Unicode code units).
cs - the CharSequence to be processed, not nullsearchChar - the char to be searched forstart - the start index, negative starts at the string startStringstatic int indexOf(CharSequence cs, CharSequence searchChar, int start)
cs - the CharSequence to be processedsearchChar - the CharSequence to be searched forstart - the start indexstatic int lastIndexOf(CharSequence cs, int searchChar, int start)
cs of the last occurrence of
the specified character, searching backward starting at the
specified index. For values of searchChar in the range
from 0 to 0xFFFF (inclusive), the index returned is the largest
value k such that:
is true. For other values of(this.charAt(k) == searchChar) && (k <= start)
searchChar, it is the
largest value k such that:
is true. In either case, if no such character occurs in(this.codePointAt(k) == searchChar) && (k <= start)
cs
at or before position start, then -1 is returned.
All indices are specified in char values
(Unicode code units).
cs - the CharSequence to be processedsearchChar - the char to be searched forstart - the start index, negative returns -1, beyond length starts at endStringstatic int lastIndexOf(CharSequence cs, CharSequence searchChar, int start)
cs - the CharSequence to be processedsearchChar - the CharSequence to be searched forstart - the start indexstatic char[] toCharArray(CharSequence cs)
cs - the CharSequence to be processedstatic boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length)
cs - the CharSequence to be processedignoreCase - whether or not to be case insensitivethisStart - the index to start on the cs CharSequencesubstring - the CharSequence to be looked forstart - the index to start on the substring CharSequencelength - character length of the regionCopyright © 2020. All rights reserved.