|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.gadgets.dashboard.internal.util.JavaScript
public class JavaScript
Escaping that was ripped from Apache Commons-Lang StringUtils class, modified to escape the '<' character as a unicode string as described in AG-1005.
Constructor Summary | |
---|---|
JavaScript()
|
Method Summary | |
---|---|
static String |
escape(String str)
Escapes the characters in a String using JavaScript String
rules. |
static void |
escape(Writer out,
String str)
Escapes the characters in a String using JavaScript String
rules to a Writer . |
static String |
hex(char ch)
Returns an upper case hexadecimal String for the given
character. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JavaScript()
Method Detail |
---|
public static String escape(String str)
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 void escape(Writer out, String str) throws IOException
Escapes the characters in a String
using JavaScript String
rules to a Writer
.
A null
string input has no effect.
out
- Writer to write escaped string intostr
- String to escape values in, may be null
IllegalArgumentException
- if the Writer is null
IOException
- if error occurs on underlying Writer#escapeJavaScript(java.lang.String)
public static String hex(char ch)
Returns an upper case hexadecimal String
for the given
character.
ch
- The character to convert.
String
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |