commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1153229 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/CharUtils.java site/changes/changes.xml
Date Tue, 02 Aug 2011 18:04:52 GMT
Author: ggregory
Date: Tue Aug  2 18:04:51 2011
New Revision: 1153229

URL: http://svn.apache.org/viewvc?rev=1153229&view=rev
Log:
[LANG-734] The CHAR_ARRAY cache in CharUtils duplicates the cache in java.lang.Character.
[LANG-735] Deprecate CharUtils.toCharacterObject(char) in favor of java.lang.Character.valueOf(char).

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharUtils.java
    commons/proper/lang/trunk/src/site/changes/changes.xml

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharUtils.java?rev=1153229&r1=1153228&r2=1153229&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/CharUtils.java Tue Aug
 2 18:04:51 2011
@@ -48,7 +48,6 @@ public class CharUtils {
         "\u0078\u0079\u007a\u007b\u007c\u007d\u007e\u007f";
     
     private static final String[] CHAR_STRING_ARRAY = new String[128];
-    private static final Character[] CHAR_ARRAY = new Character[128];
     
     /**
      * {@code \u000a} linefeed LF ('\n').
@@ -72,7 +71,6 @@ public class CharUtils {
     static {
         for (int i = 127; i >= 0; i--) {
             CHAR_STRING_ARRAY[i] = CHAR_STRING.substring(i, i + 1);
-            CHAR_ARRAY[i] = new Character((char) i);
         }
     }
 
@@ -99,14 +97,13 @@ public class CharUtils {
      *   CharUtils.toCharacterObject('A')  = 'A'
      * </pre>
      *
+     * @deprecated Java 5 introduced {@link Character#valueOf(char)} which caches chars 0
through 127.
      * @param ch  the character to convert
      * @return a Character of the specified character
      */
+    @Deprecated
     public static Character toCharacterObject(char ch) {
-        if (ch < CHAR_ARRAY.length) {
-            return CHAR_ARRAY[ch];
-        }
-        return new Character(ch);
+        return Character.valueOf(ch);
     }
     
     /**
@@ -130,7 +127,7 @@ public class CharUtils {
         if (StringUtils.isEmpty(str)) {
             return null;
         }
-        return toCharacterObject(str.charAt(0));
+        return Character.valueOf(str.charAt(0));
     }
     
     //-----------------------------------------------------------------------

Modified: commons/proper/lang/trunk/src/site/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/site/changes/changes.xml?rev=1153229&r1=1153228&r2=1153229&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/site/changes/changes.xml (original)
+++ commons/proper/lang/trunk/src/site/changes/changes.xml Tue Aug  2 18:04:51 2011
@@ -33,6 +33,8 @@
     <action type="add" issue="LANG-723">Add mode and median Comparable... methods to
ObjectUtils</action>
     <action type="add" issue="LANG-722">Add BooleanUtils.and + or varargs methods</action>
     <action type="add" issue="LANG-730">EnumSet -&gt; bit vector</action>
+    <action type="fix" issue="LANG-734">The CHAR_ARRAY cache in CharUtils duplicates
the cache in java.lang.Character</action>
+    <action type="update" issue="LANG-735">Deprecate CharUtils.toCharacterObject(char)
in favor of java.lang.Character.valueOf(char)</action>
   </release>
 
   <release version="3.0" date="2011-07-18" description="Backwards incompatible update
of Commons Lang to Java 5">  



Mime
View raw message