public class StringUtil
extends java.lang.Object
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
abbreviate(java.lang.String str,
int maxWidth)
Abbreviates a String using ellipses.
|
static java.lang.String |
asHTML(java.lang.String str)
Convert plain text into into displayable HTML.
|
static java.lang.String |
asHTML(java.lang.String str,
boolean noAutoWrap)
Convert plain text into into displayable HTML.
|
static java.lang.String |
convertTags(java.lang.String str,
java.lang.String prefix,
java.lang.String suffix)
Convert all tag symbols ( < and > ) into displayable HTML
by changing them to < and > respectively.
|
static boolean |
isValidID(java.lang.String string)
Tests whether the given string is a valid JavaScript identifier.
|
static java.lang.String |
makeXMLSafe(java.lang.String str)
Escapes special characters in XML values - so called 'unparsed data'
|
static java.lang.String |
unescapeHTML(java.lang.String str)
Reverses
asHTML(String). |
public static java.lang.String convertTags(java.lang.String str,
java.lang.String prefix,
java.lang.String suffix)
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>")public static java.lang.String asHTML(java.lang.String str)
converts to
-------- ---------------------------
& &
< <
> >
\r,\n,\r\n1space
\r,\n,\r\n
\t
2 spaces 1space
str - the string to convertpublic static java.lang.String asHTML(java.lang.String str,
boolean noAutoWrap)
converts to
-------- ---------------------------
& &
< <
> >
\r,\n,\r\n1space
\r,\n,\r\n
\t
2 spaces 1space
str - the string to convertnoAutoWrap - public static java.lang.String unescapeHTML(java.lang.String str)
asHTML(String).str - the input strpublic static java.lang.String makeXMLSafe(java.lang.String str)
" -> " ' -> ' & -> & < -> < > -> > \r -> &x000D;
str - the String to escapepublic static java.lang.String abbreviate(java.lang.String str,
int maxWidth)
str - the String to abbreviatemaxWidth - maximum length of result String, must be at least 4java.lang.IllegalArgumentException - when the width is too smallpublic static boolean isValidID(java.lang.String string)
string - the string to test.true if string is a valid JavaScript identifier; false otherwise.