public class StringUtil extends Object
Modifier and Type | Method and Description |
---|---|
static String |
breakText(String text,
int maxl,
boolean insertSplitMark)
This method breaks a text (i.e. inserts "\n" characters)
so that none of its lines exceed the maximum line length specified
by the parameter
maxl . |
static String |
decodeURL(String url) |
static String |
encodeURL(String url)
This calls the URLEncoder.encode with the configured charset.
|
static boolean |
equalStrings(String first,
String second)
Checks if both strings are equal.
|
static boolean |
escapeForSQL(CharSequence txt)
Escapes all occurrences of character '_' in the passed string builder with the escape character '\'.
|
static String |
escapeJavaStyleString(String str,
boolean escapeSingleQuote) |
static String |
format(String pattern,
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 String |
getCharset()
The charset used in communication with the browser.
|
static Collator |
getCollator()
Returns a
Collator to sort Strings correctly |
static String |
getJarPrefix(String url)
Return the jar prefix of the given url string.
|
static String |
htmlDecode(String s)
Decodes html entities defined in XHTML 1.0.
|
static String |
htmlEncode(Object o)
Translates some special characters to their representation in HTML.
|
static boolean |
isEmpty(String s)
Is the string null or the empty string
|
static boolean |
isJar(String url)
Determine whether the given url string points to a resource in a jar file.
|
static boolean |
isNotEmpty(String s) |
static boolean |
isNumber(String s) |
static boolean |
isRTL(Locale loc)
Is the writing direction in the given locale right-to-left?
|
static String |
noEmpty(Object o)
Returns " " when argument is null, otherwise o.toString()
|
static String |
noEmpty(String s)
Returns " " when argument is null, otherwise the string itself.
|
static String |
noNull(Object s)
Returns the empty string when argument is null, otherwise s.toString()
|
static String |
noNull(String s)
Returns the empty string when argument is null, otherwise the string itself.
|
static String |
normalizeUnicode(String str)
Normalize to "Canonical decomposition, followed by canonical composition."
|
static String |
noTags(String text)
De-HTMLize a string.
|
static String |
quoteForSQL(String arg)
Doubles the single quote ' to two of them ''.
|
static String |
replaceChar(String str,
char oldch,
String newStr)
Replace a character by a string.
|
static List<String> |
split(String mask,
String pat)
Split a string into pieces.
|
static List<String> |
split(String mask,
String pat,
boolean withPat)
Split a string into pieces.
|
static String |
substitute(String mask,
String pat,
String value)
Substitute a value for a pattern
|
static String[] |
toArray(String s,
String delim)
Splits the passed string using the passed delimiter and returns the trimmed parts as array.
|
static Locale |
toLocale(String localeString)
Get a Locale from a string.
|
static String |
transformForSQL(String arg)
Replaces '*' with '%' and '?'
|
public static String substitute(String mask, String pat, String value)
mask
- the mask containing the patternspat
- the pattern to substitutevalue
- the value inserted instead of the patternpublic static String noNull(String s)
s
- a stringpublic static String noNull(Object s)
s
- a objectpublic static String noEmpty(String s)
s
- a stringpublic static String noEmpty(Object o)
o
- a objectpublic static String quoteForSQL(String arg)
arg
- a stringpublic static String transformForSQL(String arg)
quoteForSQL(String)
is calledarg
- the string in which the replacements and quotes should be performedpublic static boolean escapeForSQL(CharSequence txt)
txt
- holds the string which should be escapedpublic static String htmlEncode(Object o)
o
- an object with a toString method, the string is translatedpublic static String htmlDecode(String s)
s
- a string containing entities like <public static String replaceChar(String str, char oldch, String newStr)
str
- the stringoldch
- the character to replacenewStr
- the new stringpublic static List<String> split(String mask, String pat)
mask
- the mask to splitpat
- the separator for splittingpublic static List<String> split(String mask, String pat, boolean withPat)
mask
- the string to splitpat
- the separator for splittingwithPat
- if true, the strings start with the split patternpublic static String noTags(String text)
text
- a string containing HTML tagspublic static boolean equalStrings(String first, String second)
public static boolean isEmpty(String s)
s
- the stringpublic static boolean isNotEmpty(String s)
public static String encodeURL(String url)
url
- the url containing special characterspublic static String getCharset()
public static boolean isRTL(Locale loc)
loc
- the localepublic static String format(String pattern, Object... arguments)
pattern
- the pattern to formatarguments
- the arguments for the patternpublic static boolean isNumber(String s)
public static String escapeJavaStyleString(String str, boolean escapeSingleQuote)
public static Collator getCollator()
Returns a Collator
to sort Strings
correctly
ThreadLocale
public static String breakText(String text, int maxl, boolean insertSplitMark)
maxl
.text
- the text to breakmaxl
- the maximum line lengthinsertSplitMark
- if true insert the character » where line has been splitpublic static String[] toArray(String s, String delim)
s
- the string to be splitdelim
- the delimiter for splittingpublic static String normalizeUnicode(String str)
public static Locale toLocale(String localeString)
localeString
- the String to convert to a localepublic static String getJarPrefix(String url)
url
- a String representation of the urlisJar(String)
returns true, null else.public static boolean isJar(String url)
url
- a String representation of the url@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.