|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrailo.commons.lang.StringUtil
public final class StringUtil
Util to do some additional String Operations
Constructor Summary | |
---|---|
StringUtil()
|
Method Summary | |
---|---|
static String |
addZeros(int i,
int size)
adds zeros add the begin of a int example: addZeros(2,3) return "002" |
static String |
addZeros(long i,
int size)
adds zeros add the begin of a int example: addZeros(2,3) return "002" |
static String |
camelToHypenNotation(String str)
translate a string in camel notation to a string in hypen notation example: helloWorld -> hello-world |
static String |
capitalize(String input,
char[] delims)
|
static String |
changeCharset(String str,
String charset)
change charset of string from system default to givenstr |
static String |
changeCharset(String str,
String charset,
String defaultValue)
change charset of string from system default to givenstr |
static boolean |
contains(String str,
String substr)
|
static boolean |
containsIgnoreCase(String str,
String substr)
|
static String |
emptyIfNull(Collection.Key key)
|
static String |
emptyIfNull(String str)
|
static boolean |
endsWith(String str,
char suffix)
Tests if this string ends with the specified suffix. |
static boolean |
endsWithIgnoreCase(String base,
String end)
Helper functions to query a strings end portion. |
static String |
escapeHTML(String html)
Escapes XML Tags |
static String |
escapeJS(String str)
escapes JS sensitive characters |
static char |
firstChar(String str)
return the first character of a string, if string ist empty return 0; |
static boolean |
hasLineFeed(String str)
return if in a string are line feeds or not |
static boolean |
hasUpperCase(String str)
|
static String |
hypenToCamelNotation(String str)
translate a string in hypen notation to a string in camel notation example: hello-world -> helloWorld |
static int |
indexOf(String haystack,
String needle)
|
static int |
indexOfIgnoreCase(String haystack,
String needle)
|
static boolean |
isAscii(String str)
|
static boolean |
isBOM(byte[] barr)
returns if byte arr is a BOM character Stream (UTF-8,UTF-16) |
static boolean |
isEmpty(Object obj)
|
static boolean |
isEmpty(Object obj,
boolean trim)
|
static boolean |
isEmpty(String str)
|
static boolean |
isEmpty(String str,
boolean trim)
|
static boolean |
isEmpty(StringBuffer sb)
|
static boolean |
isEmpty(StringBuffer sb,
boolean trim)
|
static boolean |
isEmpty(StringBuilder sb)
|
static boolean |
isEmpty(StringBuilder sb,
boolean trim)
|
static boolean |
isWhiteSpace(char c)
|
static boolean |
isWhiteSpace(String str)
|
static char |
lastChar(String str)
return the last character of a string, if string ist empty return 0; |
static String |
lcFirst(String str)
do first Letter Upper case |
static int |
length(String str)
|
static String |
ltrim(String str,
String defaultValue)
This function returns a string with whitespace stripped from the beginning of str |
static String |
max(String content,
int max)
cut string to max size if the string is greater, otherweise to nothing |
static String |
max(String content,
int max,
String dotDotDot)
|
static String[] |
merge(String str,
String[] arr)
|
static String |
removeQuotes(String string,
boolean trim)
removes quotes(",') that wraps the string |
static String |
removeStarting(String str,
String sub)
|
static String |
removeStartingIgnoreCase(String str,
String sub)
|
static String |
removeWhiteSpace(String str)
|
static String |
repeatString(String str,
int count)
reapeats a string |
static String |
replace(String input,
String find,
String repl)
performs a CaSe sensitive replace all |
static String |
replace(String input,
String find,
String repl,
boolean firstOnly)
maintains the legacy signature of this method where matches are CaSe sensitive (sets the default of ignoreCase to false). |
static String |
replace(String input,
String find,
String repl,
boolean firstOnly,
boolean ignoreCase)
performs a replace operation on a string |
static String |
replaceLast(String str,
char from,
char to)
|
static String |
replaceLast(String str,
String from,
String to)
|
static String |
replaceMap(String input,
Map map,
boolean ignoreCase)
this is the public entry point for the replaceMap() method |
static String |
reqExpEscape(String str)
escape all special characters of the regular expresson language |
static String |
rtrim(String str,
String defaultValue)
This function returns a string with whitespace stripped from the end of str |
static String |
soundex(String str)
soundex function |
static boolean |
startsWith(String str,
char prefix)
Tests if this string starts with the specified prefix. |
static boolean |
startsWithIgnoreCase(String base,
String start)
Helper functions to query a strings start portion. |
static String |
substring(String str,
int off,
int len)
this method works different from the regular substring method, the regular substring method takes startIndex and endIndex as second and third argument, this method takes offset and length |
static String |
substringEL(String str,
int index,
String defaultValue)
|
static String |
suppressWhiteSpace(String str)
remove all white spaces followd by whitespaces |
static String |
toClassName(String str)
translate a string to a valid classname string |
static String |
toIdentityVariableName(String varName)
translate a string to a valid identity variable name |
static String |
toLowerCase(String str)
cast a string a lower case String, is faster than the String.toLowerCase, if all Character are already Low Case |
static String |
toString(Object value,
String defaultValue)
returns string, if given string is null or lengt 0 return default value |
static String |
toString(String value,
String defaultValue)
returns string, if given string is null or lengt 0 return default value |
static String |
toStringEmptyIfNull(Object o)
translate, like method toString, a object to a string, but when value is null value will be translated to a empty String (""). |
static String |
toUpperCase(String str)
|
static String |
toVariableName(String str)
translate a string to a valid variable string |
static String |
toVariableName(String str,
boolean addIdentityNumber)
|
static String |
trim(String str,
String defaultValue)
trim given value, return defaultvalue when input is null |
static String |
ucFirst(String str)
do first Letter Upper case |
static String |
unescapeHTML(String html)
Unescapes HTML Tags |
static String |
valueOf(String str)
return "" if value is null otherwise return same string |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringUtil()
Method Detail |
---|
public static String ucFirst(String str)
str
- String to operate
public static String capitalize(String input, char[] delims)
public static String lcFirst(String str)
str
- String to operate
public static String unescapeHTML(String html)
html
- html code to escape
public static String escapeHTML(String html)
html
- html code to unescape
public static String escapeJS(String str)
str
- String to escape
public static String repeatString(String str, int count)
str
- string to repeatcount
- how many time string will be reapeted
public static String toStringEmptyIfNull(Object o)
o
- Object to convert
public static String emptyIfNull(String str)
public static String emptyIfNull(Collection.Key key)
public static String reqExpEscape(String str)
str
- String to escape
public static String toIdentityVariableName(String varName)
varName
- variable name template to translate
public static String toClassName(String str)
str
- string to translate
public static String toVariableName(String str)
str
- string to translate
public static String toVariableName(String str, boolean addIdentityNumber)
public static String ltrim(String str, String defaultValue)
str
- String to clean
public static String rtrim(String str, String defaultValue)
str
- String to clean
public static boolean hasLineFeed(String str)
str
- string to check
public static String suppressWhiteSpace(String str)
str
- strring to translate
public static String toString(String value, String defaultValue)
value
- defaultValue
-
public static String toString(Object value, String defaultValue)
value
- defaultValue
-
public static String max(String content, int max)
content
- max
-
public static String max(String content, int max, String dotDotDot)
public static String replace(String input, String find, String repl, boolean firstOnly, boolean ignoreCase)
input
- - the string input to work onfind
- - the substring to findrepl
- - the substring to replace the matches withfirstOnly
- - if true then only the first occurrence of find
will be replacedignoreCase
- - if true then matches will not be case sensitive
public static String replace(String input, String find, String repl, boolean firstOnly)
input
- - the string input to work onfind
- - the substring to findrepl
- - the substring to replace the matches withfirstOnly
- - if true then only the first occurrence of find
will be replaced
public static String replace(String input, String find, String repl)
input
- - the string input to work onfind
- - the substring to findrepl
- - the substring to replace the matches with
public static String addZeros(int i, int size)
i
- number to add nullssize
-
public static String addZeros(long i, int size)
i
- number to add nullssize
-
public static int indexOf(String haystack, String needle)
public static int indexOfIgnoreCase(String haystack, String needle)
public static boolean startsWith(String str, char prefix)
str
- string to check first charprefix
- the prefix.
public static boolean endsWith(String str, char suffix)
str
- string to check first charsuffix
- the suffix.
public static boolean startsWithIgnoreCase(String base, String start)
base
- the base string.start
- the starting text.
public static boolean endsWithIgnoreCase(String base, String end)
base
- the base string.end
- the ending text.
public static boolean isBOM(byte[] barr)
barr
-
public static String valueOf(String str)
str
-
public static String toLowerCase(String str)
str
-
public static String toUpperCase(String str)
public static String soundex(String str)
str
-
public static char lastChar(String str)
str
- string to get last character
public static boolean isEmpty(String str)
str
-
public static boolean isEmpty(String str, boolean trim)
str
-
public static char firstChar(String str)
str
- string to get first character
public static String changeCharset(String str, String charset) throws UnsupportedEncodingException
str
- charset
-
UnsupportedEncodingException
public static String changeCharset(String str, String charset, String defaultValue)
str
- charset
-
UnsupportedEncodingException
public static boolean isWhiteSpace(char c)
public static String removeWhiteSpace(String str)
public static String replaceLast(String str, char from, char to)
public static String replaceLast(String str, String from, String to)
public static String removeQuotes(String string, boolean trim)
string
-
public static boolean isEmpty(Object obj, boolean trim)
public static boolean isEmpty(Object obj)
public static boolean isEmpty(StringBuffer sb, boolean trim)
public static boolean isEmpty(StringBuilder sb, boolean trim)
public static boolean isEmpty(StringBuffer sb)
public static boolean isEmpty(StringBuilder sb)
public static String removeStarting(String str, String sub)
public static String removeStartingIgnoreCase(String str, String sub)
public static String[] merge(String str, String[] arr)
public static int length(String str)
public static boolean hasUpperCase(String str)
public static String trim(String str, String defaultValue)
str
- defaultValue
-
public static boolean contains(String str, String substr)
public static boolean containsIgnoreCase(String str, String substr)
public static String substringEL(String str, int index, String defaultValue)
public static String camelToHypenNotation(String str)
str
-
public static String hypenToCamelNotation(String str)
str
-
public static boolean isAscii(String str)
public static boolean isWhiteSpace(String str)
public static String substring(String str, int off, int len)
str
- off
- len
-
public static String replaceMap(String input, Map map, boolean ignoreCase) throws PageException
input
- - the string on which the replacements should be performed.map
- - a java.util.Map with key/value pairs where the key is the substring to find and the value is the substring with which to replace the matched keyignoreCase
- - if true then matches will not be case sensitive
PageException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |