Classes


Built-In Namespace String

Method Summary
Method Attributes Method Name and Description
 
Count the bytes in a UTF8 string
 
Decode a String from the application/x-www-form-urlencoded MIME format to plain text.
 
Replaces the angle brackets in "<?" and "?>" with entity references to prevent text from being re-interpreted as SJS
 
Makes a string safe for displaying on and HTML page by replacing certain characters in this order:
  • "&#" is replaced by "&#38;#"
  • "#" is replaced by "&#35;"
  • "<" is replaced by "&lt;"
  • ">" is replaced by "&gt;"
  • "(" is replaced by "&#40;"
  • ")" is replaced by "&#41;"
  • newlines are replaced by "<BR/>"
 
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
 
endsWith(substring)
Determine if the string ends with the passed substring.
 
Remove reserved JavaScript characters from the string.
 
Escapes the characters in a String using XML entities (&gt;, &lt;, &quot;, &amp;, &apos;).
 
format(args)
Format a String by replacing placeholders with arguments.
 
Convert HTML text to ASCII by eliminating markup, converting block level elements to new lines, and replacing HTML entities with the plain text character they represent.
 
Merges values passed as request parameters into the String
 
Convert a JSON string to a javascript object in a slightly more secure manner than simply calling eval().
 
startsWith(substring)
Determine if the string begins with the passed substring.
 
stripTags(allowedTags)
Remove all HTML tags except those specified in the allowedTags parameter
 
trim()
Remove leading and trailing whitespace from the String
Method Detail
{Integer} countBytes()
Count the bytes in a UTF8 string
Returns:
number of bytes

{String} decodeURL()
Decode a String from the application/x-www-form-urlencoded MIME format to plain text.

To conversion process is the reverse of that used by the URLEncoder class. It is assumed that all characters in the encoded string are one of the following: "a" through "z", "A" through "Z", "0" through "9", and "-", "_", ".", and "*". The character "%" is allowed but is interpreted as the start of a special escaped sequence.

The following rules are applied in the conversion:

<?
	var message =  "Salsa's%20API%20rocks!!".decodeURL();
	// message = "Salsa's API rocks!!"
?>
Returns:
The passed text decoded per the rules described above.
See:
String#encodeURL

{String} deSJS()
Replaces the angle brackets in "<?" and "?>" with entity references to prevent text from being re-interpreted as SJS
Returns:
A new String with SJS delimiters escaped.

deTag()
Makes a string safe for displaying on and HTML page by replacing certain characters in this order:

{String} encodeURL()
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
The implementation of this method includes the logic to determine whether the session ID needs to be encoded in the URL. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary.
For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
See:
Java Servlet API

{Boolean} endsWith(substring)
Determine if the string ends with the passed substring.
Parameters:
substring
Returns:
true if the current string's last n characters match the passed substring; false otherwise.

{String} escapeJS()
Remove reserved JavaScript characters from the string.
Returns:
A copy of the String with the characters removed.

{String} escapeXml()
Escapes the characters in a String using XML entities (&gt;, &lt;, &quot;, &amp;, &apos;). For example: "bread" & "butter" => &quot;bread&quot; &amp; &quot;butter&quot;.
Returns:
A new escaped String

{String} format(args)
Format a String by replacing placeholders with arguments.

The placeholders in the format string are marked by "%" and are followed by one or more of these elements, in this order:

  1. An optional "+" sign that forces to preceed the result with a plus or minus sign on numeric values. By default, only the "-" sign is used on negative numbers.
  2. An optional padding specifier that says what character to use for padding (if specified). Possible values are 0 or any other character precedeed by a '. The default is to pad with spaces.
  3. An optional "-" sign, that causes sprintf to left-align the result of this placeholder. The default is to right-align the result.
  4. An optional number, that says how many characters the result should have. If the value to be returned is shorter than this number, the result will be padded.
  5. An optional precision modifier, consisting of a "." (dot) followed by a number, that says how many digits should be displayed for floating point numbers. When used on a string, it causes the result to be truncated.
  6. A type specifier that can be any of:
    • % - print a literal "%" character
    • b - print an integer as a binary number
    • c - print an integer as the character with that ASCII value
    • d - print an integer as a signed decimal number
    • e - print a float as scientific notation
    • u - print an integer as an unsigned decimal number
    • f - print a float as is
    • o - print an integer as an octal number
    • s - print a string as is
    • x - print an integer as a hexadecimal number (lower-case)
    • X - print an integer as a hexadecimal number (upper-case)

Based on the sprintf project.

Parameters:
args
arg 1, arg 2, ... arg n The arguments to replace the placeholders in this String.
Throws:
An exception if not enough arguments were supplied, or if the arguments are of the wrong type (a String provided for %d for example)
Returns:
A String with the placeholders replaced by the argument
See:
printf For printing formatted strings

{String} HTML2Text()
Convert HTML text to ASCII by eliminating markup, converting block level elements to new lines, and replacing HTML entities with the plain text character they represent.
Returns:
{String} An approximation of the HTML content using only ASCII characters.

mergeFields()
Merges values passed as request parameters into the String

{Object} parseJSON()
Convert a JSON string to a javascript object in a slightly more secure manner than simply calling eval().
Returns:
{Object} The object represented by the JSON string.

{Boolean} startsWith(substring)
Determine if the string begins with the passed substring.
Parameters:
{String} substring
Returns:
true if the current string's first N characters match the passed substring, false otherwise.

{String} stripTags(allowedTags)
Remove all HTML tags except those specified in the allowedTags parameter
Parameters:
{String} allowedTags Optional
Comma separated list of tags to allow
Returns:
A new String with tags removed

{String} trim()
Remove leading and trailing whitespace from the String
Returns:
A copy of the String with the whitespace removed.

Documentation generated by JsDoc Toolkit 2.3.0 on Tue Jun 14 2011 05:41:52 GMT-0400 (EDT)