|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.googlecode.flyway.core.util.StringUtils
public class StringUtils
Various string-related utilities.
| Method Summary | |
|---|---|
static java.lang.String |
arrayToCommaDelimitedString(java.lang.String[] strings)
Turns this string array in one comma-delimited string. |
static java.lang.String |
collapseWhitespace(java.lang.String str)
Replaces all sequences of whitespace by a single blank. |
static java.lang.String |
collectionToCommaDelimitedString(java.util.Collection<?> collection)
Convenience method to return a Collection as a comma-delimited String. |
static int |
countOccurrencesOf(java.lang.String str,
java.lang.String token)
Counts the number of occurances of this token in this string. |
static boolean |
hasLength(java.lang.String str)
Checks whether this string is not null and not blank. |
static boolean |
hasText(java.lang.String s)
Checks whether this string contains at least one non-blank character. |
static boolean |
isNumeric(java.lang.String str)
Checks if the String contains only unicode digits. |
static java.lang.String |
left(java.lang.String str,
int count)
Returns the first n characters from this string, where n = count. |
static java.lang.String |
replace(java.lang.String inString,
java.lang.String oldPattern,
java.lang.String newPattern)
Replace all occurences of a substring within a string with another string. |
static java.lang.String |
replaceAll(java.lang.String str,
java.lang.String originalToken,
java.lang.String replacementToken)
Replaces all occurrances of this originalToken in this string with this replacementToken. |
static java.lang.String[] |
tokenizeToStringArray(java.lang.String str,
java.lang.String delimiters)
Splits this string into an array using these delimiters. |
static java.lang.String |
trimLeadingWhitespace(java.lang.String str)
Trim leading whitespace from the given String. |
static java.lang.String |
trimOrPad(java.lang.String str,
int length)
Trims or pads (with spaces) this string, so it has this exact length. |
static java.lang.String |
trimTrailingWhitespace(java.lang.String str)
Trim trailing whitespace from the given String. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String trimOrPad(java.lang.String str,
int length)
str - The string to adjust. null is treated as an empty string.length - The exact length to reach.
public static boolean isNumeric(java.lang.String str)
Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false.
null will return false. An empty String ("") will return true.
StringUtils.isNumeric(null) = false
StringUtils.isNumeric("") = true
StringUtils.isNumeric(" ") = false
StringUtils.isNumeric("123") = true
StringUtils.isNumeric("12 3") = false
StringUtils.isNumeric("ab2c") = false
StringUtils.isNumeric("12-3") = false
StringUtils.isNumeric("12.3") = false
str - the String to check, may be null
true if only contains digits, and is non-nullpublic static java.lang.String collapseWhitespace(java.lang.String str)
str - The string to analyse.
public static java.lang.String left(java.lang.String str,
int count)
str - The string to parse.count - The amount of characters to return.
public static java.lang.String replaceAll(java.lang.String str,
java.lang.String originalToken,
java.lang.String replacementToken)
str - The string to process.originalToken - The token to replace.replacementToken - The replacement.
public static boolean hasLength(java.lang.String str)
null and not blank.
str - The string to check.
true if it has content, false if it is null or blank.public static java.lang.String arrayToCommaDelimitedString(java.lang.String[] strings)
strings - The array to process.
public static boolean hasText(java.lang.String s)
s - The string to check.
true if it has text, false if not.
public static java.lang.String[] tokenizeToStringArray(java.lang.String str,
java.lang.String delimiters)
str - The string to split.delimiters - The delimiters to use.
public static int countOccurrencesOf(java.lang.String str,
java.lang.String token)
str - The string to analyse.token - The token to look for.
public static java.lang.String replace(java.lang.String inString,
java.lang.String oldPattern,
java.lang.String newPattern)
inString - String to examineoldPattern - String to replacenewPattern - String to insert
public static java.lang.String collectionToCommaDelimitedString(java.util.Collection<?> collection)
toString() implementations.
collection - the Collection to analyse
public static java.lang.String trimLeadingWhitespace(java.lang.String str)
str - the String to check
Character.isWhitespace(char)public static java.lang.String trimTrailingWhitespace(java.lang.String str)
str - the String to check
Character.isWhitespace(char)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||