public class CharSequenceUtils
extends java.lang.Object
Operations on CharSequence
that are
null
safe.
CharSequence
Modifier and Type | Field and Description |
---|---|
private static int |
NOT_FOUND |
Constructor and Description |
---|
CharSequenceUtils()
CharSequenceUtils instances should NOT be constructed in
standard programming. |
Modifier and Type | Method and Description |
---|---|
(package private) static int |
indexOf(java.lang.CharSequence cs,
java.lang.CharSequence searchChar,
int start)
Used by the indexOf(CharSequence methods) as a green implementation of indexOf.
|
(package private) static int |
indexOf(java.lang.CharSequence cs,
int searchChar,
int start)
Finds the first index in the
CharSequence that matches the
specified character. |
(package private) static int |
lastIndexOf(java.lang.CharSequence cs,
java.lang.CharSequence searchChar,
int start)
Used by the lastIndexOf(CharSequence methods) as a green implementation of lastIndexOf
|
(package private) static int |
lastIndexOf(java.lang.CharSequence cs,
int searchChar,
int start)
Finds the last index in the
CharSequence that matches the
specified character. |
(package private) static boolean |
regionMatches(java.lang.CharSequence cs,
boolean ignoreCase,
int thisStart,
java.lang.CharSequence substring,
int start,
int length)
Green implementation of regionMatches.
|
static java.lang.CharSequence |
subSequence(java.lang.CharSequence cs,
int start)
Returns a new
CharSequence that is a subsequence of this
sequence starting with the char value at the specified index. |
(package private) static char[] |
toCharArray(java.lang.CharSequence cs)
Green implementation of toCharArray.
|
private static final int NOT_FOUND
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 java.lang.CharSequence subSequence(java.lang.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, validjava.lang.IndexOutOfBoundsException
- if start
is negative or if
start
is greater than length()
static int indexOf(java.lang.CharSequence cs, int searchChar, int start)
Finds the first index in the CharSequence
that matches the
specified character.
cs
- the CharSequence
to be processed, not nullsearchChar
- the char to be searched forstart
- the start index, negative starts at the string startstatic int indexOf(java.lang.CharSequence cs, java.lang.CharSequence searchChar, int start)
cs
- the CharSequence
to be processedsearchChar
- the CharSequence
to be searched forstart
- the start indexstatic int lastIndexOf(java.lang.CharSequence cs, int searchChar, int start)
Finds the last index in the CharSequence
that matches the
specified character.
cs
- the CharSequence
to be processedsearchChar
- the char to be searched forstart
- the start index, negative returns -1, beyond length starts at endstatic int lastIndexOf(java.lang.CharSequence cs, java.lang.CharSequence searchChar, int start)
cs
- the CharSequence
to be processedsearchChar
- the CharSequence
to be searched forstart
- the start indexstatic char[] toCharArray(java.lang.CharSequence cs)
cs
- the CharSequence
to be processedstatic boolean regionMatches(java.lang.CharSequence cs, boolean ignoreCase, int thisStart, java.lang.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 region