|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.mockrunner.util.common.StringUtil
public class 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 |
fieldToString(java.lang.String fieldName,
java.lang.Object field)
Helper method for toString() implementations. |
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 |
replaceAll(java.lang.String source,
java.lang.String match,
java.lang.String replacement)
Replaces all occurrences of match in
source with replacement. |
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 java.lang.String replaceAll(java.lang.String source,
java.lang.String match,
java.lang.String replacement)
match in
source with replacement.
source - the source stringmatch - the string that is searchedreplacement - the replacement string
java.lang.IllegalArgumentException - if any argument is null or
if match is the empty string
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
range
public 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
range
public static java.lang.String fieldToString(java.lang.String fieldName,
java.lang.Object field)
toString() implementations.
Returns a string "field name: value". Handles
null values, collections and arrays. If the
field is a collection or an array, the returned string will
be:"field name 0: value0\nfield name 1: value1"
fieldName - the field namefield - the field value
toString() implementations
public 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 data
public static void appendTabs(java.lang.StringBuffer buffer,
int number)
buffer - the buffernumber - the number of tabs to append
public 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.
string - the string to searchother - the string that is searched
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 otherwise
public 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 otherwise
public 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 | |||||||||