incubator-ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1170532 - /incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java
Date Wed, 14 Sep 2011 11:16:35 GMT
Author: marrs
Date: Wed Sep 14 11:16:34 2011
New Revision: 1170532

URL: http://svn.apache.org/viewvc?rev=1170532&view=rev
Log:
Extended the codec to explicitly handle null strings.

Modified:
    incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java

Modified: incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java?rev=1170532&r1=1170531&r2=1170532&view=diff
==============================================================================
--- incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java (original)
+++ incubator/ace/trunk/ace-util/src/main/java/org/apache/ace/util/Codec.java Wed Sep 14 11:16:34
2011
@@ -43,6 +43,9 @@ public class Codec
                     else if (c == 'r') {
                         result.append('\r');
                     }
+                    else if (c == 'e') {
+                        return null;
+                    }
                     else {
                         throw new IllegalArgumentException("Unknown escape character: " +
c);
                     }
@@ -59,6 +62,9 @@ public class Codec
     }
 
     public static String encode(String source) {
+        if (source == null) {
+            return "$e";
+        }
         StringBuffer result = new StringBuffer();
         StringCharacterIterator sci = new StringCharacterIterator(source);
         for (char c = sci.current(); c != CharacterIterator.DONE; c = sci.next()) {



Mime
View raw message