com.smartgwt.client.util

## Class StringUtil

- java.lang.Object
- - com.smartgwt.client.util.StringUtil

-     public class StringUtil
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    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 &lt; and &gt; 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)`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StringUtil

          public StringUtil()

  - ### Method Detail

    - #### convertTags

          public 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 &lt; and &gt; respectively.
      Parameters:
        `str` - the string to convert
        `prefix` - 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

          public static java.lang.String asHTML(java.lang.String str)

      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

          public static java.lang.String asHTML(java.lang.String str,
                                                boolean noAutoWrap)

      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
        `noAutoWrap` -
      Returns:
        the plain text into into displayable HTM

    - #### unescapeHTML

          public static java.lang.String unescapeHTML(java.lang.String str)

      Reverses `asHTML(String)`.
      Parameters:
        `str` - the input str
      Returns:
        unescaped HTML

    - #### makeXMLSafe

          public static java.lang.String makeXMLSafe(java.lang.String str)

      Escapes special characters in XML values - so called 'unparsed data'

           " -> "
           ' -> '
           & -> &
           < -> <
           > -> >
           \r -> &x000D;

      Parameters:
        `str` - the String to escape
      Returns:
        xml safe String

    - #### abbreviate

          public static java.lang.String abbreviate(java.lang.String str,
                                                    int maxWidth)

      Abbreviates a String using ellipses. StringUtils.abbreviate("abcdefg", 6) = "abc..."
      Parameters:
        `str` - the String to abbreviate
        `maxWidth` - maximum length of result String, must be at least 4
      Returns:
        the abbreviated String
      Throws:
        `java.lang.IllegalArgumentException` - when the width is too small

    - #### isValidID

          public static boolean isValidID(java.lang.String string)

      Tests whether the given string is a valid JavaScript identifier.
      Parameters:
        `string` - the string to test.
      Returns:
        `true` if `string` is a valid JavaScript identifier; `false` otherwise.