public class StringUtil
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
breakText(java.lang.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 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 occurrences 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()
The charset used in communication with the browser.
|
static java.text.Collator |
getCollator()
Returns a
Collator to sort Strings correctly |
static java.lang.String |
getJarPrefix(java.lang.String url)
Return the jar prefix of the given url string.
|
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 |
isJar(java.lang.String url)
Determine whether the given url string points to a resource in a jar file.
|
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?
|
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 |
normalizeUnicode(java.lang.String str)
Normalize to "Canonical decomposition, followed by canonical composition."
|
static java.lang.String |
noTags(java.lang.String text)
De-HTMLize a string.
|
static java.lang.String |
quoteForSQL(java.lang.String arg)
Doubles the single quote ' to two of them ''.
|
static java.lang.String |
replaceChar(java.lang.String str,
char oldch,
java.lang.String newStr)
Replace a character by a string.
|
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.util.Locale |
toLocale(java.lang.String localeString)
Get a Locale from a string.
|
static java.lang.String |
transformForSQL(java.lang.String arg)
Replaces '*' with '%' and '?'
|
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 patternpublic static java.lang.String noNull(java.lang.String s)
s
- a stringpublic static java.lang.String noNull(java.lang.Object s)
s
- a objectpublic static java.lang.String noEmpty(java.lang.String s)
s
- a stringpublic static java.lang.String noEmpty(java.lang.Object o)
o
- a objectpublic static java.lang.String quoteForSQL(java.lang.String arg)
arg
- a stringpublic static java.lang.String transformForSQL(java.lang.String arg)
quoteForSQL(String)
is calledarg
- the string in which the replacements and quotes should be performedpublic static boolean escapeForSQL(java.lang.CharSequence txt)
txt
- holds the string which should be escapedpublic static java.lang.String htmlEncode(java.lang.Object o)
o
- an object with a toString method, the string is translatedpublic 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 stringpublic static java.util.List<java.lang.String> split(java.lang.String mask, java.lang.String pat)
mask
- the mask to splitpat
- the separator for splittingpublic 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 patternpublic static java.lang.String noTags(java.lang.String text)
text
- a string containing HTML tagspublic static boolean equalStrings(java.lang.String first, java.lang.String second)
public static boolean isEmpty(java.lang.String s)
s
- the stringpublic static boolean isNotEmpty(java.lang.String s)
public static java.lang.String encodeURL(java.lang.String url)
url
- the url containing special characterspublic static java.lang.String decodeURL(java.lang.String url)
public static java.lang.String getCharset()
public static boolean isRTL(java.util.Locale loc)
loc
- the localepublic static java.lang.String format(java.lang.String pattern, java.lang.Object[] arguments)
pattern
- the pattern to formatarguments
- the arguments for the patternpublic 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 breakText(java.lang.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 java.lang.String[] toArray(java.lang.String s, java.lang.String delim)
s
- the string to be splitdelim
- the delimiter for splittingpublic static java.lang.String normalizeUnicode(java.lang.String str)
public static java.util.Locale toLocale(java.lang.String localeString)
localeString
- the String to convert to a localepublic static java.lang.String getJarPrefix(java.lang.String url)
url
- a String representation of the urlisJar(String)
returns true, null else.public static boolean isJar(java.lang.String url)
url
- a String representation of the url@enterprise 9.0.33982 Copyright © 2001-2023 Groiss Informatics GmbH. All Rights Reserved.