|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.directwebremoting.util.JavascriptUtil
public class JavascriptUtil
Various Javascript code utilities. The escape classes were taken from jakarta-commons-lang which in turn borrowed from Turbine and other projects. The list of authors below is almost certainly far too long, but I'm not sure who really wrote these methods.
| Constructor Summary | |
|---|---|
JavascriptUtil()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
escapeJavaScript(java.lang.String str)
|
static java.lang.String |
escapeJavaScript(java.lang.String str,
boolean escapeSingleQuote)
Escapes the characters in a String using JavaScript String rules. |
static boolean |
isReservedWord(java.lang.String name)
Check to see if the given word is reserved or a bad idea in any known version of JavaScript. |
static java.lang.String |
unescapeJavaScript(java.lang.String str)
Unescapes any JavaScript literals found in the String. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JavascriptUtil()
| Method Detail |
|---|
public static java.lang.String escapeJavaScript(java.lang.String str)
public static java.lang.String escapeJavaScript(java.lang.String str,
boolean escapeSingleQuote)
Escapes the characters in a String using JavaScript String rules.
Escapes any values it finds into their JavaScript String form. Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters '\\' and
't'.
The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.
Example:
input string: He didn't say, "Stop!" output string: He didn\'t say, \"Stop!\"
str - String to escape values in, may be null
null if null string inputpublic static java.lang.String unescapeJavaScript(java.lang.String str)
Unescapes any JavaScript literals found in the String.
For example, it will turn a sequence of '\' and 'n'
into a newline character, unless the '\' is preceded by another
'\'.
str - the String to unescape, may be null
String, null if null string inputpublic static boolean isReservedWord(java.lang.String name)
name - The word to check
|
Copyright ยจ 2008 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||