|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mockrunner.util.common.StringUtil
Simple util class for String
related methods.
Constructor Summary | |
StringUtil()
|
Method Summary | |
static void |
appendObjectsAsString(java.lang.StringBuffer buffer,
java.util.List data)
Appends the entries in the specified List as strings
with a terminating "\n" after each row. |
static void |
appendTabs(java.lang.StringBuffer buffer,
int number)
Appends number tabs (\t) to the buffer. |
static int |
compare(java.lang.String string1,
java.lang.String string2)
Compares two strings and returns the last index where the two string are equal. |
static int |
countMatches(java.lang.String string,
java.lang.String other)
Returns how many times string contains
other. |
static java.lang.String |
lowerCase(java.lang.String string,
int index)
Converts the character at the specified index to lowercase and returns the resulting string. |
static java.lang.String |
lowerCase(java.lang.String string,
int startIndex,
int endIndex)
Converts the character in the specified index range to lowercase and returns the resulting string. |
static boolean |
matchesContains(java.lang.String source,
java.lang.String target,
boolean caseSensitive)
Returns if source contains target ,
ignoring case, if caseSensitive is false . |
static boolean |
matchesExact(java.lang.String source,
java.lang.String target,
boolean caseSensitive)
Returns if the specified strings are equal, ignoring case, if caseSensitive is false . |
static boolean |
matchesPerl5(java.lang.String source,
java.lang.String target,
boolean caseSensitive)
Returns if the regular expression target matches
source , ignoring case, if caseSensitive
is false . |
static java.lang.String[] |
split(java.lang.String string,
java.lang.String delim,
boolean doTrim)
Splits a string into tokens. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StringUtil()
Method Detail |
public static int compare(java.lang.String string1, java.lang.String string2)
string1
- the first stringstring2
- the second string
public static java.lang.String lowerCase(java.lang.String string, int index)
string
- the string to convertindex
- the index where the character is set to lowercase
java.lang.IndexOutOfBoundsException
- if the index is out of
rangepublic static java.lang.String lowerCase(java.lang.String string, int startIndex, int endIndex)
string
- the string to convertstartIndex
- the index to start, inclusiveendIndex
- the index to end, exclusive
java.lang.IndexOutOfBoundsException
- if the index is out of
rangepublic static void appendObjectsAsString(java.lang.StringBuffer buffer, java.util.List data)
List
as strings
with a terminating "\n" after each row.
buffer
- the bufferdata
- the List
with the datapublic static void appendTabs(java.lang.StringBuffer buffer, int number)
buffer
- the buffernumber
- the number of tabs to appendpublic static java.lang.String[] split(java.lang.String string, java.lang.String delim, boolean doTrim)
StringTokenizer
except that empty tokens are recognized and added as null
.
With a delimiter of ";" the string
"a;;b;c;;" will split into
["a"] [null] ["b"] ["c"] [null].
string
- the Stringdelim
- the delimiterdoTrim
- should each token be trimmed
public static int countMatches(java.lang.String string, java.lang.String other)
string
contains
other.
- Parameters:
string
- the string to searchother
- the string that is searched
- Returns:
- the number of occurences
public static boolean matchesExact(java.lang.String source, java.lang.String target, boolean caseSensitive)
caseSensitive
is false
.
source
- the source Stringtarget
- the target StringcaseSensitive
- is the comparison case sensitive
true
if the strings matches
false
otherwisepublic static boolean matchesContains(java.lang.String source, java.lang.String target, boolean caseSensitive)
source
contains target
,
ignoring case, if caseSensitive
is false
.
source
- the source Stringtarget
- the target StringcaseSensitive
- is the comparison case sensitive
true
if the strings matches
false
otherwisepublic static boolean matchesPerl5(java.lang.String source, java.lang.String target, boolean caseSensitive)
target
matches
source
, ignoring case, if caseSensitive
is false
.
source
- the source Stringtarget
- the target StringcaseSensitive
- is the comparison case sensitive
true
if the strings matches
false
otherwise
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |