Package com.smartgwt.client.util
Class StringUtil
java.lang.Object
com.smartgwt.client.util.StringUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringabbreviate(String str, int maxWidth) Abbreviates a String using ellipses.static StringConvert plain text into into displayable HTML.static StringConvert plain text into into displayable HTML.static StringconvertTags(String str, String prefix, String suffix) Convert all tag symbols ( < and > ) into displayable HTML by changing them to < and > respectively.static booleanTests whether the given string is a valid JavaScript identifier.static StringmakeXMLSafe(String str) Escapes special characters in XML values - so called 'unparsed data'static StringunescapeHTML(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:
trueifstringis a valid JavaScript identifier;falseotherwise.
-