public final class KarafStringEscapeUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
escapeJava(String str)
Escapes the characters in a
String using Java String rules. |
static String |
hex(char ch)
Returns an upper case hexadecimal
String for the given
character. |
static String |
unescapeJava(String str)
Unescapes any Java literals found in the
String to a
Writer . |
public static String unescapeJava(String str)
Unescapes any Java literals found in the String
to a
Writer
.
str
- the String
to unescape, may be nullIllegalArgumentException
- if the Writer is null
public static String escapeJava(String str)
Escapes the characters in a String
using Java String rules.
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 nullnull
if null string inputpublic static String hex(char ch)
Returns an upper case hexadecimal String
for the given
character.
ch
- The character to convert.String
Apache Camel