diff --git a/src/java/org/apache/commons/collections/ExtendedProperties.java b/src/java/org/apache/commons/collections/ExtendedProperties.java index 3b2e5ff0b..5e85187af 100644 --- a/src/java/org/apache/commons/collections/ExtendedProperties.java +++ b/src/java/org/apache/commons/collections/ExtendedProperties.java @@ -238,7 +238,7 @@ public class ExtendedProperties extends Hashtable { int end = -1; int prec = 0 - END_TOKEN.length(); String variable = null; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); // FIXME: we should probably allow the escaping of the start token while (((begin = base.indexOf(START_TOKEN, prec + END_TOKEN.length())) > -1) @@ -250,7 +250,7 @@ public class ExtendedProperties extends Hashtable { if (priorVariables.contains(variable)) { String initialBase = priorVariables.remove(0).toString(); priorVariables.add(variable); - StringBuffer priorVariableSb = new StringBuffer(); + StringBuilder priorVariableSb = new StringBuilder(); // create a nice trace of interpolated variables like so: // var1->var2->var3 @@ -296,7 +296,7 @@ public class ExtendedProperties extends Hashtable { * Inserts a backslash before every comma and backslash. */ private static String escape(String s) { - StringBuffer buf = new StringBuffer(s); + StringBuilder buf = new StringBuilder(s); for (int i = 0; i < buf.length(); i++) { char c = buf.charAt(i); if (c == ',' || c == '\\') { @@ -311,7 +311,7 @@ public class ExtendedProperties extends Hashtable { * Removes a backslash from every pair of backslashes. */ private static String unescape(String s) { - StringBuffer buf = new StringBuffer(s); + StringBuilder buf = new StringBuilder(s); for (int i = 0; i < buf.length() - 1; i++) { char c1 = buf.charAt(i); char c2 = buf.charAt(i + 1); @@ -369,7 +369,7 @@ public class ExtendedProperties extends Hashtable { * @throws IOException if there is difficulty reading the source. */ public String readProperty() throws IOException { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); String line = readLine(); while (line != null) { line = line.trim(); @@ -423,7 +423,7 @@ public class ExtendedProperties extends Hashtable { * @return A String. */ public String nextToken() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); while (hasMoreTokens()) { String token = super.nextToken(); @@ -757,7 +757,7 @@ public class ExtendedProperties extends Hashtable { Object value = get(key); if (value != null) { if (value instanceof String) { - StringBuffer currentOutput = new StringBuffer(); + StringBuilder currentOutput = new StringBuilder(); currentOutput.append(key); currentOutput.append("="); currentOutput.append(escape((String) value)); @@ -767,7 +767,7 @@ public class ExtendedProperties extends Hashtable { List values = (List) value; for (Iterator it = values.iterator(); it.hasNext(); ) { String currentElement = (String) it.next(); - StringBuffer currentOutput = new StringBuffer(); + StringBuilder currentOutput = new StringBuilder(); currentOutput.append(key); currentOutput.append("="); currentOutput.append(escape(currentElement)); diff --git a/src/java/org/apache/commons/collections/bag/AbstractMapBag.java b/src/java/org/apache/commons/collections/bag/AbstractMapBag.java index 6cb471424..aa7e13e3d 100644 --- a/src/java/org/apache/commons/collections/bag/AbstractMapBag.java +++ b/src/java/org/apache/commons/collections/bag/AbstractMapBag.java @@ -579,7 +579,7 @@ public abstract class AbstractMapBag implements Bag { if (size() == 0) { return "[]"; } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append('['); Iterator it = uniqueSet().iterator(); while (it.hasNext()) { diff --git a/src/java/org/apache/commons/collections/bidimap/TreeBidiMap.java b/src/java/org/apache/commons/collections/bidimap/TreeBidiMap.java index 390d1a7c3..e1aa8ef0e 100644 --- a/src/java/org/apache/commons/collections/bidimap/TreeBidiMap.java +++ b/src/java/org/apache/commons/collections/bidimap/TreeBidiMap.java @@ -1372,7 +1372,7 @@ public class TreeBidiMap, V extends Comparable> imple if (nodeCount == 0) { return "{}"; } - StringBuffer buf = new StringBuffer(nodeCount * 32); + StringBuilder buf = new StringBuilder(nodeCount * 32); buf.append('{'); MapIterator it = getMapIterator(dataElement); boolean hasNext = it.hasNext(); diff --git a/src/java/org/apache/commons/collections/buffer/PriorityBuffer.java b/src/java/org/apache/commons/collections/buffer/PriorityBuffer.java index 66d66d022..b9b15a01f 100644 --- a/src/java/org/apache/commons/collections/buffer/PriorityBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/PriorityBuffer.java @@ -527,7 +527,7 @@ public class PriorityBuffer extends AbstractCollection implements Buffer implements KeyValue { * @return a String view of the entry */ public String toString() { - return new StringBuffer() + return new StringBuilder() .append(getKey()) .append('=') .append(getValue()) diff --git a/src/java/org/apache/commons/collections/list/AbstractLinkedList.java b/src/java/org/apache/commons/collections/list/AbstractLinkedList.java index 738871e86..9cbe6c77c 100644 --- a/src/java/org/apache/commons/collections/list/AbstractLinkedList.java +++ b/src/java/org/apache/commons/collections/list/AbstractLinkedList.java @@ -360,7 +360,7 @@ public abstract class AbstractLinkedList implements List { if (size() == 0) { return "[]"; } - StringBuffer buf = new StringBuffer(16 * size()); + StringBuilder buf = new StringBuilder(16 * size()); buf.append("["); Iterator it = iterator(); diff --git a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java index fd646ad47..5a27bef9e 100644 --- a/src/java/org/apache/commons/collections/map/AbstractHashedMap.java +++ b/src/java/org/apache/commons/collections/map/AbstractHashedMap.java @@ -1095,7 +1095,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab } public String toString() { - return new StringBuffer().append(getKey()).append('=').append(getValue()).toString(); + return new StringBuilder().append(getKey()).append('=').append(getValue()).toString(); } } @@ -1331,7 +1331,7 @@ public class AbstractHashedMap extends AbstractMap implements Iterab if (size() == 0) { return "{}"; } - StringBuffer buf = new StringBuffer(32 * size()); + StringBuilder buf = new StringBuilder(32 * size()); buf.append('{'); MapIterator it = mapIterator(); diff --git a/src/java/org/apache/commons/collections/map/Flat3Map.java b/src/java/org/apache/commons/collections/map/Flat3Map.java index e13a13039..4cd567739 100644 --- a/src/java/org/apache/commons/collections/map/Flat3Map.java +++ b/src/java/org/apache/commons/collections/map/Flat3Map.java @@ -1128,7 +1128,7 @@ public class Flat3Map implements IterableMap, Serializable, Cloneabl if (size == 0) { return "{}"; } - StringBuffer buf = new StringBuffer(128); + StringBuilder buf = new StringBuilder(128); buf.append('{'); switch (size) { // drop through case 3: diff --git a/src/java/org/apache/commons/collections/map/ListOrderedMap.java b/src/java/org/apache/commons/collections/map/ListOrderedMap.java index 327f04778..4b1fd12c8 100644 --- a/src/java/org/apache/commons/collections/map/ListOrderedMap.java +++ b/src/java/org/apache/commons/collections/map/ListOrderedMap.java @@ -321,7 +321,7 @@ public class ListOrderedMap if (isEmpty()) { return "{}"; } - StringBuffer buf = new StringBuffer(); + StringBuilder buf = new StringBuilder(); buf.append('{'); boolean first = true; for (Map.Entry entry : entrySet()) { diff --git a/src/java/org/apache/commons/collections/map/SingletonMap.java b/src/java/org/apache/commons/collections/map/SingletonMap.java index 4c670cfbf..ce31472c0 100644 --- a/src/java/org/apache/commons/collections/map/SingletonMap.java +++ b/src/java/org/apache/commons/collections/map/SingletonMap.java @@ -557,7 +557,7 @@ public class SingletonMap * @return a string version of the map */ public String toString() { - return new StringBuffer(128) + return new StringBuilder(128) .append('{') .append((getKey() == this ? "(this Map)" : getKey())) .append('=') diff --git a/src/test/org/apache/commons/collections/AbstractTestObject.java b/src/test/org/apache/commons/collections/AbstractTestObject.java index b6128079e..72ae1d72e 100644 --- a/src/test/org/apache/commons/collections/AbstractTestObject.java +++ b/src/test/org/apache/commons/collections/AbstractTestObject.java @@ -232,7 +232,7 @@ public abstract class AbstractTestObject extends BulkTest { } protected String getCanonicalEmptyCollectionName(Object object) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); retval.append("data/test/"); String colName = object.getClass().getName(); colName = colName.substring(colName.lastIndexOf(".") + 1, colName.length()); @@ -244,7 +244,7 @@ public abstract class AbstractTestObject extends BulkTest { } protected String getCanonicalFullCollectionName(Object object) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); retval.append("data/test/"); String colName = object.getClass().getName(); colName = colName.substring(colName.lastIndexOf(".") + 1, colName.length()); diff --git a/src/test/org/apache/commons/collections/TestClosureUtils.java b/src/test/org/apache/commons/collections/TestClosureUtils.java index f0d1ab190..4df9bf505 100644 --- a/src/test/org/apache/commons/collections/TestClosureUtils.java +++ b/src/test/org/apache/commons/collections/TestClosureUtils.java @@ -121,7 +121,7 @@ public class TestClosureUtils extends junit.framework.TestCase { //------------------------------------------------------------------ public void testNopClosure() { - StringBuffer buf = new StringBuffer("Hello"); + StringBuilder buf = new StringBuilder("Hello"); ClosureUtils.nopClosure().execute(null); assertEquals("Hello", buf.toString()); ClosureUtils.nopClosure().execute("Hello"); @@ -132,10 +132,10 @@ public class TestClosureUtils extends junit.framework.TestCase { //------------------------------------------------------------------ public void testInvokeClosure() { - StringBuffer buf = new StringBuffer("Hello"); + StringBuilder buf = new StringBuilder("Hello"); ClosureUtils.invokerClosure("reverse").execute(buf); assertEquals("olleH", buf.toString()); - buf = new StringBuffer("Hello"); + buf = new StringBuilder("Hello"); ClosureUtils.invokerClosure("setLength", new Class[] {Integer.TYPE}, new Object[] {new Integer(2)}).execute(buf); assertEquals("He", buf.toString()); } diff --git a/src/test/org/apache/commons/collections/buffer/TestPriorityBuffer.java b/src/test/org/apache/commons/collections/buffer/TestPriorityBuffer.java index cff46a864..c7d71acd8 100644 --- a/src/test/org/apache/commons/collections/buffer/TestPriorityBuffer.java +++ b/src/test/org/apache/commons/collections/buffer/TestPriorityBuffer.java @@ -332,7 +332,7 @@ public class TestPriorityBuffer extends AbstractTestCollection { */ protected String showTree(PriorityBuffer h) { int count = 1; - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); for (int offset = 1; count < h.size() + 1; offset *= 2) { for (int i = offset; i < offset * 2; i++) { if (i < h.elements.length && h.elements[i] != null) diff --git a/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java b/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java index 2d825c9d1..c03568fa0 100644 --- a/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java +++ b/src/test/org/apache/commons/collections/comparators/AbstractTestComparator.java @@ -169,7 +169,7 @@ public abstract class AbstractTestComparator extends AbstractTestObject { } public String getCanonicalComparatorName(Object object) { - StringBuffer retval = new StringBuffer(); + StringBuilder retval = new StringBuilder(); retval.append("data/test/"); String colName = object.getClass().getName(); colName = colName.substring(colName.lastIndexOf(".")+1,colName.length()); diff --git a/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java b/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java index 1be2041e0..89cb9e395 100644 --- a/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java +++ b/src/test/org/apache/commons/collections/comparators/TestComparatorChain.java @@ -144,7 +144,7 @@ public class TestComparatorChain extends AbstractTestComparator