public final class CharSequenceUtilities extends Object
Modifier and Type | Method and Description |
---|---|
static void |
append(StringBuffer sb,
CharSequence text)
Append character sequence to the given string buffer.
|
static void |
append(StringBuffer sb,
CharSequence text,
int start,
int end)
Append part of the character sequence to the given string buffer.
|
static void |
checkIndexesValid(CharSequence text,
int start,
int end)
Ensure that the given start and end parameters are valid indices
of the given text.
|
static void |
checkIndexesValid(int start,
int end,
int length)
Ensure that the given start and end parameters are valid indices
of the given text.
|
static void |
checkIndexNonNegative(int index)
Ensure that the given index is >=0 and lower than the given length.
|
static void |
checkIndexValid(int index,
int length)
Ensure that the given index is >=0 and lower than the given length.
|
static String |
debugChar(char ch)
Return the text description of the given character
translating the special characters (and '\') into escape sequences.
|
static void |
debugChar(StringBuffer sb,
char ch)
Append the character description to the given string buffer
translating the special characters (and '\') into escape sequences.
|
static void |
debugChar(StringBuilder sb,
char ch)
Append the character description to the given string builder
translating the special characters (and '\') into escape sequences.
|
static String |
debugText(CharSequence text)
Create text description as String
translating the special characters (and '\') into escape sequences.
|
static void |
debugText(StringBuffer sb,
CharSequence text)
Append the text description to the given string buffer
translating the special characters (and '\') into escape sequences.
|
static void |
debugText(StringBuilder sb,
CharSequence text)
Append the text description to the given string builder
translating the special characters (and '\') into escape sequences.
|
static boolean |
endsWith(CharSequence text,
CharSequence suffix)
Implementation of
String.endsWith(String) for character sequences. |
static boolean |
equals(CharSequence text,
Object o)
Compare character sequence to another object.
|
static int |
indexOf(CharSequence text,
CharSequence seq)
Implementation of
String.indexOf(String) for character sequences. |
static int |
indexOf(CharSequence text,
CharSequence seq,
int fromIndex)
Implementation of
String.indexOf(String,int) for character sequences. |
static int |
indexOf(CharSequence text,
int ch)
Implementation of
String.indexOf(int) for character sequences. |
static int |
indexOf(CharSequence text,
int ch,
int fromIndex)
Implementation of
String.indexOf(int,int) for character sequences. |
static int |
lastIndexOf(CharSequence text,
CharSequence seq)
Implementation of
String.lastIndexOf(String) for character sequences. |
static int |
lastIndexOf(CharSequence text,
CharSequence seq,
int fromIndex)
Implementation of
String.lastIndexOf(String,int) for character sequences. |
static int |
lastIndexOf(CharSequence text,
int ch)
Implementation of
String.lastIndexOf(int) for character sequences. |
static int |
lastIndexOf(CharSequence text,
int ch,
int fromIndex)
Implementation of
String.lastIndexOf(int,int) for character sequences. |
static boolean |
startsWith(CharSequence text,
CharSequence prefix)
Implementation of
String.startsWith(String) for character sequences. |
static int |
stringLikeHashCode(CharSequence text)
Compute
String -like hashcode over given CharSequence . |
static boolean |
textEquals(CharSequence text1,
CharSequence text2)
Test whether whether the given character sequences
represent the same text.
|
static String |
toString(CharSequence text)
Create a string from the given character sequence by first creating
a
StringBuilder and appending the whole character sequence
to it. |
static String |
toString(CharSequence text,
int start,
int end)
Create string for the given portion of the character sequence.
|
static CharSequence |
trim(CharSequence text)
Implementation of
String.trim() for character sequences. |
public static int stringLikeHashCode(CharSequence text)
String
-like hashcode over given CharSequence
.text
- character sequence for which the hashcode is being computed.public static boolean equals(CharSequence text, Object o)
text
- character sequence being compared to the given object.
It may be null
.o
- object to be compared to the character sequence.
It may be null
.public static boolean textEquals(CharSequence text1, CharSequence text2)
text1
- first character sequence being compared.
It must not be null
.text2
- second character sequence being compared.
It must not be null
.public static String toString(CharSequence text)
StringBuilder
and appending the whole character sequence
to it.
toString()
on the given character
sequence.text
- character sequence for which the String
form
should be created.public static String toString(CharSequence text, int start, int end)
text
- non-null text.start
- >=0 and <text.length() index of the first character
to be present in the returned string.end
- >=start and <text.length() index after the last character
to be present in the returned string.public static void append(StringBuffer sb, CharSequence text)
public static void append(StringBuffer sb, CharSequence text, int start, int end)
public static int indexOf(CharSequence text, int ch)
String.indexOf(int)
for character sequences.public static int indexOf(CharSequence text, int ch, int fromIndex)
String.indexOf(int,int)
for character sequences.public static int indexOf(CharSequence text, CharSequence seq)
String.indexOf(String)
for character sequences.public static int indexOf(CharSequence text, CharSequence seq, int fromIndex)
String.indexOf(String,int)
for character sequences.public static int lastIndexOf(CharSequence text, CharSequence seq)
String.lastIndexOf(String)
for character sequences.public static int lastIndexOf(CharSequence text, CharSequence seq, int fromIndex)
String.lastIndexOf(String,int)
for character sequences.public static int lastIndexOf(CharSequence text, int ch)
String.lastIndexOf(int)
for character sequences.public static int lastIndexOf(CharSequence text, int ch, int fromIndex)
String.lastIndexOf(int,int)
for character sequences.public static boolean startsWith(CharSequence text, CharSequence prefix)
String.startsWith(String)
for character sequences.public static boolean endsWith(CharSequence text, CharSequence suffix)
String.endsWith(String)
for character sequences.public static CharSequence trim(CharSequence text)
String.trim()
for character sequences.public static void debugChar(StringBuffer sb, char ch)
sb
- non-null string buffer to append to.ch
- character to be debugged.public static void debugChar(StringBuilder sb, char ch)
sb
- non-null string buffer to append to.ch
- character to be debugged.public static String debugChar(char ch)
ch
- char to debug.public static void debugText(StringBuffer sb, CharSequence text)
sb
- non-null string buffer to append to.text
- non-null text to be debugged.public static void debugText(StringBuilder sb, CharSequence text)
sb
- non-null string builder to append to.text
- non-null text to be debugged.public static String debugText(CharSequence text)
text
- non-null text to be debugged.public static void checkIndexNonNegative(int index)
IndexOutOfBoundsException
- if the index is not within bounds.public static void checkIndexValid(int index, int length)
IndexOutOfBoundsException
- if the index is not within bounds.public static void checkIndexesValid(int start, int end, int length)
start
- must be >=0 and <=end.end
- must be >=start and <=textLength.length
- total length of a charsequence.IndexOutOfBoundsException
- if the start or end are not within bounds.public static void checkIndexesValid(CharSequence text, int start, int end)
text
- non-null char sequence.start
- must be >=0 and <=end.end
- must be >=start and <=text.length()
.IndexOutOfBoundsException
- if the start or end are not within bounds
of the given text.