commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r795596 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate: EntityArrays.java EscapeUtils.java UnescapeUtils.java
Date Sun, 19 Jul 2009 19:15:14 GMT
Author: bayard
Date: Sun Jul 19 19:15:14 2009
New Revision: 795596

URL: http://svn.apache.org/viewvc?rev=795596&view=rev
Log:
Refactoring the array of Java ctrl characters to be in EntityArray rather than embedded in
their own escape/unescape

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java?rev=795596&r1=795595&r2=795596&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EntityArrays.java
Sun Jul 19 19:15:14 2009
@@ -349,6 +349,18 @@
     public static String[][] APOS_UNESCAPE() { return APOS_UNESCAPE.clone(); }
     private static final String[][] APOS_UNESCAPE = invert(APOS_ESCAPE);
 
+    public static String[][] JAVA_CTRL_CHARS_ESCAPE() { return JAVA_CTRL_CHARS_ESCAPE.clone();
}
+    private static final String[][] JAVA_CTRL_CHARS_ESCAPE = {
+        {"\b", "\\b"},
+        {"\n", "\\n"},
+        {"\t", "\\t"},
+        {"\f", "\\f"},
+        {"\r", "\\r"}
+    };
+
+    public static String[][] JAVA_CTRL_CHARS_UNESCAPE() { return JAVA_CTRL_CHARS_UNESCAPE.clone();
}
+    private static final String[][] JAVA_CTRL_CHARS_UNESCAPE = invert(JAVA_CTRL_CHARS_ESCAPE);
+
     /**
      * Used to invert an escape array into an unescape array
      * @param array String[][] to be inverted

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java?rev=795596&r1=795595&r2=795596&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/EscapeUtils.java
Sun Jul 19 19:15:14 2009
@@ -29,23 +29,13 @@
  */
 public class EscapeUtils {
 
-    public static final CharSequenceTranslator ESCAPE_JAVA_CTRL_CHARS = 
-          new LookupTranslator(
-            new String[][] {
-              {"\b", "\\b"},
-              {"\n", "\\n"},
-              {"\t", "\\t"},
-              {"\f", "\\f"},
-              {"\r", "\\r"}
-            });
-
     public static final CharSequenceTranslator ESCAPE_JAVA = 
           new LookupTranslator(
             new String[][] { 
               {"\"", "\\\""},
               {"\\", "\\\\"},
           }).with(
-            ESCAPE_JAVA_CTRL_CHARS
+            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE())
           ).with(
             UnicodeEscaper.outsideOf(32, 0x7f) 
         );
@@ -63,7 +53,7 @@
                             {"\\", "\\\\"},
                             {"/", "\\/"}
                       }),
-            ESCAPE_JAVA_CTRL_CHARS,
+            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()),
             UnicodeEscaper.outsideOf(32, 0x7f) 
         );
             

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java?rev=795596&r1=795595&r2=795596&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/translate/UnescapeUtils.java
Sun Jul 19 19:15:14 2009
@@ -29,21 +29,11 @@
  */
 public class UnescapeUtils {
 
-    public static final CharSequenceTranslator UNESCAPE_JAVA_CTRL_CHARS = 
-            new LookupTranslator(
-                      new String[][] { 
-                            {"\\b", "\b"},
-                            {"\\n", "\n"},
-                            {"\\t", "\t"},
-                            {"\\f", "\f"},
-                            {"\\r", "\r"}
-                      });
-
     // throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per
the compiler)?
     public static final CharSequenceTranslator UNESCAPE_JAVA = 
         new AggregateTranslator(
             new UnicodeUnescaper(),
-            UNESCAPE_JAVA_CTRL_CHARS,
+            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_UNESCAPE()),
             new LookupTranslator(
                       new String[][] { 
                             {"\\\\", "\\"},



Mime
View raw message