commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <p...@steitz.com>
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" <phil@steitz.com>
> 
>>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
>>CharSetUtils.translate().
>>
>>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?

Phil


> Stephen
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message