Package com.smartgwt.client.util
Class StringUtil
java.lang.Object
com.smartgwt.client.util.StringUtil
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
abbreviate
(String str, int maxWidth) Abbreviates a String using ellipses.static String
Convert plain text into into displayable HTML.static String
Convert plain text into into displayable HTML.static String
convertTags
(String str, String prefix, String suffix) Convert all tag symbols ( < and > ) into displayable HTML by changing them to < and > respectively.static boolean
Tests whether the given string is a valid JavaScript identifier.static String
makeXMLSafe
(String str) Escapes special characters in XML values - so called 'unparsed data'static String
unescapeHTML
(String str) ReversesasHTML(String)
.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
convertTags
Convert all tag symbols ( < and > ) into displayable HTML by changing them to < and > respectively.- Parameters:
str
- the string to convertprefix
- text to tack onto the beginning of result (eg: "<PRE>")suffix
- text to tack onto the end of result (eg: "</PRE>")- Returns:
- prefix + converted text + suffix as a single string
-
asHTML
Convert plain text into into displayable HTML. This prevents HTML-special characters like < and > from being interpreted as tags, and preserves line breaks and extra spacing.converts to -------- --------------------------- & & < < > > \r,\n,\r\n1space
\r,\n,\r\n
\t 2 spaces 1space- Parameters:
str
- the string to convert- Returns:
- the plain text into into displayable HTM
-
asHTML
Convert plain text into into displayable HTML. This prevents HTML-special characters like < and > from being interpreted as tags, and preserves line breaks and extra spacing.converts to -------- --------------------------- & & < < > > \r,\n,\r\n1space
\r,\n,\r\n
\t 2 spaces 1space- Parameters:
str
- the string to convertnoAutoWrap
-- Returns:
- the plain text into into displayable HTM
-
unescapeHTML
ReversesasHTML(String)
.- Parameters:
str
- the input str- Returns:
- unescaped HTML
-
makeXMLSafe
Escapes special characters in XML values - so called 'unparsed data'" -> " ' -> ' & -> & < -> < > -> > \r -> &x000D;
- Parameters:
str
- the String to escape- Returns:
- xml safe String
-
abbreviate
Abbreviates a String using ellipses. StringUtils.abbreviate("abcdefg", 6) = "abc..."- Parameters:
str
- the String to abbreviatemaxWidth
- maximum length of result String, must be at least 4- Returns:
- the abbreviated String
- Throws:
IllegalArgumentException
- when the width is too small
-
isValidID
Tests whether the given string is a valid JavaScript identifier.- Parameters:
string
- the string to test.- Returns:
true
ifstring
is a valid JavaScript identifier;false
otherwise.
-