commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <>
Subject Re: [lang][PROPOSAL] How to best address Bug 25454
Date Sat, 13 Dec 2003 22:30:56 GMT
Stephen Colebourne wrote:
> From: "Phil Steitz" <>
>>The example in the bug report looks like a bug to me, which should be
>>fixed. I doubt seriously that anyone is relying on the following kind of
>>bugged behavior:
>>StringUtils.replaceChars("abc", "abc", "cba") = "aba"
>>This results from the string being modified and re-searched in a loop over
>>the search characters (so multiple "translations" may be applied,
>>depending on the order of characters in the search string).
>>As long as the search and replace character strings have the same length,
>>StringUtils.replaceChars() *should* produce the same results as
>>I suggest, therefore
>>(5) Fix the bug in StringUtils.replaceChars() and improve the javadoc for
>>this method.
> +1, replaceChars should be like calling replaceChars(String, char, char)
> multiple times.

hmm.  I think that was what I was referring to as "bugged." The problem is 
that, as Gary points out above, the old CharSetUtils.translate() really 
works like a simple translation map, passing the string just one time and 
performing the indicated character replacements.  The behavior now in 
replaceChars() is as you describe -- so if the replacement map takes c_1 
to c_2 and c_2 to c_3 (and c_1 preceeds c_2 in the searchString) the net 
effect will be c_1 |-> c_3.  Is this really how we want it to work?


> Stephen
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message