|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.groiss.util.StringUtil
public class StringUtil
Some convenient string manipulation methods.
Method Summary | |
---|---|
static java.lang.String |
decodeURL(java.lang.String url)
|
static java.lang.String |
encodeURL(java.lang.String url)
This calls the URLEncoder.encode with the configured charset. |
static boolean |
equalStrings(java.lang.String first,
java.lang.String second)
Checks if both strings are equal. |
static boolean |
escapeForSQL(java.lang.CharSequence txt)
Escapes all occurencies of character '_' in the passed string builder with the escape character '\'. |
static java.lang.String |
escapeJavaStyleString(java.lang.String str,
boolean escapeSingleQuote)
|
static java.lang.String |
format(java.lang.String pattern,
java.lang.Object[] arguments)
Formats the passed pattern with the passed argument (as known by java.text.MessageFormat(String, Object []) but it guarantees that single quotes remain in the pattern (class MessageFormat would remove them). |
static java.lang.String |
getCharset()
|
static java.text.Collator |
getCollator()
Returns a Collator to sort Strings correctly |
static java.lang.String |
htmlDecode(java.lang.String s)
Decodes html entities defined in XHTML 1.0. |
static java.lang.String |
htmlEncode(java.lang.Object o)
Translates some special characters to their representation in HTML. |
static boolean |
isEmpty(java.lang.String s)
Is the string null or the empty string |
static boolean |
isNotEmpty(java.lang.String s)
|
static boolean |
isNumber(java.lang.String s)
|
static boolean |
isRTL(java.util.Locale loc)
Is the writing direction in the given locale right-to-left? This is for example true in Hebrew, Arabic, or Persian |
static java.lang.String |
noEmpty(java.lang.Object o)
Returns " " when argument is null, otherwise o.toString() |
static java.lang.String |
noEmpty(java.lang.String s)
Returns " " when argument is null, otherwise the string itself. |
static java.lang.String |
noNull(java.lang.Object s)
Returns the empty string when argument is null, otherwise s.toString() |
static java.lang.String |
noNull(java.lang.String s)
Returns the empty string when argument is null, otherwise the string itself. |
static java.lang.String |
noTags(java.lang.String text)
De-HTMLize a string. |
static java.lang.String |
quoteForSQL(java.lang.String arg)
Doubles the singe quote ' to ''. |
static java.lang.String |
replaceChar(java.lang.String str,
char oldch,
java.lang.String newStr)
Replace a character by a string. |
static void |
setCharset(java.lang.String charSet)
|
static java.util.List<java.lang.String> |
split(java.lang.String mask,
java.lang.String pat)
Split a string into pieces. |
static java.util.List<java.lang.String> |
split(java.lang.String mask,
java.lang.String pat,
boolean withPat)
Split a string into pieces. |
static java.lang.String |
substitute(java.lang.String mask,
java.lang.String pat,
java.lang.String value)
Substitute a value for a pattern |
static java.lang.String[] |
toArray(java.lang.String s,
java.lang.String delim)
Splits the passed string using the passed delimiter and returns the trimmed parts as array. |
static java.lang.String |
transformForSQL(java.lang.String arg)
Replaces '*' with '%' and '?' with '_' which are the correct wildcards for sql queries. |
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 substitute(java.lang.String mask, java.lang.String pat, java.lang.String value)
mask
- the mask containing the patternspat
- the pattern to substitutevalue
- the value inserted instead of the pattern
public static java.lang.String noNull(java.lang.String s)
s
- a string
public static java.lang.String noNull(java.lang.Object s)
s
- a object
public static java.lang.String noEmpty(java.lang.String s)
s
- a string
public static java.lang.String noEmpty(java.lang.Object o)
o
- a object
public static java.lang.String quoteForSQL(java.lang.String arg)
arg
- a string
public static java.lang.String transformForSQL(java.lang.String arg)
quoteForSQL(String)
is called
arg
- the string in which the replacements and quotes should be performed
public static boolean escapeForSQL(java.lang.CharSequence txt)
txt
- holds the string which should be escaped
public static java.lang.String htmlEncode(java.lang.Object o)
o
- an object with a toString method, the string is translated
public static java.lang.String htmlDecode(java.lang.String s)
s
- a string containing entities like <
public static java.lang.String replaceChar(java.lang.String str, char oldch, java.lang.String newStr)
str
- the stringoldch
- the character to replacenewStr
- the new string
public static java.util.List<java.lang.String> split(java.lang.String mask, java.lang.String pat)
mask
- the mask to splitpat
- the separator for splitting
public static java.util.List<java.lang.String> split(java.lang.String mask, java.lang.String pat, boolean withPat)
mask
- the string to splitpat
- the separator for splittingwithPat
- if true, the strings start with the split pattern
public static java.lang.String noTags(java.lang.String text)
text
- a string containing HTML tags
public static boolean equalStrings(java.lang.String first, java.lang.String second)
public static boolean isEmpty(java.lang.String s)
s
- the string
public static boolean isNotEmpty(java.lang.String s)
public static java.lang.String encodeURL(java.lang.String url)
url
- the url containing special characters
public static java.lang.String decodeURL(java.lang.String url)
public static java.lang.String getCharset()
public static void setCharset(java.lang.String charSet)
public static boolean isRTL(java.util.Locale loc)
loc
- the locale
public static java.lang.String format(java.lang.String pattern, java.lang.Object[] arguments)
pattern
- the pattern to formatarguments
- the arguments for the pattern
public static boolean isNumber(java.lang.String s)
public static java.lang.String escapeJavaStyleString(java.lang.String str, boolean escapeSingleQuote)
public static java.text.Collator getCollator()
Returns a Collator
to sort Strings
correctly
ThreadLocale
public static java.lang.String[] toArray(java.lang.String s, java.lang.String delim)
s
- the string to be splitdelim
- the delimiter for splitting
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |