commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r826958 - in /commons/proper/lang/trunk/src/java/org/apache/commons/lang: ./ exception/ math/
Date Tue, 20 Oct 2009 05:35:47 GMT
Author: bayard
Date: Tue Oct 20 05:35:46 2009
New Revision: 826958

URL: http://svn.apache.org/viewvc?rev=826958&view=rev
Log:
Switched StringBuffer to StringBuilder whenever a local usage (and not subsequently used in
an API) as per LANG-541

Modified:
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java
    commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharRange.java Tue Oct 20 05:35:46
2009
@@ -215,7 +215,7 @@
     @Override
     public String toString() {
         if (iToString == null) {
-            StringBuffer buf = new StringBuffer(4);
+            StringBuilder buf = new StringBuilder(4);
             if (isNegated()) {
                 buf.append('^');
             }

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java Tue Oct 20
05:35:46 2009
@@ -91,7 +91,7 @@
             return str;
         }
         CharSet chars = CharSet.getInstance(set);
-        StringBuffer buffer = new StringBuffer(str.length());
+        StringBuilder buffer = new StringBuilder(str.length());
         char[] chrs = str.toCharArray();
         int sz = chrs.length;
         char lastChar = ' ';
@@ -289,7 +289,7 @@
      */
     private static String modify(String str, String[] set, boolean expect) {
         CharSet chars = CharSet.getInstance(set);
-        StringBuffer buffer = new StringBuffer(str.length());
+        StringBuilder buffer = new StringBuilder(str.length());
         char[] chrs = str.toCharArray();
         int sz = chrs.length;
         for(int i=0; i<sz; i++) {

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/ClassUtils.java Tue Oct 20
05:35:46 2009
@@ -188,7 +188,7 @@
             return StringUtils.EMPTY;
         }
 
-        StringBuffer arrayPrefix = new StringBuffer();
+        StringBuilder arrayPrefix = new StringBuilder();
 
         // Handle array encoding
         if (className.startsWith("[")) {
@@ -859,7 +859,7 @@
         if (className == null) {
             throw new NullPointerException("className must not be null.");
         } else if (className.endsWith("[]")) {
-            StringBuffer classNameBuffer = new StringBuffer();
+            StringBuilder classNameBuffer = new StringBuilder();
             while (className.endsWith("[]")) {
                 className = className.substring(0, className.length() - 2);
                 classNameBuffer.append("[");
@@ -1026,7 +1026,7 @@
                         className = reverseAbbreviationMap.get(className.substring(0, 1));
                     }
                 }
-                StringBuffer canonicalClassNameBuffer = new StringBuffer(className);
+                StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
                 for (int i = 0; i < dim; i++) {
                     canonicalClassNameBuffer.append("[]");
                 }

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java Tue Oct 20
05:35:46 2009
@@ -2809,7 +2809,7 @@
         }
 
         bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length())
+ 1);
-        StringBuffer buf = new StringBuffer(bufSize);
+        StringBuilder buf = new StringBuilder(bufSize);
 
         for (int i = startIndex; i < endIndex; i++) {
             if (i > startIndex) {
@@ -2898,7 +2898,7 @@
         bufSize *= ((array[startIndex] == null ? 16 : array[startIndex].toString().length())
                         + separator.length());
 
-        StringBuffer buf = new StringBuffer(bufSize);
+        StringBuilder buf = new StringBuilder(bufSize);
 
         for (int i = startIndex; i < endIndex; i++) {
             if (i > startIndex) {
@@ -2940,7 +2940,7 @@
         }
 
         // two or more elements
-        StringBuffer buf = new StringBuffer(256); // Java default is 16, probably too small
+        StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
         if (first != null) {
             buf.append(first);
         }
@@ -2984,7 +2984,7 @@
         }
 
         // two or more elements
-        StringBuffer buf = new StringBuffer(256); // Java default is 16, probably too small
+        StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
         if (first != null) {
             buf.append(first);
         }
@@ -3376,7 +3376,7 @@
         int increase = replacement.length() - replLength;
         increase = (increase < 0 ? 0 : increase);
         increase *= (max < 0 ? 16 : (max > 64 ? 64 : max));
-        StringBuffer buf = new StringBuffer(text.length() + increase);
+        StringBuilder buf = new StringBuilder(text.length() + increase);
         while (end != -1) {
             buf.append(text.substring(start, end)).append(replacement);
             start = end + replLength;
@@ -3611,7 +3611,7 @@
         // have upper-bound at 20% increase, then let Java take over
         increase = Math.min(increase, text.length() / 5);
 
-        StringBuffer buf = new StringBuffer(text.length() + increase);
+        StringBuilder buf = new StringBuilder(text.length() + increase);
 
         while (textIndex != -1) {
 
@@ -3735,7 +3735,7 @@
         boolean modified = false;
         int replaceCharsLength = replaceChars.length();
         int strLength = str.length();
-        StringBuffer buf = new StringBuffer(strLength);
+        StringBuilder buf = new StringBuilder(strLength);
         for (int i = 0; i < strLength; i++) {
             char ch = str.charAt(i);
             int index = searchChars.indexOf(ch);
@@ -3810,7 +3810,7 @@
             start = end;
             end = temp;
         }
-        return new StringBuffer(len + start - end + overlay.length() + 1)
+        return new StringBuilder(len + start - end + overlay.length() + 1)
             .append(str.substring(0, start))
             .append(overlay)
             .append(str.substring(end))
@@ -4009,7 +4009,7 @@
                 }
                 return new String(output2);
             default :
-                StringBuffer buf = new StringBuffer(outputLength);
+                StringBuilder buf = new StringBuilder(outputLength);
                 for (int i = 0; i < repeat; i++) {
                     buf.append(str);
                 }
@@ -4551,7 +4551,7 @@
         if (str == null || (strLen = str.length()) == 0) {
             return str;
         }
-        return new StringBuffer(strLen)
+        return new StringBuilder(strLen)
             .append(Character.toTitleCase(str.charAt(0)))
             .append(str.substring(1))
             .toString();
@@ -4582,7 +4582,7 @@
         if (str == null || (strLen = str.length()) == 0) {
             return str;
         }
-        return new StringBuffer(strLen)
+        return new StringBuilder(strLen)
             .append(Character.toLowerCase(str.charAt(0)))
             .append(str.substring(1))
             .toString();
@@ -4620,7 +4620,7 @@
         if (str == null || (strLen = str.length()) == 0) {
             return str;
         }
-        StringBuffer buffer = new StringBuffer(strLen);
+        StringBuilder buffer = new StringBuilder(strLen);
 
         char ch = 0;
         for (int i = 0; i < strLen; i++) {
@@ -5072,7 +5072,7 @@
     // Reversing
     //-----------------------------------------------------------------------
     /**
-     * <p>Reverses a String as per {@link StringBuffer#reverse()}.</p>
+     * <p>Reverses a String as per {@link StringBuilder#reverse()}.</p>
      *
      * <p>A <code>null</code> String returns <code>null</code>.</p>
      *
@@ -5089,7 +5089,7 @@
         if (str == null) {
             return null;
         }
-        return new StringBuffer(str).reverse().toString();
+        return new StringBuilder(str).reverse().toString();
     }
 
     /**

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/WordUtils.java Tue Oct 20 05:35:46
2009
@@ -172,7 +172,7 @@
         }
         int inputLineLength = str.length();
         int offset = 0;
-        StringBuffer wrappedLine = new StringBuffer(inputLineLength + 32);
+        StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
         
         while ((inputLineLength - offset) > wrapLength) {
             if (str.charAt(offset) == ' ') {
@@ -278,7 +278,7 @@
             return str;
         }
         int strLen = str.length();
-        StringBuffer buffer = new StringBuffer(strLen);
+        StringBuilder buffer = new StringBuilder(strLen);
         boolean capitalizeNext = true;
         for (int i = 0; i < strLen; i++) {
             char ch = str.charAt(i);
@@ -408,7 +408,7 @@
             return str;
         }
         int strLen = str.length();
-        StringBuffer buffer = new StringBuffer(strLen);
+        StringBuilder buffer = new StringBuilder(strLen);
         boolean uncapitalizeNext = true;
         for (int i = 0; i < strLen; i++) {
             char ch = str.charAt(i);
@@ -454,7 +454,7 @@
         if (str == null || (strLen = str.length()) == 0) {
             return str;
         }
-        StringBuffer buffer = new StringBuffer(strLen);
+        StringBuilder buffer = new StringBuilder(strLen);
 
         boolean whitespace = true;
         char ch = 0;
@@ -626,7 +626,7 @@
             upper = lower;
         }
 
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         int index = StringUtils.indexOf(str, " ", lower);
         if (index == -1) {
             result.append(str.substring(0, upper));

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/exception/DefaultExceptionContext.java
Tue Oct 20 05:35:46 2009
@@ -87,7 +87,7 @@
      * @since 3.0
      */
     public String getFormattedExceptionMessage(String baseMessage){
-        StringBuffer buffer = new StringBuffer(256);
+        StringBuilder buffer = new StringBuilder(256);
         if (baseMessage != null) {
             buffer.append(baseMessage);
         }
@@ -127,4 +127,4 @@
         return buffer.toString();
     }
     
-}
\ No newline at end of file
+}

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/DoubleRange.java Tue Oct
20 05:35:46 2009
@@ -421,7 +421,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            StringBuffer buf = new StringBuffer(32);
+            StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(min);
             buf.append(',');

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/FloatRange.java Tue Oct
20 05:35:46 2009
@@ -415,7 +415,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            StringBuffer buf = new StringBuffer(32);
+            StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(min);
             buf.append(',');

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Fraction.java Tue Oct
20 05:35:46 2009
@@ -902,7 +902,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            toString = new StringBuffer(32)
+            toString = new StringBuilder(32)
                 .append(getNumerator())
                 .append('/')
                 .append(getDenominator()).toString();
@@ -936,13 +936,13 @@
                 if (properNumerator == 0) {
                     toProperString = Integer.toString(getProperWhole());
                 } else {
-                    toProperString = new StringBuffer(32)
+                    toProperString = new StringBuilder(32)
                         .append(getProperWhole()).append(' ')
                         .append(properNumerator).append('/')
                         .append(getDenominator()).toString();
                 }
             } else {
-                toProperString = new StringBuffer(32)
+                toProperString = new StringBuilder(32)
                     .append(getNumerator()).append('/')
                     .append(getDenominator()).toString();
             }

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/IntRange.java Tue Oct
20 05:35:46 2009
@@ -389,7 +389,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            StringBuffer buf = new StringBuffer(32);
+            StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(min);
             buf.append(',');

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/LongRange.java Tue Oct
20 05:35:46 2009
@@ -402,7 +402,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            StringBuffer buf = new StringBuffer(32);
+            StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(min);
             buf.append(',');

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberRange.java Tue Oct
20 05:35:46 2009
@@ -236,7 +236,7 @@
     @Override
     public String toString() {
         if (toString == null) {
-            StringBuffer buf = new StringBuffer(32);
+            StringBuilder buf = new StringBuilder(32);
             buf.append("Range[");
             buf.append(min);
             buf.append(',');

Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java?rev=826958&r1=826957&r2=826958&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java (original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/Range.java Tue Oct 20
05:35:46 2009
@@ -422,7 +422,7 @@
      */
     @Override
     public String toString() {
-        StringBuffer buf = new StringBuffer(32);
+        StringBuilder buf = new StringBuilder(32);
         buf.append("Range[");
         buf.append(getMinimumNumber());
         buf.append(',');



Mime
View raw message