|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.mmapps.commons.util.StringUtil
public class StringUtil
Constructor Summary | |
---|---|
StringUtil()
|
Method Summary | |
---|---|
static java.lang.String |
addLeadingChar(java.lang.String str,
char ch,
int total)
Add Leading Char.to the string |
static int |
countOccurences(java.lang.String haystack,
java.lang.String needle)
This method counts the occurences of 'needle' in the string 'haystack'. |
static int |
countOccurences(java.lang.String haystack,
java.lang.String needle,
int position)
This method counts the occurences of 'needle' in the string 'haystack' starting from position 'position'. |
static java.lang.String |
escapeXml(java.lang.String str)
|
static boolean |
isEmpty(java.lang.String str)
is Empty.String |
static boolean |
isEmptyOrWhitespace(java.lang.String str)
is Empty Or Whitespace.String |
static java.lang.String |
randomString(int len,
char begin,
char end)
Generates a String with length 'len', filled with random(ish) characters from 'begin' to 'end'. e.g. randomString(3, 'a', 'm') can return "kgm", "faa", "dlb", etc. but never "kgn" (because 'n' doesn't lie between 'a' and 'm') |
static java.lang.String |
removeWhitespaces(java.lang.String s)
Remove all whitespaces from a string |
static java.lang.String |
replace(java.lang.String str,
java.lang.String oldToken,
java.lang.String newToken)
Transforms a string by replacing every occurence of a given searchstring with another string. |
static java.lang.String |
replaceIgnoreCase(java.lang.String str,
java.lang.String oldToken,
java.lang.String newToken)
Transforms a string by replacing every occurence of a given searchstring with another string. |
static java.lang.String |
truncate(java.lang.String str,
int maxLength)
Returns a new string with the given maximum length of the given string, with "..." appended to the end if the maximum length was exceeded. |
static java.lang.String |
wrap(java.lang.String str,
int lineLength)
Wraps the given string, using the java.text.BreakIterator. |
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 boolean isEmpty(java.lang.String str)
str
- String to check emptiness
public static boolean isEmptyOrWhitespace(java.lang.String str)
str
- String to check emptiness
public static java.lang.String addLeadingChar(java.lang.String str, char ch, int total)
str
- String to add character in front ofch
- character to addtotal
- total length of output string
public static java.lang.String replace(java.lang.String str, java.lang.String oldToken, java.lang.String newToken)
str
- The sourcestring.oldToken
- The searchstring.newToken
- The replacestring.
public static java.lang.String replaceIgnoreCase(java.lang.String str, java.lang.String oldToken, java.lang.String newToken)
str
- The sourcestring.oldToken
- The searchstring.newToken
- The replacestring.
public static int countOccurences(java.lang.String haystack, java.lang.String needle)
haystack
- full stringneedle
- needle to search for
public static int countOccurences(java.lang.String haystack, java.lang.String needle, int position)
haystack
- full stringneedle
- needle to search forposition
- starting position
public static java.lang.String escapeXml(java.lang.String str)
public static java.lang.String randomString(int len, char begin, char end)
len
- the length of the desired stringbegin
- the first valid character in the sequence of possible charactersend
- the first valid character in the sequence of possible characters
public static java.lang.String wrap(java.lang.String str, int lineLength)
str
- The string that might be too longlineLength
- The maximum length of the lines to be returned.
public static java.lang.String truncate(java.lang.String str, int maxLength)
str
- The string that might be too longmaxLength
- The maximum length of the string to be returned, ignored if <= 0.
public static java.lang.String removeWhitespaces(java.lang.String s)
s
- String which might contain whitespaces
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |