Updating ESCAPE_JAVA to use the new .with() approach and to fold the two unicode escape methods into one.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@788245 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-06-25 03:55:18 +00:00
parent b9ab7659bc
commit cec3b9ff20
1 changed files with 15 additions and 9 deletions

View File

@ -30,15 +30,21 @@
public class EscapeUtils {
public static final CharSequenceTranslator ESCAPE_JAVA =
new AggregateTranslator(
new LookupTranslator(
new String[][] {
{"\"", "\\\""},
{"\\", "\\\\"}
}),
new EscapeLowAsciiAsUnicode(),
new EscapeNonAsciiAsUnicode()
);
new LookupTranslator(
new String[][] {
{"\"", "\\\""},
{"\\", "\\\\"},
}).with(
new LookupTranslator(
new String[][] {
{"\b", "\\b"},
{"\n", "\\n"},
{"\t", "\\t"},
{"\f", "\\f"},
{"\r", "\\r"}
}).with(
UnicodeEscaper.outsideOf(32, 0x7f)
));
public static final String escapeJava(String input) {
return ESCAPE_JAVA.translate(input);