1 /*********************************************************************
5 * Purpose : Utility string functions.
7 * Copyright : Written by and Copyright (C) 2003 the SourceForge
8 * Privoxy team. http://www.privoxy.org/
10 * Based on the Internet Junkbuster originally written
11 * by and Copyright (C) 1997 Anonymous Coders and
12 * Junkbusters Corporation. http://www.junkbusters.com
14 * This program is free software; you can redistribute it
15 * and/or modify it under the terms of the GNU General
16 * Public License as published by the Free Software
17 * Foundation; either version 2 of the License, or (at
18 * your option) any later version.
20 * This program is distributed in the hope that it will
21 * be useful, but WITHOUT ANY WARRANTY; without even the
22 * implied warranty of MERCHANTABILITY or FITNESS FOR A
23 * PARTICULAR PURPOSE. See the GNU General Public
24 * License for more details.
26 * The GNU General Public License should be included with
27 * this file. If not, you can view it at
28 * http://www.gnu.org/copyleft/gpl.html
29 * or write to the Free Software Foundation, Inc., 59
30 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 *********************************************************************/
36 package org.privoxy.activityconsole;
39 * Utility string functions.
40 * @author Last Modified By: $Author$
41 * @version $Rev$-$Date$$State$
45 private static final String
46 COPYRIGHT = org.privoxy.activityconsole.Copyright.COPYRIGHT;
48 /****************************************************************************
49 * This method replaces the preValue with the postValue in the originalString.
51 * @param originalString the string to have replacements
52 * @param preValue The substring value that the string currently contains
53 * @param postValue The substring value to replace the preValue
54 * @param recursive true if replacements should occur recursively
56 * @return String representing the substituted value(s)
57 ****************************************************************************/
58 public static final String replaceSubstring( String originalString
64 String finalString = originalString;
65 int previousFind = originalString.length();
67 int index = originalString.lastIndexOf(preValue);
74 finalString = originalString.substring(0,index)
76 + finalString.substring(index+preValue.length());
78 index = finalString.lastIndexOf(preValue,previousFind);
81 if (index == previousFind)
83 index = finalString.lastIndexOf(preValue,previousFind);
90 /****************************************************************************
91 * This method replaces the preValue with the postValue in the originalString.
93 * @param originalString the string to have replacements
94 * @param preValue The substring value that the string currently contains
95 * @param postValue The substring value to replace the preValue
97 * @return String representing the substituted value(s)
98 ****************************************************************************/
99 public static final String replaceSubstring( String originalString
104 return(replaceSubstring(originalString, preValue, postValue, false));