/*
 * Copyright 2001-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

package org.apache.jmeter.util;

/**
 * @version $Revision$
 */
public final class StringUtilities {
	public static String substitute(String input, String pattern, String sub) {
		StringBuffer ret = new StringBuffer();
		int start = 0;
		int index = -1;
		while ((index = input.indexOf(pattern, start)) >= start) {
			ret.append(input.substring(start, index));
			ret.append(sub);
			start = index + pattern.length();
		}
		ret.append(input.substring(start));
		return ret.toString();
	}

	/**
	 * Private constructor to prevent instantiation.
	 */
	private StringUtilities() {
	}

}

@@ -716,16 +716,416 @@
 lities %7B
+%0A%0A    /**%0A     * Private constructor to prevent instantiation.%0A     */%0A    private StringUtilities() %7B%0A    %7D%0A%0A    /**%0A     * Replace all patterns in a String%0A     * %0A     * @see String.replaceAll(regex,replacement) - JDK1.4 only%0A     * %0A     * @param input - string to be transformed%0A     * @param pattern - pattern to replace%0A     * @param sub - replacement%0A     * @return the updated string%0A     */
 %0A%09public
@@ -1150,16 +1150,22 @@
 stitute(
+final 
 String i
@@ -1169,16 +1169,22 @@
 g input,
+ final
  String 
@@ -1191,16 +1191,22 @@
 pattern,
+ final
  String 
@@ -1250,16 +1250,30 @@
 gBuffer(
+input.length()
 );%0A%09%09int
@@ -1302,16 +1302,61 @@
 x = -1;%0A
+        final int length = pattern.length();%0A
 %09%09while 
@@ -1474,19 +1474,28 @@
 d(sub);%0A
-%09%09%09
+            
 start = 
@@ -1502,32 +1502,22 @@
 index + 
-pattern.
 length
-()
 ;%0A%09%09%7D%0A%09%09
@@ -1584,100 +1584,6 @@
 %0A%09%7D%0A
-%0A%09/**%0A%09 * Private constructor to prevent instantiation.%0A%09 */%0A%09private StringUtilities() %7B%0A%09%7D%0A%0A
 %7D%0A

Add documentation and tidy up a bit