commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1145851 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
Date Wed, 13 Jul 2011 03:31:14 GMT
Author: bayard
Date: Wed Jul 13 03:31:14 2011
New Revision: 1145851

URL: http://svn.apache.org/viewvc?rev=1145851&view=rev
Log:
Removing the option around whether or not to support the + in \u+0000. JDK 7 now supports
the + sign, so UnicodeUnescaper will unescape \u0000 or \u+0000. 

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java?rev=1145851&r1=1145850&r2=1145851&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java
Wed Jul 13 03:31:14 2011
@@ -23,47 +23,14 @@ import java.util.EnumSet;
 
 /**
  * Translates escaped unicode values of the form \\u+\d\d\d\d back to 
- * unicode.
+ * unicode. It supports multiple 'u' characters and will work with or 
+ * without the +.
  * 
  * @since 3.0
  * @version $Id$
  */
 public class UnicodeUnescaper extends CharSequenceTranslator {
 
-    public static enum OPTION { escapePlus }
-
-    // TODO?: Create an OptionsSet class to hide some of the conditional logic below
-    private final EnumSet<OPTION> options;
-
-    /**
-     * Create a UnicodeUnescaper.
-     *
-     * The constructor takes a list of options, only one of which is currently 
-     * available (whether to expect a plus sign after the 'u'). 
-     *
-     * For example, to handle "\\u+0047":
-     *    new UnicodeUnescaper(UnicodeUnescaper.OPTION.escapePlus)
-     *
-     * @param options to apply to this unescaper
-     */
-    public UnicodeUnescaper(OPTION... options) {
-        if(options.length > 0) {
-            this.options = EnumSet.copyOf(Arrays.asList(options));
-        } else {
-            this.options = null;
-        }
-    }
-
-    /**
-     * Whether the passed in option is currently set.
-     *
-     * @param option to check state of
-     * @return whether the option is set
-     */
-    public boolean isSet(OPTION option) { 
-        return (options == null) ? false : options.contains(option);
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -77,11 +44,8 @@ public class UnicodeUnescaper extends Ch
                     i++;
                 }
 
-                // consume + symbol in \\u+0045
-                if(isSet(OPTION.escapePlus)) {
-                    if( (index + i < input.length()) && (input.charAt(index +
i) == '+') ) {
-                        i++;
-                    }
+                if( (index + i < input.length()) && (input.charAt(index + i) ==
'+') ) {
+                    i++;
                 }
 
                 if( (index + i + 4 <= input.length()) ) {

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java?rev=1145851&r1=1145850&r2=1145851&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java
Wed Jul 13 03:31:14 2011
@@ -30,14 +30,6 @@ public class UnicodeUnescaperTest extend
         UnicodeUnescaper uu = new UnicodeUnescaper();
 
         String input = "\\u+0047";
-        try {
-            uu.translate(input);
-            fail("Default behaviour should not parse u+");
-        } catch(IllegalArgumentException iae) {
-            // expected
-        }
-
-        uu = new UnicodeUnescaper(UnicodeUnescaper.OPTION.escapePlus);
         assertEquals("Failed to unescape unicode characters with 'u+' notation", "G", uu.translate(input));
     }
 



Mime
View raw message